Наследование: System.ComponentModel.AsyncCompletedEventArgs
Пример #1
0
 void wc_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     skinButton1.Enabled = true;
     sw.Stop();
     skinButton1.Text = "选择文件";
     skinProgressBar1.Value = 0;
 }
        private void WClient_UploadFileCompleted(object sender, System.Net.UploadFileCompletedEventArgs e)
        {
            timer.Stop();
            timer.Dispose();

            notificationManager.Cancel(notificationID);

            notificationID      = new Random().Next(10000, 99999);
            notificationBuilder = new Notification.Builder(ApplicationContext);
            notificationBuilder.SetOngoing(false)
            .SetSmallIcon(Resource.Drawable.icon);

            if (e.Cancelled == false && e.Error == null)
            {
                JsonResult result = JsonConvert.DeserializeObject <JsonResult>(System.Text.Encoding.UTF8.GetString(e.Result));

                if (result != null && result.Success == true)
                {
                    notificationBuilder.SetContentTitle("Upload complete");
                }
                else
                if (result.Success == false)
                {
                    notificationBuilder.SetContentTitle("Upload failed");
                    Intent        notificationIntent = new Intent(ApplicationContext, typeof(UploadErrorActivity));
                    PendingIntent contentIntent      = PendingIntent.GetActivity(ApplicationContext,
                                                                                 0, notificationIntent, PendingIntentFlags.UpdateCurrent);
                    notificationBuilder.SetContentIntent(contentIntent);
                    notificationBuilder.SetContentText(result.Message);
                    notificationBuilder.SetAutoCancel(true);
                }
            }
            else
            {
                notificationBuilder.SetContentTitle("Upload failed");
            }

            notification = notificationBuilder.Build();
            notificationManager.Notify(notificationID, notification);

            notificationID = 0;

            notificationBuilder.Dispose();
            notification.Dispose();
            notificationManager.Dispose();

            uploadedBytes   = 0;
            totalBytes      = 0;
            percentComplete = 0;
            wClient.Dispose();
        }
Пример #3
0
 private void GetResults(object sender, System.Net.UploadFileCompletedEventArgs e) //Get  Response from Server
 {
     try
     {
         string Results = System.Text.Encoding.UTF8.GetString(e.Result); //Get Response
         AddtoLV(Results);                                               //Add Response to Listivew
         this.btnScan.Enabled = true;
     }
     catch (Exception ex)
     {
         this.btnScan.Enabled = true;
         MessageBox.Show(ex.Message); //Show Messagebox On Error
     }
 }
        void UploadImageRequestCompleted(object sender, UploadFileCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBoxResult r = MessageBox.Show(e.Error.Message, "Network error");
                Debug.WriteLine(e.Error.Message);
                MainWindow win = (MainWindow)Application.Current.MainWindow;
                win.ProgressBar.Visibility = Visibility.Collapsed;
                this.Visibility = Visibility.Visible;
            }
            else
            {
                string result = System.Text.Encoding.UTF8.GetString(e.Result);
                System.Web.Script.Serialization.JavaScriptSerializer js =
                    new System.Web.Script.Serialization.JavaScriptSerializer();
                var obj = js.Deserialize<dynamic>(result);
                if (obj["status_code"] != 200)
                    throw new Exception(String.Format(
                    "Server error (HTTP {0}: {1}).",
                    obj["status_code"],
                    obj["status_txt"]));
                else
                {
                    string imageUrl = (obj["data"])["thumb_url"];

                    Dictionary<string, string> dic = new Dictionary<string, string>();
                    dic.Add("name", Name.Text);
                    dic.Add("description", Description.Text);
                    dic.Add("picture", imageUrl);
                    dic.Add("author", Author.Text);
                    dic.Add("status", Status.Text);
                    dic.Add("published_date", Date.Text);
                    dic.Add("page_count", PageCount.Text);

                    var addBookHandler = new HttpHandler(dic, this);
                    addBookHandler.RequestCompleted += HandlerAddBookRequestCompleted;
                    addBookHandler.AddBook();
                }
            }
        }
Пример #5
0
		protected virtual void OnUploadFileCompleted (UploadFileCompletedEventArgs e)
		{
			CompleteAsync ();
			if (UploadFileCompleted != null)
				UploadFileCompleted (this, e);
		}
