Ejemplo n.º 1
0
        /// <summary>
        /// 下载失败回调函数.
        /// </summary>
        /// <param name="iDownloadInfo">下载信息.</param>
        /// <param name="iIsManifest">Manifest文件标志位.</param>
        /// <param name="iErrors">错误信息.</param>
        public void OnDownloadFail(DownloaderBase iDownloader, DownloadTargetInfo iDownloadInfo, bool iIsManifest, List <ErrorDetail> iErrors)
        {
            // 线程安全:添加错误信息至列表
            lock (_downloaderErrorLock) {
                string errsStr = null;
                foreach (ErrorDetail error in iErrors)
                {
                    if (string.IsNullOrEmpty(errsStr) == true)
                    {
                        errsStr = string.Format("Type:{0} State:{1} Detail:{2} Retries:{3}",
                                                error.Type.ToString(), error.State.ToString(), error.Detail, error.Retries.ToString());
                    }
                    else
                    {
                        errsStr = string.Format("{0} \n Type:{1} State:{2} Detail:{3} Retries:{4}",
                                                errsStr, error.Type.ToString(), error.State.ToString(), error.Detail, error.Retries.ToString());
                    }
                }

                this.Error("OnDownloadFail()::Download Failed!!! {0} \n Detail:{1}",
                           iDownloadInfo.toString(), errsStr);

                this._errors.AddRange(iErrors);
                this._State = TRunState.Error;

                if (iDownloader != null)
                {
                    iDownloader.Dispose();
                    GC.Collect();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 下载成功回调函数.
        /// </summary>
        /// <param name="iDownloadInfo">下载信息.</param>
        /// <param name="iRetries">重试次数.</param>
        public void OnDownloadSuccessed(DownloaderBase iDownloader, DownloadTargetInfo iDownloadInfo, int iRetries)
        {
            this.Info("OnDownloadSuccessed()::Download Successed. {0} Retries:{1}",
                      iDownloadInfo.toString(), iRetries);

            DownloadList.GetInstance().DownloadCompleted(iDownloadInfo.ID, iDownloadInfo.FileType);

            if (true == iDownloadInfo.Downloaded)
            {
                // 文件拷贝
                iDownloadInfo.CopyTargetWhenDownloadCompleted();

                if (iDownloader != null)
                {
                    iDownloader.Dispose();
                    GC.Collect();
                }

                lock (_downloaderCountLock) {
                    --this.DownloaderCount;
                }
            }
        }