void Download_Manager_Window::Download_File()
{
PromptOK("called");
if (Downloading)
return;//If Function Is Already Working
else
Downloading = true;// If Function Not Working Mark it as Working
if (!List_Download.IsCursor())
{
// If No Downloads Was Found To be Done
Downloading = false;
return;
}
int FileKey = List_Download.Get(0,0);
//SqlId FILESID = "FILES.ID"; // Id Column in Files Table
int ItemId; // To know from which Item This File is
String file_download_path;
String file_name;
String file_link;
SQL*Select(SqlAll()).From(FILES).Where(FILE_ID == FileKey); // Get data of File
if (SQL.Fetch())
{
ItemId = SQL[ITEM_ID];
file_link = SQL[FILE_LINK];
file_name = SQL[FILE_NAME];
SQL*Select(DOWNLOAD_PATH).From(ITEMS,DEFAULT_DOWNLOAD_PATHS).Where((ITEM_ID == ItemId) && (DOWNLOAD_PATHS_SUBJECT_ID == ITEM_SUBJECT) && (DOWNLOAD_PATHS_TYPE_ID == ITEM_TYPE));
if (SQL.Fetch())
{
file_download_path = SQL[DOWNLOAD_PATH];
}
else
{
int user_click = PromptOKCancel("ERROR : Cannot Find Default Download Path&Click Ok To Set Download Path Manualy&Or Cancel to Cancel Download");
if (user_click == IDCANCEL)
{
PromptOK("return");
return;
PromptOK("Strange");
}
else
if (user_click == IDOK)
{
FileSel path;
path.ExecuteSelectDir("Please Select Download Path");
file_download_path = path.GetFile(0);
}
}
}
else
{
PromptOK("ERROR : Program Can't Find LINK ID in Database !!!!");
return;
}
PromptOK("Downloading");
client.URL(file_link);
label_File.SetText(file_name);
label_DownloadDirectory.SetText(file_download_path);
//label_DownloadSpeed.SetText("Downloading");
client.TimeoutMsecs(1000*60*60*60);
String file_data = client.ExecuteRedirect(HttpClient::DEFAULT_MAX_REDIRECT, HttpClient::DEFAULT_RETRIES,THISBACK(progress_indecator));
label_DownloadSpeed.SetText("Downloaded");
RealizePath(file_download_path);
SaveFile(file_download_path+"\\"+file_name, file_data);
SQL*SqlUpdate(FILES)(FILE_DOWNLOAD_PATH,file_download_path).Where(FILE_ID == FileKey);
List_Download.Remove(0);
Download_File();
}
when i add row
this function shows a message that it returned
but also it completes and show a message that it's downloading