Пример #6
0
 void WebClientUploadCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     string response = System.Text.Encoding.UTF8.GetString(e.Result);
     string[] messageFromServer = response.Split(' ');
     if (messageFromServer.Count() == 1)
     {
         MessageBox.Show("Operacja zakończona sukcesem.", "PDF Asystent",
             MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     else if (messageFromServer[0] == "OK")
     {
         string temp = "";
         for (int i = 1; i < messageFromServer.Count(); i++)
         {
             temp += messageFromServer[i] + " ";
         }
         MessageBox.Show("Operacja zakończona sukcesem.\r\n" + temp, "PDF Asystent",
             MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     else if (messageFromServer[0] == "ERROR")
     {
         string temp = "";
         for (int i = 1; i < messageFromServer.Count(); i++)
         {
             temp += messageFromServer[i] + " ";
         }
         MessageBox.Show("Wystąpił błąd podczas wysyłania pliku na serwer Elibri.\r\n" + temp, "PDF Asystent",
             MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
 }
        // Progress Bar

        private void WebClientUploadCompleted(object sender, UploadFileCompletedEventArgs e)
        {
            double value = (ProgressBarUpload.Maximum / ListBoxImages.Items.Count) * (uploadedImagesCount + 1);
            ProgressBarAnimation(value, TimeSpan.FromMilliseconds(250));
        }
Пример #8
0
        void SubmitPkgFileUploadCompleted(object sender, UploadFileCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =>
                {
                    DisplayError("Upload failed.");
                }));
                return;
            }

            // The upload is finished, clean up
            string resp = System.Text.Encoding.ASCII.GetString(e.Result);

            // Interpret result
            var items = resp.Split('\n');
            int requestStatus = 0, errCode = 0;
            //long requestId = 0;
            foreach (var item in items)
            {
                var pair = item.Split('=');
                if (pair.Count() != 2)
                    continue;
                var name = pair[0];
                var value = pair[1];
                if (name == "requestStatus")
                    requestStatus = Convert.ToInt32(value);
                else if (name == "requestId")
                    RequestId = Convert.ToInt64(value);
                else if (name == "errCode")
                    errCode = Convert.ToInt32(value);
            }

            var thread = new System.Threading.Thread(new System.Threading.ThreadStart(WaitForPkgCreation));
            thread.Start();
        }
 protected virtual new void OnUploadFileCompleted(UploadFileCompletedEventArgs e)
 {
 }
 protected virtual new void OnUploadFileCompleted(UploadFileCompletedEventArgs e)
 {
 }
Пример #11
0
 /// <summary>
 /// 异步上传文件完成之后触发的事件
 /// </summary>
 /// <paramKey colName="sender">下载对象</paramKey>
 /// <paramKey colName="e">数据信息对象</paramKey>
 void client_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     if (UploadFileCompleted != null)
     {
         UploadFileCompleted(sender, e);
     }
 }
Пример #12
0
 private void UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     if (!e.Cancelled)
     {
         _curTransfer.Status = FileTransferStatus.Completed;
     }
     else
     {
         _curTransfer.Status = FileTransferStatus.Cancelled;
     }
     _reset.Set();
 }
Пример #13
0
 private void Webclient_UploadFileCompleted(object sender, System.Net.UploadFileCompletedEventArgs e)
 {
     throw new NotImplementedException();
 }
Пример #14
0
 public void UploadFileCompleted(Object sender, UploadFileCompletedEventArgs e)
 {
     Notify("Upload completed!");
 }
Пример #15
0
 private void UploadCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     _uploadWindow.EnableOkButton();
     //MessageBox.Show("Upload complete!");
 }
Пример #16
0
 private void OnUploadFileCompleted(object uploadSender, UploadFileCompletedEventArgs uploadEventArgs)
 {
     Cursor = Cursors.Default;
     if (uploadEventArgs.Error == null)
     {
         Msg.Inform(this, Resources.ErrorReportSent + Environment.NewLine + Encoding.UTF8.GetString(uploadEventArgs.Result), MsgSeverity.Info);
         Close();
     }
     else
     {
         Msg.Inform(this, uploadEventArgs.Error.Message, MsgSeverity.Error);
         commentBox.Enabled = detailsBox.Enabled = buttonReport.Enabled = buttonCancel.Enabled = true;
     }
 }
Пример #17
0
 protected virtual void OnUploadFileCompleted(UploadFileCompletedEventArgs e)
 {
     throw new NotImplementedException();
 }
