Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 void OnDownloadProgress(CDownload downloader, int progress)
 {
     if (Downloader != downloader) return;
     Progress = progress;
     OnStateChanged(ESourceState.Downloading);
 }
Ejemplo n.º 4
0
 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;
     }
 }