Example #1
0
 public void InitDownload()
 {
     // 停止正在进行的下载
     PauseDownload();
     // 置空当前处理对象
     downloadTaskList.Clear();
     downloadSpeed        = null;
     downloadProcess      = null;
     downloadCountProcess = null;
     unzipProcess         = null;
     downloadResult       = null;
     curDownloadTask      = null;
     curUnzipTask         = null;
     downloadedCount      = 0;
     IsPause = false;
 }
Example #2
0
        public bool CreateDownloadTask(string _reomteUrl, string _localFolder, string _fileName, string _fileSuffix, long _fileSize, bool _isZipFile = true, long?_unZipSize = null)
        {
            if (downloadTaskList.ContainsKey(_reomteUrl))
            {
                return(false);
            }

            DownloadTask task = new DownloadTask(_reomteUrl, _localFolder, _fileName, _fileSuffix, _fileSize, _isZipFile, _unZipSize);

            task.OnHandleError      = HotterError;
            task.OnDownloadComplete = BeginDownload;
            task.OnUnzipComplete    = BeginUnzip;
            task.OnDownloadSpeed    = DownloadSpeed;
            task.OnDownloadProcess  = DownloadProcess;
            task.OnUnzipProcess     = UnzipProcess;

            downloadTaskList.Add(_reomteUrl, task);

            return(true);
        }
Example #3
0
 private void BeginUnzip()
 {
     ABCheck.Instance.EnterInvoke(() =>
     {
         curUnzipTask = null;
         foreach (DownloadTask task in downloadTaskList.Values)
         {
             if (task.IsNeedUnzip)
             {
                 curUnzipTask = task;
                 curUnzipTask.UnZip();
                 break;
             }
         }
         // 解压完成后,整个下载就结束了
         if (null == curUnzipTask)
         {
             if (null != downloadResult)
             {
                 downloadResult(true, null);
             }
         }
     });
 }
Example #4
0
 public void BeginDownload()
 {
     ABCheck.Instance.EnterInvoke(() =>
     {
         downloadedCount++;
         curDownloadTask = null;
         downloadprocess = -1;
         unzipprocess    = -1;
         DownloadCountProcess(downloadedCount);
         foreach (var task in downloadTaskList.Values)
         {
             if (task.DownloadProcess < 1)
             {
                 curDownloadTask = task;
                 curDownloadTask.Start();
                 break;
             }
         }
         if (null == curDownloadTask)
         {
             BeginUnzip();
         }
     });
 }