示例#1
0
        /// <summary>
        /// Constructor to support serialization required for storing the task.
        /// </summary>
        /// <param name="info">The serialization information.</param>
        /// <param name="context">The serialization context.</param>
        protected DownloadTask(SerializationInfo info, StreamingContext context)
        {
            var reader = new SerializationInfoReader(info, context);

            DownloadItem    = reader.Get("_manifest", (DownloadItem)null);
            _state          = reader.Get("_state", DownloadTaskState.None);
            _id             = reader.Get("_id", Guid.Empty);
            JobId           = reader.Get("_jobId", (Guid?)null);
            TransferredSize = reader.Get("_transferSize", 0);
            FileSize        = reader.Get("_fileSize", 0);
            _createDate     = TimeZoneInfo.ConvertTime(reader.Get("_createDate", DateTime.Now), TimeZoneInfo.Local);
            _fileName       = reader.Get("_fileName", (string)null);
            _errorText      = reader.Get("_errorText", (string)null);
            _supportsBITS   = reader.Get("_supportsBITS", false);

            if (reader.Contains("_downloadFilesBase"))
            {
                DownloadFilesBase = reader.Get("_downloadFilesBase", (string)null);
            }
            else /* there used to be a typo in the field name */
            {
                DownloadFilesBase = reader.Get("_donwnloadFilesBase", (string)null);
            }
            if (reader.Contains("_downloadErrorResumeCount"))
            {
                _downloadErrorResumeCount = reader.Get("_downloadErrorResumeCount", 0);
            }
        }
示例#2
0
 public DownloadDataEventArgs(string url, string path, string name, DownloadTaskState downloadTaskState)
 {
     this.Name  = name;
     this.Url   = url;
     this.Path  = path;
     this.State = downloadTaskState;
 }
示例#3
0
 public DownloadDataEventArgs(DownloadTask downloadTask)
 {
     this.Name  = System.IO.Path.GetFileName(downloadTask.Path);
     this.Url   = downloadTask.Url;
     this.Path  = downloadTask.Path;
     this.State = downloadTask.State;
 }
 public DownloadTask()
 {
     state = DownloadTaskState.Idle;
     urls = new List<string>();
     downloadedContents = null;
     thread = null;
     abortSignal = false;
     urlsFile = "frequency.txt";
     writePath = "IcibaHtmls\\";
     wordToUrl = GetRealUrl;
 }
示例#5
0
 internal void InvokeStateChangeEvent(string name, string url, string path, DownloadTaskState state)
 {
     if (this.StateChange != null)
     {
         DownloadDataEventArgs eventArgs = new DownloadDataEventArgs()
         {
             Name  = name,
             Url   = url,
             Path  = path,
             State = state
         };
         this.StateChange.Invoke(this, eventArgs);//触发事件
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DownloadTaskStateChangedEventMessage"/> class.
 /// </summary>
 /// <param name="state">The state.</param>
 public DownloadTaskStateChangedEventMessage(DownloadTaskState state)
 {
     State = state;
 }
 private void ChangeState(DownloadTaskState newState)
 {
     state = newState;
     Log("change state, new state is: " + newState);
 }
        /// <summary>
        /// Changes the state of the download task.
        /// </summary>
        /// <param name="downloadTaskState">State of the download task.</param>
        public void ChangeState(DownloadTaskState downloadTaskState)
        {
            State = downloadTaskState;

            m_EventManager.EventPublisher.Publish(new DownloadTaskStateChangedEventMessage(downloadTaskState));
        }
        /// <summary>
        /// Changes the state of the download task.
        /// </summary>
        /// <param name="downloadTaskState">State of the download task.</param>
        public void ChangeState(DownloadTaskState downloadTaskState)
        {
            State = downloadTaskState;

            m_EventManager.EventPublisher.Publish(new DownloadTaskStateChangedEventMessage(downloadTaskState));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DownloadTaskStateChangedEventMessage"/> class.
 /// </summary>
 /// <param name="state">The state.</param>
 public DownloadTaskStateChangedEventMessage(DownloadTaskState state)
 {
     State = state;
 }