Пример #18
0
        void SubmitRdpCaptureFileUploadCompleted(object sender, UploadFileCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =>
                {
                    DisplayError("Upload failed: " + e.Error.Message);
                }));
                return;
            }

            // The upload is finished. Read response.
            string resp = System.Text.Encoding.ASCII.GetString(e.Result).Trim();
            if (string.IsNullOrEmpty(resp))
            {
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =>
                {
                    DisplayError("Upload failed.");
                }));
                return;
            }
            if (resp.StartsWith("ERR:", StringComparison.InvariantCultureIgnoreCase))
            {
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =>
                {
                    var errStr = resp.Substring("ERR:".Length).Trim();
                    if (errStr.Equals("Account limit reached", StringComparison.InvariantCultureIgnoreCase))
                        DisplayError("Account quota reached. Consider upgrading your account.");
                    else
                        DisplayError("Error: " + errStr);
                }));
                return;
            }

            var thread = new Thread(new ParameterizedThreadStart(StartRdpCapturePlay));
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start(resp);
        }
Пример #19
0
        private void UploadFileAsyncReadCallback(byte [] returnBytes, Exception exception, AsyncOperation asyncOp) {

            UploadFileCompletedEventArgs eventArgs =
                new UploadFileCompletedEventArgs(returnBytes, exception, m_Cancelled, asyncOp.UserSuppliedState);

            InvokeOperationCompleted(asyncOp, uploadFileOperationCompleted, eventArgs);
        }
Пример #20
0
 void client_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     try
     {
         if (e.Cancelled)
         {
             label12.Text = "Cancelled";
         }
         //label1.Invoke((Action)delegate { ReportProgress2(1, 4, e.Result.ToString() + " bytes sent", 0); });
     }
     catch (Exception ee)
     {
         label12.Text = ee.Message;
     }
 }
Пример #21
0
 void UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     string seIri = (string) e.UserState;
     toolStripProgressBar.Value = 100;
     switch (profile.GetFinalState())
     {
         case "Ask":
             InProgressDialog(seIri);
             break;
         case "In Progress":
             UploadCompleteDialog(seIri);
             break;
         case "Complete":
             UploadCompleteDialog(seIri);
             break;
         default:
             InProgressDialog(seIri);
             break;
     }
 }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// uploadfilecompletedeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this UploadFileCompletedEventHandler uploadfilecompletedeventhandler, Object sender, UploadFileCompletedEventArgs e, AsyncCallback callback)
        {
            if(uploadfilecompletedeventhandler == null) throw new ArgumentNullException("uploadfilecompletedeventhandler");

            return uploadfilecompletedeventhandler.BeginInvoke(sender, e, callback, null);
        }
        /// <summary>
        /// Fired when the WebClient finishes.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="uploadFileCompletedEventArgs">The <see cref="UploadFileCompletedEventArgs" /> instance containing the event data.</param>
        private void WebClientOnUploadFileCompleted(object sender, UploadFileCompletedEventArgs uploadFileCompletedEventArgs)
        {
            if (uploadFileCompletedEventArgs.Result.Length < 50)
            {
                _cancel = true;

                TaskDialog.Show(new TaskDialogOptions
                    {
                        MainIcon                = VistaTaskDialogIcon.Error,
                        Title                   = "Upgrade error",
                        MainInstruction         = "Upgrade error",
                        Content                 = "Invalid response received from server: " + Encoding.UTF8.GetString(uploadFileCompletedEventArgs.Result) + "\r\n\r\nTry again using a different server or send your TVShows.db3 file to [email protected] for a \"manual\" conversion. :)",
                        AllowDialogCancellation = true,
                        CustomButtons           = new[] { "OK" }
                    });

                Process.GetCurrentProcess().Kill();
                return;
            }

            using (var ms = new MemoryStream(uploadFileCompletedEventArgs.Result))
            using (var br = new BinaryReader(ms))
            {
                ms.Position = 0;

                try
                {
                    while (ms.Position < ms.Length)
                    {
                        var name = Encoding.UTF8.GetString(br.ReadBytes((int)br.ReadUInt32()));
                        var file = br.ReadBytes((int)br.ReadUInt32());

                        _tdstr = "Extracting file " + name + "...";
                        Directory.CreateDirectory(Path.GetDirectoryName(Path.Combine(Signature.InstallPath, "db", name)));
                        
                        using (var mz = new MemoryStream(file))
                        using (var fs = File.Create(Path.Combine(Signature.InstallPath, "db", name)))
                        using (var gz = new DeflateStream(mz, CompressionMode.Decompress))
                        {
                            gz.CopyTo(fs);
                        }
                    }
                }
                catch (Exception ex)
                {
                    _cancel = true;

                    TaskDialog.Show(new TaskDialogOptions
                        {
                            MainIcon                = VistaTaskDialogIcon.Error,
                            Title                   = "Upgrade error",
                            MainInstruction         = "Upgrade error",
                            Content                 = "Error while unpacking database: " + ex.Message + "\r\n\r\nTry again using a different server or send your TVShows.db3 file to [email protected] for a \"manual\" conversion. :)",
                            AllowDialogCancellation = true,
                            CustomButtons           = new[] { "OK" }
                        });

                    Process.GetCurrentProcess().Kill();
                    return;
                }

                _tdstr = "Finished extracting files!";
            }

            try { File.Move(Path.Combine(Signature.InstallPath, "TVShows.db3"), Path.Combine(Signature.InstallPath, "TVShows.db3.old")); } catch { }
            try { File.Move(Path.Combine(Signature.UACVirtualPath, "TVShows.db3"), Path.Combine(Signature.UACVirtualPath, "TVShows.db3.old")); } catch { }
            try { File.Delete(Path.Combine(Signature.InstallPath, "TVShows.db3.gz")); } catch { }

            _cancel = true;

            TaskDialog.Show(new TaskDialogOptions
                {
                    MainIcon                = VistaTaskDialogIcon.Information,
                    Title                   = "Upgrade finished",
                    MainInstruction         = "Upgrade finished",
                    Content                 = "The software will now quit. Please restart it afterwards.",
                    AllowDialogCancellation = true,
                    CustomButtons           = new[] { "OK" }
                });

            Process.GetCurrentProcess().Kill();
        }
