public FileUploadProgressEventArgs(string fileName, UploadStatus status, decimal speed, int contentLen) { this.FileName = fileName; this.Status = status; this.Speed = speed; this.ContentLen = contentLen; }
public void DealDeck(UploadStatus status) { m_Rolling = false; m_Wheelthread.Abort(); Thread.Sleep(300); ((StatusForm) Program.Engine.UploadNotificationSystem).Invoke(status == UploadStatus.Error ? (() => notifyIcon1.Icon = Resources.error) : new Action(() => notifyIcon1.Icon = Resources.success)); Thread.Sleep(1000); ((StatusForm) Program.Engine.UploadNotificationSystem).Invoke( new Action(() => notifyIcon1.Icon = Resources.grabbie)); }
public void SetUploadStatus(UploadStatus status) { switch (status) { case UploadStatus.Uploading: Show(); AddToUploadLog("---Beginning of Upload " + DateTime.Now + " ---"); Program.Core.RollTheWheel(); break; case UploadStatus.Success: Invoke(new Action(HideForm)); Program.Core.DealDeck(status); break; case UploadStatus.Error: Program.Core.DealDeck(status); break; } }
public UploadProgress(UploadStatus status, long bytesSent, Exception exception) { _status = status; _bytesSent = bytesSent; _exception = exception; }
public UploadStatusEventArgs(UploadStatus status) { Status = status; }
private void DriveService_ProgressChanged(UploadStatus status, long bytesSent, Exception exception) { try { DriveService_ProgressChanged(new UploadProgress(status, bytesSent, exception)); } catch (Exception exception2) { Log.Error(exception2); } }
public FileUploadEventArgs(UploadStatus status, FileUploadControl fileUploadControl,string fileName) { this.FileName = fileName; this.Status = status; this.FileUploadControl = fileUploadControl; }
void ftpUpload_FileUploadProgress(object sender, FileUploadProgressEventArgs e) { status = e.Status; //decimal speed = e.UploadChange.Speed; this.Invoke(new UpdateUI(delegate() { progressBar1.Value += e.ContentLen; this.lblProgress.Text = (progressBar1.Value / 1024) + "Kb /" + (fileSize / 1024) + "Kb"; })); if (status == UploadStatus.Uploading) { return; } else if (status == UploadStatus.Error) { this.Invoke(new UpdateUI(delegate() { this.lblSpeed.Text = "上传失败"; })); } else if (status == UploadStatus.Cancel) { this.Invoke(new UpdateUI(delegate() { this.lblSpeed.Text = "上传被取消"; })); } else { status = UploadStatus.Succeed; this.Invoke(new UpdateUI(delegate() { this.lblSpeed.Text = "上传成功"; })); } if (FileUploadCompleted != null) { FileUploadCompleted(this, new FileUploadEventArgs(status, this, this.fileName)); } }
/// <summary> /// 将状态设取消 /// </summary> public void Cancel() { status = UploadStatus.Cancel; }
private void Disconnect() { //pauseEvent.Reset(); var tepmStatus = this.CurrentStatus; Suspend(); //suspend upload CurrentStatus = UploadStatus.Disconnected; //Change status to disconnected this._last_status = tepmStatus; }
// main upload method private void Upload(bool continueUpload) { // this method is called after every step of the upload progress var callback = new DelegateTransfer(Upload); // check if last step has been finished successfully if (continueUpload) { // check status of the upload progress switch (ulStatus) { case UploadStatus.Start: // step 1: check if server is locked FireStatus(Strings.Connecting); ulStatus = UploadStatus.CheckLock; CheckLock(callback); break; case UploadStatus.CheckLock: // step 2: lock the server ulStatus = UploadStatus.LockServer; LockServer(callback); break; case UploadStatus.LockServer: // step 3: download global config file ulStatus = UploadStatus.DownloadGlobalConfig; DownloadGlobalConfig(callback); break; case UploadStatus.DownloadGlobalConfig: // step 4: analyse local version (create local file list) FireStatus(Strings.AnalysingNewVersion); ulStatus = UploadStatus.AnalyseNewVersion; AnalyzeNewVersion(callback); break; case UploadStatus.AnalyseNewVersion: // step 5: create remote directory ulStatus = UploadStatus.CreateDirectory; CreateDirectory(callback); break; case UploadStatus.CreateDirectory: // step 6: check if there are versions on the server if (versions.LatestVersion != null) { // step 7a: download all version configs FireStatus(Strings.DownloadingConfigurationFiles); ulStatus = UploadStatus.DownloadVersionConfigs; DownloadVersionConfigs(callback); } else { // step 7b.1: upload local files FireStatus(Strings.UploadingFiles); ulStatus = UploadStatus.UploadFiles; ulFiles = ulLocalFiles.Values.ToList<TransferFile>(); UploadFiles(callback); } break; case UploadStatus.DownloadVersionConfigs: // step 7b.2: build lists of files to upload and files to delete FireStatus(Strings.BuildingConfiguration); ulStatus = UploadStatus.BuildUploadList; BuildUploadListAsync(callback); break; case UploadStatus.BuildUploadList: // step 7b.3: upload local files FireStatus(Strings.UploadingFiles); ulStatus = UploadStatus.UploadFiles; UploadFiles(callback); break; case UploadStatus.UploadFiles: // step 8: upload new version config ulStatus = UploadStatus.UploadVersionConfigs; UploadVersionConfigs(callback); break; case UploadStatus.UploadVersionConfigs: // step 9: upload global config ulStatus = UploadStatus.UploadGlobalConfig; UploadGlobalConfig(callback); break; case UploadStatus.UploadGlobalConfig: // step 10: unlock server and inform the gui FireInformation(Strings.UploadCompleted); fileTransfer.ClearProgress(); UnlockServer(); ResetInterface(); break; } } // a step hasn't been finished successfully: upload aborted else { // fire an event to inform the GUI about the error switch (ulStatus) { case UploadStatus.CheckLock: FireWarning(Strings.CurrentlyLocked); break; case UploadStatus.LockServer: FireError(Strings.UnableToLock); break; case UploadStatus.DownloadGlobalConfig: FireWarning(Strings.VersionTooLow); break; case UploadStatus.AnalyseNewVersion: FireError(Strings.UnableToAnalyzeNewVersion); break; case UploadStatus.CreateDirectory: FireError(Strings.UnableToCreateRemoteDirectory); break; case UploadStatus.DownloadVersionConfigs: FireError(Strings.UnableToDownloadConfigurationFiles); break; case UploadStatus.BuildUploadList: FireError(Strings.UnableToBuildConfiguration); break; case UploadStatus.UploadFiles: case UploadStatus.UploadVersionConfigs: case UploadStatus.UploadGlobalConfig: FireWarning(Strings.UploadFailed); fileTransfer.ClearProgress(); break; } // if remote directory was created, delete it switch (ulStatus) { case UploadStatus.DownloadVersionConfigs: case UploadStatus.BuildUploadList: case UploadStatus.UploadFiles: case UploadStatus.UploadVersionConfigs: case UploadStatus.UploadGlobalConfig: FireStatus(Strings.CleaningUp); DeleteRemoteDirectory(); break; } // unlock the server UnlockServer(); if (exit) // if program should quit, fire exit event FireExit(); else // otherwise restart (test settings & download global config) Start(); } }
public YoutubeJob(YoutubeVideo video, YoutubeAccount account, YoutubeError error, UploadStatus uploadStatus) : this(video, account, uploadStatus) { if (!SimplifyLogging) { LOGGER.Info($"Creating new job with error '{error}'"); } Error = error; }
private void SetupContext() { // Find the current upload context PostBackID = Request.Params["postBackID"]; ProgressBarID = Request.Params["barID"]; UploadModule.BindProgressState(PostBackID, ProgressBarID, this); if (log.IsDebugEnabled) log.Debug("Status " + Status + " when SessionID = " + (HttpContext.Current.Session != null ? HttpContext.Current.Session.SessionID : null)); if (Status == UploadStatus.Unknown) { CurrentStatus = UploadStatus.Unknown; // Status is unknown, so try to find the last post back based on the lastPostBackID param. // If successful, use the status of the last post back. string lastPostBackID = Page.Request.Params["lastPostBackID"]; if (lastPostBackID != null && lastPostBackID.Length > 0 && Page.Request.Params["refresher"] == null) { UploadModule.BindProgressState(lastPostBackID, ProgressBarID, this); if (FileBytesRead == 0 && ProcessingState != null) { Status = UploadStatus.Unknown; } } } else { if (log.IsDebugEnabled) log.Debug("In ProgressPage, PostBackID = " + PostBackID); if (log.IsDebugEnabled) log.Debug("In ProgressPage, Status = " + Status); CurrentStatus = Status; } }
// creates a new update (or fullversion) and uploads it public void Upload(string path, string version, bool FullVersion) { ulLocalPath = (path.EndsWith("\\")) ? path : path + "\\"; ulVersion = version; ulFullVersion = FullVersion; ulStatus = UploadStatus.Start; ulNewFiles = new List<TransferFile>(); ulDeletedFiles = new List<TransferFile>(); ulFiles = new List<TransferFile>(); Upload(true); }
/// <summary> /// 上传文件 /// </summary> /// <param name="do">委托,传入当前上传目标的特定上传函数</param> private void Upload(doUpload @do) { uploadInfo.retries = 1;//第一次上传 UploadStatus uploadStatus = new UploadStatus(); uploadInfo.status.Add(uploadInfo.type, uploadStatus);//初始化并在该文件上传信息中添加新的上传状态 InfoLog.InfoPrintf($"\r\n==============建立{uploadInfo.type}上传任务================\r\n" + $"主播名:{uploadInfo.streamerName}" + $"\r\n标题:{uploadInfo.streamTitle}" + $"\r\n本地文件:{uploadInfo.srcFile}" + $"\r\n上传路径:{uploadInfo.remotePath}" + $"\r\n网盘类型:{uploadInfo.type}" + $"\r\n开始时间:{MMPU.Unix转换为DateTime(uploadInfo.status[uploadInfo.type].startTime.ToString())}" + $"\r\n===============建立{uploadInfo.type}上传任务===============\r\n", InfoLog.InfoClass.必要提示); uploadInfo.status[uploadInfo.type].comments = "建立上传任务"; uploadInfo.status[uploadInfo.type].statusCode = 1; //第一次上传 while (true) //失败后重试,达到最大次数后退出 { try { InfoLog.InfoPrintf($"{uploadInfo.type}:开始第{uploadInfo.retries}次上传", InfoLog.InfoClass.必要提示); uploadInfo.status[uploadInfo.type].comments = $"开始第{uploadInfo.retries}次上传"; uploadInfo.status[uploadInfo.type].statusCode = uploadInfo.retries; //第n次上传 @do(uploadInfo); //执行指定目标的上传函数,失败则异常被捕获 InfoLog.InfoPrintf($"{uploadInfo.type}:上传完毕", InfoLog.InfoClass.必要提示); uploadInfo.status[uploadInfo.type].endTime = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds); //更新结束时间 InfoLog.InfoPrintf($"\r\n=============={uploadInfo.type}上传成功================\r\n" + $"主播名:{uploadInfo.streamerName}" + $"\r\n标题:{uploadInfo.streamTitle}" + $"\r\n本地文件:{uploadInfo.srcFile}" + $"\r\n上传路径:{uploadInfo.remotePath}" + $"\r\n网盘类型:{uploadInfo.type}" + $"\r\n开始时间:{MMPU.Unix转换为DateTime(uploadInfo.status[uploadInfo.type].startTime.ToString())}" + $"\r\n结束时间:{MMPU.Unix转换为DateTime(uploadInfo.status[uploadInfo.type].endTime.ToString())}" + $"\r\n==============={uploadInfo.type}上传成功===============\r\n", InfoLog.InfoClass.必要提示); uploadInfo.status[uploadInfo.type].comments = $"上传成功"; uploadInfo.status[uploadInfo.type].statusCode = 0; //上传成功 break; //成功则退出 } catch (UploadFailure) //此次上传失败 { if (uploadInfo.retries == Uploader.RETRY_MAX_TIMES) //最后一次上传 { InfoLog.InfoPrintf($"{uploadInfo.type}:第{uploadInfo.retries}/{Uploader.RETRY_MAX_TIMES}次{uploadInfo.type}上传失败", InfoLog.InfoClass.必要提示); uploadInfo.status[uploadInfo.type].endTime = Convert.ToInt32((DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds); InfoLog.InfoPrintf($"\r\n=============={uploadInfo.type}上传失败================\r\n" + $"主播名:{uploadInfo.streamerName}" + $"\r\n标题:{uploadInfo.streamTitle}" + $"\r\n本地文件:{uploadInfo.srcFile}" + $"\r\n上传路径:{uploadInfo.remotePath}" + $"\r\n网盘类型:{uploadInfo.type}" + $"\r\n开始时间:{MMPU.Unix转换为DateTime(uploadInfo.status[uploadInfo.type].startTime.ToString())}" + $"\r\n结束时间:{MMPU.Unix转换为DateTime(uploadInfo.status[uploadInfo.type].endTime.ToString())}" + $"\r\n==============={uploadInfo.type}上传失败===============\r\n", InfoLog.InfoClass.必要提示); uploadInfo.status[uploadInfo.type].comments = $"上传失败"; uploadInfo.status[uploadInfo.type].statusCode = -1; //上传失败 break; //达到最大重试次数,失败,退出 } else//未达到最大重试次数,等待一定时间后重试 { InfoLog.InfoPrintf($"{uploadInfo.type}:第{uploadInfo.retries}/{Uploader.RETRY_MAX_TIMES}次上传失败,{Uploader.RETRY_WAITING_TIME}s后重试", InfoLog.InfoClass.必要提示); uploadInfo.status[uploadInfo.type].comments = $"第{uploadInfo.retries}次上传失败,重试等待中"; uploadInfo.retries++; //重试次数+1 Thread.Sleep(Uploader.RETRY_WAITING_TIME * 1000); //等待RETRY_WAITING_TIME秒 uploadInfo.status[uploadInfo.type].statusCode = uploadInfo.retries; //更新第n次重试 } } } }
/// <summary> /// Create a ResumableUploadProgress instance. /// </summary> /// <param name="status">The status of the upload.</param> /// <param name="bytesSent">The number of bytes sent so far.</param> public ResumableUploadProgress(UploadStatus status, long bytesSent) { Status = status; BytesSent = bytesSent; }
public ActionResult UploadResult(UploadStatus status) { return View(status); }
private void Control_PreRender(object sender, EventArgs args) { if (IsDesignTime) return; // Find the current upload context string postBackID = Page.Request.Params["postBackID"]; string barID = Page.Request.Params["barID"]; // Set the status to Cancelled if requested. if (Page.Request.Params["cancelled"] == "true") { UploadModule.CancelPostBack(postBackID); } IUploadProgressState progressState = new UploadProgressState(); UploadModule.BindProgressState(postBackID, barID, progressState); if (progressState.Status == UploadStatus.Unknown) { // Status is unknown, so try to find the last post back based on the lastPostBackID param. // If successful, use the status of the last post back. string lastPostBackID = Page.Request.Params["lastPostBackID"]; if (lastPostBackID != null && lastPostBackID.Length > 0 && Page.Request.Params["refresher"] == null) { UploadModule.BindProgressState(lastPostBackID, barID, progressState); if (progressState.FileBytesRead == 0 && progressState.ProcessingState == null) { progressState.Status = UploadStatus.Unknown; } } } Status = progressState.Status; ProgressInfo progress = null; progress = (ProgressInfo)progressState.ProcessingState; if (progress != null && Status == UploadStatus.Completed) { Status = UploadStatus.ProcessingCompleted; } Attributes["status"] = Status.ToString(); if (WhenStatus != null) { string[] matchingStatuses = WhenStatus.Split(' '); if (Array.IndexOf(matchingStatuses, Status.ToString()) == -1) { this.Visible = false; } } }
private void displayUploadStatusMessage(UploadStatus status, string fileName) { string msg = string.Empty; if (status == UploadStatus.Cancel) { msg = "文件" + fileName + "发送已被取消!"; chatMessageViewerControl1.AddFloatInformation(msg); } else if (status == UploadStatus.Succeed) { //msg = "文件" + fileName + "发送成功!"; } else if (status == UploadStatus.Error) { msg = "文件" + fileName + "发送失败!"; } if (status != UploadStatus.Uploading) { chatMessageViewerControl1.AddInformation(msg); } }
private void lblCancel_Click(object sender, EventArgs e) { ftpUpload.Cancel(); status = UploadStatus.Cancel; }
/// <summary> /// 线程起动上传文件 /// </summary> public void Start() { Thread t = new Thread(new ThreadStart(FtpFileUpload)); t.Start(); status = UploadStatus.Uploading;//正在上传状态 }
// main upload method private void Upload(bool continueUpload) { // this method is called after every step of the upload progress var callback = new DelegateTransfer(Upload); // check if last step has been finished successfully if (continueUpload) { // check status of the upload progress switch (ulStatus) { case UploadStatus.Start: // step 1: check if server is locked FireStatus(Strings.Connecting); ulStatus = UploadStatus.CheckLock; CheckLock(callback); break; case UploadStatus.CheckLock: // step 2: lock the server ulStatus = UploadStatus.LockServer; LockServer(callback); break; case UploadStatus.LockServer: // step 3: download global config file ulStatus = UploadStatus.DownloadGlobalConfig; DownloadGlobalConfig(callback); break; case UploadStatus.DownloadGlobalConfig: // step 4: analyse local version (create local file list) FireStatus(Strings.AnalysingNewVersion); ulStatus = UploadStatus.AnalyseNewVersion; AnalyzeNewVersion(callback); break; case UploadStatus.AnalyseNewVersion: // step 5: create remote directory ulStatus = UploadStatus.CreateDirectory; CreateDirectory(callback); break; case UploadStatus.CreateDirectory: // step 6: check if there are versions on the server if (versions.LatestVersion != null) { // step 7a: download all version configs FireStatus(Strings.DownloadingConfigurationFiles); ulStatus = UploadStatus.DownloadVersionConfigs; DownloadVersionConfigs(callback); } else { // step 7b.1: upload local files FireStatus(Strings.UploadingFiles); ulStatus = UploadStatus.UploadFiles; ulFiles = ulLocalFiles.Values.ToList <TransferFile>(); UploadFiles(callback); } break; case UploadStatus.DownloadVersionConfigs: // step 7b.2: build lists of files to upload and files to delete FireStatus(Strings.BuildingConfiguration); ulStatus = UploadStatus.BuildUploadList; BuildUploadListAsync(callback); break; case UploadStatus.BuildUploadList: // step 7b.3: upload local files FireStatus(Strings.UploadingFiles); ulStatus = UploadStatus.UploadFiles; UploadFiles(callback); break; case UploadStatus.UploadFiles: // step 8: upload new version config ulStatus = UploadStatus.UploadVersionConfigs; UploadVersionConfigs(callback); break; case UploadStatus.UploadVersionConfigs: // step 9: upload global config ulStatus = UploadStatus.UploadGlobalConfig; UploadGlobalConfig(callback); break; case UploadStatus.UploadGlobalConfig: // step 10: unlock server and inform the gui FireInformation(Strings.UploadCompleted); fileTransfer.ClearProgress(); UnlockServer(); ResetInterface(); break; } } // a step hasn't been finished successfully: upload aborted else { // fire an event to inform the GUI about the error switch (ulStatus) { case UploadStatus.CheckLock: FireWarning(Strings.CurrentlyLocked); break; case UploadStatus.LockServer: FireError(Strings.UnableToLock); break; case UploadStatus.DownloadGlobalConfig: FireWarning(Strings.VersionTooLow); break; case UploadStatus.AnalyseNewVersion: FireError(Strings.UnableToAnalyzeNewVersion); break; case UploadStatus.CreateDirectory: FireError(Strings.UnableToCreateRemoteDirectory); break; case UploadStatus.DownloadVersionConfigs: FireError(Strings.UnableToDownloadConfigurationFiles); break; case UploadStatus.BuildUploadList: FireError(Strings.UnableToBuildConfiguration); break; case UploadStatus.UploadFiles: case UploadStatus.UploadVersionConfigs: case UploadStatus.UploadGlobalConfig: FireWarning(Strings.UploadFailed); fileTransfer.ClearProgress(); break; } // if remote directory was created, delete it switch (ulStatus) { case UploadStatus.DownloadVersionConfigs: case UploadStatus.BuildUploadList: case UploadStatus.UploadFiles: case UploadStatus.UploadVersionConfigs: case UploadStatus.UploadGlobalConfig: FireStatus(Strings.CleaningUp); DeleteRemoteDirectory(); break; } // unlock the server UnlockServer(); if (exit) { // if program should quit, fire exit event FireExit(); } else { // otherwise restart (test settings & download global config) Start(); } } }
public void CopyFrom(object source) { UploadState src = (UploadState)source; this._BytesPerSec = src._BytesPerSec; this._BytesRead = src._BytesRead; this._BytesTotal = src._BytesTotal; this._Failure = src._Failure; this._FileBytesRead = src._FileBytesRead; this._Files = src._Files; this._MultiRequestObject = src._MultiRequestObject; this._PostBackID = src._PostBackID; this._ProcessingStateDict = src._ProcessingStateDict; this._Rejection = src._Rejection; this._Status = src._Status; this.BytesReadAtLastMark = src.BytesReadAtLastMark; this.IsMerging = src.IsMerging; this.TimeOfFirstByte = src.TimeOfFirstByte; this.TimeOfLastMark = src.TimeOfLastMark; this.TimeOfLastMerge = src.TimeOfLastMerge; this.UploadStateAtLastMerge = src.UploadStateAtLastMerge; }
private void curUpl_UploadStatusChanged( object sender, UploadStatus e ) { if (e != UploadStatus.Uploaded && this.CurrentStatus != UploadStatus.Canceled) { this.CurrentStatus = e; } }