Exemplo n.º 1
0
        /// <summary>
        /// Handles the <see cref="FileDownloader.DownloadComplete"/> event of the file downloader.
        /// </summary>
        /// <remarks>
        /// This stops the updating of the progress properties.
        /// </remarks>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">A <see cref="CompletedDownloadEventArgs"/> describing the event arguments.</param>
        private void Downloader_DownloadComplete(object sender, CompletedDownloadEventArgs e)
        {
            m_tmrUpdater.Stop();

            if (m_areWaitForDownload != null)
            {
                m_areWaitForDownload.Set();
            }

            if (Status == TaskStatus.Paused)
            {
                OnTaskEnded(String.Format("Paused: {0}", ((FileDownloader)sender).URL), ((FileDownloader)sender).TempFiles);
            }
            else if (!e.GotEntireFile)
            {
                if (Status == TaskStatus.Cancelling)
                {
                    m_fdrDownloader.Cleanup();
                    Status = TaskStatus.Cancelled;
                }
                else
                {
                    Status = TaskStatus.Incomplete;
                }

                ErrorCode = ((FileDownloader)sender).ErrorCode;
                ErrorInfo = ((FileDownloader)sender).ErrorInfo;

                if (ErrorCode == "666")
                {
                    OnTaskEnded(String.Format("{1}: {0} , ", ((FileDownloader)sender).URL, ErrorInfo), ((FileDownloader)sender).URL);
                }
                else if (!string.IsNullOrEmpty(e.FailureMessage))
                {
                    Status = TaskStatus.Error;
                    OnTaskEnded(e.FailureMessage, ((FileDownloader)sender).URL);
                }
                else
                {
                    OnTaskEnded(String.Format("Error: {0} , unable to finish the download.", ((FileDownloader)sender).URL), ((FileDownloader)sender).URL);
                }
            }
            else
            {
                Status = TaskStatus.Complete;
                OnTaskEnded(new DownloadedFileInfo(((FileDownloader)sender).URL, e.SavedFileName));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the <see cref="FileDownloader.DownloadComplete"/> event of the file downloader.
        /// </summary>
        /// <remarks>
        /// This stops the updating of the progress properties.
        /// </remarks>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">A <see cref="CompletedDownloadEventArgs"/> describing the event arguments.</param>
        private void Downloader_DownloadComplete(object sender, CompletedDownloadEventArgs e)
        {
            FileDownloader fdrDownloader = ((FileDownloader)sender);

            if (!e.GotEntireFile)
            {
                fdrDownloader.Cleanup();
                m_dicSaveDownloadPaths[fdrDownloader] = null;
            }
            else
            {
                m_dicSaveDownloadPaths[fdrDownloader] = e.SavedFileName;
            }

            if (m_dicWaitForDownloads.ContainsKey(fdrDownloader))
            {
                m_dicWaitForDownloads[fdrDownloader].Set();
            }
        }