Пример #24
0
        /// <summary>
        /// Handles the completion event from the web client
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void web_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
        {
            // First, stop the marquee
            myProgress.Style = ProgressBarStyle.Blocks;
            myProgress.Value = 120;
            myStatusMsg.Text = "Process Complete... See status dialog.";

            // Display the results
            if (e.Error == null)
                ShowResultDialog("The MPFS image upload was successfully completed.");
            else
            {
                generationResult = false;
                generateLog.Add("\r\nERROR: Could not contact remote device for upload.");
                generateLog.Add("ERROR: " + e.Error.Message);
                ShowResultDialog("The MPFS image could not be uploaded.");
            }
        }
 void uploader_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     resultUrl = Encoding.UTF8.GetString(e.Result).Trim();
     this.Close();
 }
Пример #26
0
        /// <summary>
        /// Parses the response from the async upload.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void _client_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
        {
            try
            {
                Document _result = new Document();

                // Get the response
                string _xml = System.Text.Encoding.Default.GetString(e.Result);

                // Load up the resultant XML
                Response _response = new Response(_xml);

                // Are we cool?
                if (_response.Status != "ok")
                {
                    foreach (int _code in _response.ErrorList.Keys)
                    {
                        // Let the subscribers know, cuz they care.
                        OnErrorOccurred(_code, _response.ErrorList[_code]);
                    }
                }
                else
                {
                    // Parse the response
                    if (_response != null && _response.HasChildNodes && _response.ErrorList.Count < 1)
                    {
                        XmlNode _node = _response.SelectSingleNode("rsp");

                        // Data
                        _result.DocumentId = int.Parse(_node.SelectSingleNode("doc_id").InnerText);
                        _result.AccessKey = _node.SelectSingleNode("access_key").InnerText;

                        // Security
                        if (_node.SelectSingleNode("secret_password") != null)
                        {
                            _result.AccessType = AccessTypes.Private;
                            _result.SecretPassword = _node.SelectSingleNode("secret_password").InnerText;
                        }
                    }
                }

                // Notify those who care.
                Document.OnUploaded(_result);
            }
            catch (Exception _ex)
            {
                OnErrorOccurred(666, _ex.Message, _ex);
            }

        }
 private void m_WebClient_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     try
     {
         if (e.Error != null)
         {
             this.m_ExceptionEncounteredDuringFileTransfer = e.Error;
         }
         if (!e.Cancelled && (e.Error == null))
         {
             this.InvokeIncrement(100);
         }
     }
     finally
     {
         this.CloseProgressDialog();
     }
 }
