private void StartDownloadA() { NeedGoodGonfigData(); string url = URL; string GzFileName = ""; string GzFullFileName = ""; GzFileName = Utils.GetFileNameFromURL(url); if (GzFileName == url) { OnDownloadEvent(null, ESimpleEvent.finished, ""); return; } GzFullFileName = TopManager.DownloadFolder + "\\" + GzFileName; if (File.Exists(GzFullFileName)) { File.Delete(GzFullFileName); } Downloader = TopManager.St.DownloaderManager.AddDownload(OnDownloadEvent, url, GzFullFileName, OnDownloadProgress); if (Downloader == null) { DoError("Allready downloading the file"); return; } return; }
void OnDownloadEvent(CDownload downloader, ESimpleEvent downloadEvent, string msg) { lock (this) { switch (downloadEvent) { case ESimpleEvent.started: OnStateChanged(ESourceState.DownloadStarted); break; case ESimpleEvent.canceled: LogError("download canceled"); OnStateChanged(ESourceState.DownloadFailed); break; case ESimpleEvent.failed: OnStateChanged(ESourceState.DownloadFailed); break; case ESimpleEvent.finished: OnStateChanged(ESourceState.DownloadFinished); break; } } OnSubTaskEvent(downloadEvent); }
void OnDownloadProgress(CDownload downloader, int progress) { if (Downloader != downloader) return; Progress = progress; OnStateChanged(ESourceState.Downloading); }
public void ClearState() { lock (this) { if (TaskState == ESimpleEvent.started) { DoError("busy"); } ScheduledTasks.Clear(); CancelToken = false; State = ESourceState.None; TaskState = ESimpleEvent.none; SubTaskState = ESimpleEvent.none; Downloader = null; GzipExtract = null; Progress = 0; } }