private void UploadStatusEvent(object sender, UploadStatusEventArgs e) { if (e.PhotoUploadStatusDictionary != null) { Logger.Verbose("Photo Upload Broadcast received : " + e.PhotoUploadStatusDictionary.Count); } }
protected void SlickUpload1_UploadComplete(object sender, UploadStatusEventArgs e) { uploadPanel.Visible = false; resultPanel.Visible = true; if (e.UploadedFiles != null && e.UploadedFiles.Count > 0) { resultsRepeater.DataSource = e.UploadedFiles; resultsRepeater.DataBind(); resultsRepeater.Visible = true; } else { resultsRepeater.Visible = false; } }
private void UploadStatusEvent(object sender, UploadStatusEventArgs e) { CustomerPhotoViewModel vm = this.ViewModel as CustomerPhotoViewModel; if (e.PhotoUploadStatusDictionary == null || vm == null) { return; } foreach (var map in e.PhotoUploadStatusDictionary) { CustomerPhoto photo = new CustomerPhoto { Id = map.Key, PhotoUploadStatus = map.Value }; vm.PhotoUpdated(photo); } }
protected void SlickUpload1_UploadComplete(object sender, UploadStatusEventArgs e) { uploadPanel.Visible = false; resultPanel.Visible = true; if (e.UploadedFiles != null && e.UploadedFiles.Count > 0) { // Simulate post processing Dictionary<string, string> status = new Dictionary<string, string>(); for (int i = 0; i < 100; i++) { status["percentComplete"] = i.ToString(); status["percentCompleteText"] = i.ToString() + "%"; // Update the progress context e.Status.UpdatePostProcessStatus(status); System.Threading.Thread.Sleep(100); } status["percentComplete"] = "100"; status["percentCompleteText"] = "100 %"; // Update the progress context as complete e.Status.UpdatePostProcessStatus(status); resultsRepeater.DataSource = e.UploadedFiles; resultsRepeater.DataBind(); resultsRepeater.Visible = true; } else { resultsRepeater.Visible = false; } }
protected void uploadManager_UploadComplete(object sender, UploadStatusEventArgs args) { uploadPanel.Visible = false; resultsMessage.Visible = true; if (args.Status.Reason == UploadTerminationReason.NotTerminated) { if ((sender as UploadManager).UploadedFiles.Count == 0) { return; } string filename = Constant.GetRandomFileName(ConfigurationManager.AppSettings["UploadVideo"].ToString()) + args.Status.CurrentFileName.Substring(args.Status.CurrentFileName.LastIndexOf(".")); if (System.IO.File.Exists(filename)) { resultsMessage.Text = "文件已经存在"; } else { System.IO.File.Move(Server.MapPath("../") + "/TempUploadFile/" + args.Status.CurrentFileName, filename); Response.Write("成功上传"); Response.End(); } } else { if (args.Status.Reason == UploadTerminationReason.Disconnected) { resultsMessage.Text = "已取消上传"; } else { resultsMessage.Text = "上传时发生一个错误" + args.Status.ErrorMessage; } resultsMessage.Style["color"] = "red"; } }
protected void SlickUpload1_UploadComplete(object sender, UploadStatusEventArgs e) { uploadPanel.Visible = false; resultPanel.Visible = true; if (e.UploadedFiles != null && e.UploadedFiles.Count > 0) { Dictionary<string, string> status = new Dictionary<string, string>(); status["percentComplete"] = "0"; status["percentCompleteText"] = "0%"; // Update the progress context e.Status.UpdatePostProcessStatus(status); string bucket = ConfigurationManager.AppSettings["awsBucket"]; long totalLength = 0; long transferredLength = 0; // Calculate total length foreach (UploadedFile uFile in e.UploadedFiles) totalLength += uFile.ContentLength; // Upload each file foreach (UploadedFile uFile in e.UploadedFiles) { string fileName = uFile.LocationInfo[FileUploadStreamProvider.FileNameKey]; using (ObjectAddRequest req = new ObjectAddRequest(bucket, Server.UrlEncode(uFile.ClientName))) { req.LoadStreamWithFile(fileName); // Create and fire up a new thread to do the actual upload Thread t = new Thread(UploadThread); t.Start(req); while (t.IsAlive && req.BytesTransferred < req.BytesTotal) { float percentComplete = ((transferredLength + req.BytesTransferred) / (float)totalLength); status["percentComplete"] = (percentComplete * 100).ToString("f2"); status["percentCompleteText"] = percentComplete.ToString("p2"); // Update the progress context e.Status.UpdatePostProcessStatus(status); // wait 500ms Thread.Sleep(500); } } transferredLength += uFile.ContentLength; File.Delete(fileName); } status["percentComplete"] = "100"; status["percentCompleteText"] = "100 %"; // Update the progress context e.Status.UpdatePostProcessStatus(status, true); resultsRepeater.DataSource = e.UploadedFiles; resultsRepeater.DataBind(); resultsRepeater.Visible = true; if (_s3Exception != null) { errorMessage.InnerHtml += _s3Exception.GetType().FullName + ": " + _s3Exception.Message; errorMessage.Visible = true; } } else { resultsRepeater.Visible = false; } }