Beispiel #1
0
        private async void downloadButton_Click(object sender, RoutedEventArgs e)
        {
            var progress = new Progress <OperationStatus>(status =>
            {
                this.statusLabel.Content = $"Connection: {status.ConnectionStatus}, " +
                                           $"Last operation: {status.LastOperationType}, " +
                                           $"last status code: {status.StatusCode}";
            });

            try
            {
                string host           = this.ipTextbox.Text;
                int    port           = int.Parse(this.portTextbox.Text);
                string relativePath   = this.fileTextbox.Text;
                string downloadFolder = this.downloadFolderTextbox.Text;

                BaseDownloader downloader = sender == this.downloadHttpButton
                    ? new HttpClientDownloader(host, port, relativePath, downloadFolder)
                    : new TcpClientDownloader(host, port, relativePath, downloadFolder);

                await downloader.DownloadAsync(progress);

                this.errorLabel.Content = string.Empty;
            }
            catch (Exception ex)
            {
                this.errorLabel.Content = $"Exception: {ex.Message}";
            }
        }
Beispiel #2
0
 public Crawler()
 {
     Downloader = new BaseDownloader();
     Schduler   = new DefaultSchduler();
     Processor  = new DefaultProcessor();
     inst       = this;
 }
Beispiel #3
0
 /// <summary>
 /// 更新状态栏
 /// </summary>
 /// <param name="Message"></param>
 /// <param name="Status"></param>
 /// <param name="FullSize"></param>
 /// <param name="CurrentBytes"></param>
 /// <param name="EstimatedTimeLeft"></param>
 /// <param name="Speed"></param>
 private void ftpCtl1_StatusUpdateEvent(string Message, DotNetRemoting.DStatus Status, long FullSize, long CurrentBytes, TimeSpan EstimatedTimeLeft, double Speed)
 {
     toolStripLabelStatus.Text = Status.ToString();
     label_mess.Text           = Message;
     toolStripLabelTime.Text   = BaseDownloader.TimeSpanToString(EstimatedTimeLeft);
     toolStripLabelSpeed.Text  = Speed.ToString("F1") + " Kb/s";
     if (Status == DStatus.complete || Status == DStatus.error)
     {
         if (Status == DStatus.complete)
         {
             listViewData.AppendLog(new string[] { "test", "success" });
         }
         btnUpLoad.Text = "UpLoad";
     }
 }
Beispiel #4
0
 /// <summary>
 /// 更新上传进度条
 /// </summary>
 /// <param name="Message"></param>
 /// <param name="Status"></param>
 /// <param name="FullSize"></param>
 /// <param name="CurrentBytes"></param>
 /// <param name="EstimatedTimeLeft"></param>
 /// <param name="Speed"></param>
 private void FtpClientCtrl_StatusUpdateEvent(string Message, DStatus Status, long FullSize, long CurrentBytes, TimeSpan EstimatedTimeLeft, double Speed)
 {
     toolStripLabelStatus.Text = Status.ToString();
     label_mess.Text           = Message;
     toolStripLabelTime.Text   = BaseDownloader.TimeSpanToString(EstimatedTimeLeft);
     toolStripLabelSpeed.Text  = Speed.ToString("F1") + " Kb/s";
     isUpLoading = true;
     if (Status == DStatus.complete || Status == DStatus.error)
     {
         isUpLoading = false;
         if (Status == DStatus.complete)
         {
             listViewData.AppendLog(new string[] { image.FileName, Status.ToString() });
         }
     }
 }