Пример #28
0
 /// <summary>
 /// 异步上传文件完成之后触发的事件
 /// </summary>
 /// <param name="sender">下载对象</param>
 /// <param name="e">数据信息对象</param>
 void client_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     if (_isDeleteTempFile)
     {
         if (File.Exists(_UploadTempFile))
         {
             File.SetAttributes(_UploadTempFile, FileAttributes.Normal);
             File.Delete(_UploadTempFile);
         }
         _isDeleteTempFile = false;
     }
     if (UploadFileCompleted != null)
     {
         UploadFileCompleted(sender, e);
     }
 }
Пример #29
0
 protected virtual void OnUploadFileCompleted(UploadFileCompletedEventArgs e) {
     if (UploadFileCompleted != null) {
         UploadFileCompleted(this, e);
     }
 }
Пример #30
0
 /// <summary>
 /// 上传完毕后删除生成的临时文件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void uploadCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         String fileName = Encoding.Default.GetString(e.Result);
         String tempFilePath = Application.StartupPath.ToString() + "\\temp\\" + fileName;
         if (File.Exists(tempFilePath))
         {
             File.Delete(tempFilePath);
         }
     }
     else
     {
         MessageBox.Show(e.Error.Message);
     }
 }
Пример #31
0
        void SubmitPkgFileUploadCompleted(object sender, UploadFileCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =>
                {
                    DisplayError("Upload failed: " + e.Error.Message);
                }));
                return;
            }

            // The upload is finished, clean up
            string resp = System.Text.Encoding.ASCII.GetString(e.Result);

            // Interpret result
            var items = resp.Split('\n');
            int requestStatus = 0, errCode = 0;
            //long requestId = 0;
            foreach (var item in items)
            {
                var pair = item.Split('=');
                if (pair.Count() != 2)
                    continue;
                var name = pair[0];
                var value = pair[1];
                if (name == "requestStatus")
                    requestStatus = Convert.ToInt32(value);
                else if (name == "requestId")
                    RequestId = Convert.ToInt64(value);
                else if (name == "errCode")
                    errCode = Convert.ToInt32(value);
            }

            if (requestStatus == 0 || RequestId == 0)
            {
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =>
                {
                    if (errCode == (int)APIRET.INSUFFICIENT_BUFFER)            // Used for indicating account quota is over
                        DisplayError("Account quota reached. Consider upgrading your account.");
                    else if (errCode == (int)APIRET.INSUFFICIENT_PRIVILEGES)   // When modifying an existing package to which the user has no access
                        DisplayError("Insufficient permissions.");
                    else if (requestStatus == (int)PkgStatus.StatusFailed)
                        DisplayError("Packaging failed.");
                    else
                        DisplayError("Submission failed.");
                }));
                return;
            }

            var thread = new Thread(new ThreadStart(WaitForPkgCreation));
            thread.Start();
        }
Пример #32
0
 void UploadFileCompletedCallback(object sender, UploadFileCompletedEventArgs e)
 {
     client.UploadFileCompleted -= UploadFileCompletedCallback;
     File.Delete (filename);
     NetworkManager.Instance.Notify (src, "Upload completed!");
     NetworkManager.Instance.Notify (src, string.Format ("{0}/{1}", ACCESS_URI, filename));
 }
Пример #33
0
        private void UploadCompletedCallback(object sender, UploadFileCompletedEventArgs e)
        {
            if (e.Cancelled)
                __message("upload", "cancelled");
            else
            if (e.Error != null)
            {
                if (e.Error is WebException)
                    web_error(e.Error as WebException, "upload");
                else
                    __message("upload", e.Error.Message);
            }
            else
                if (e.Result != null)
                    __message(null, Encoding.UTF8.GetString(e.Result));

            __endTask(this, Path.GetFileName(fdata) + ".");
        }
Пример #34
0
        void MyWebClient_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
        {
            if (e.Cancelled)
                filename = "";
            if (e.Error != null)
                filename = "";

            progress.Progress= 100;
            FinishDownload (filename);
            try{
                File.Delete(filename);
            }catch{
            }
        }
Пример #35
0
 /// <summary>
 /// This event is raised each time file upload operation completes.
 /// </summary>
 private void Gett_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
 {
     UploadFileCompletedEventHandler copyUploadFileCompleted = UploadFileCompleted;
     if (copyUploadFileCompleted != null)
         copyUploadFileCompleted(this, e);
 }