/// <summary>
        /// Sends this instance.
        /// </summary>
        /// <remarks>Documented by Dev02, 2009-07-15</remarks>
        private void Send()
        {
            TrayIconSetText(trayicon, Properties.Resources.ERROR_TRANSMIT_SENDING, showMessages);

            //begin with chunking and transfer
            ErrorReportService.ErrorReportService errorReportService = null;
            bool success = false;
            try
            {
                if (!SendingCanceled)
                {
                    //read out report data
                    byte[] buffer = File.ReadAllBytes(reportfile);
                    string filename = Path.GetFileName(reportfile);

                    ErrorReportHandler handler = new ErrorReportHandler(new FileInfo(reportfile));
                    string email = String.Empty, description = String.Empty, stacktrace = String.Empty;
                    try
                    {
                        email = handler.GetValue(Resources.ERRORREPORTPATH_USEREMAIL);
                        description = handler.GetValue(Resources.ERRORREPORTPATH_USERDESCRIPTION);
                    }
                    catch (Exception exp)
                    {
                        Trace.WriteLine("Reading user data from ErrorReport Exception: " + exp.ToString());
                    }
                    try
                    {
                        stacktrace = handler.GetValue(Resources.ERRORREPORTPATH_MESSAGE) + Environment.NewLine +
                            handler.GetValue(Resources.ERRORREPORTPATH_STACKTRACE);
                    }
                    catch (Exception exp)
                    {
                        Trace.WriteLine("Reading error data from ErrorReport Exception: " + exp.ToString());
                    }

                    //try to connect to webservice
                    errorReportService = new ErrorReportService.ErrorReportService();
                    errorReportService.Url = Properties.Settings.Default.MLifterErrorHandler_ErrorReportService_ErrorReportService;
                    errorReportService.CookieContainer = new System.Net.CookieContainer();

                    int chunksize = Settings.Default.Transfer_Chunksize;
                    int partcount = Convert.ToInt32(Math.Ceiling(buffer.Length * 1.0 / chunksize));
                    if (success = errorReportService.TransferStart(filename, buffer.Length, chunksize, email, description, stacktrace))
                    {
                        byte[] chunk = new byte[chunksize];
                        for (int partno = 0; partno < partcount; partno++)
                        {
                            if (SendingCanceled)
                            {
                                success = false;
                                break;
                            }

                            int length = partno == partcount - 1 ? buffer.Length % chunksize : chunksize;
                            Buffer.BlockCopy(buffer, partno * chunksize, chunk, 0, length);

                            if (!(success = errorReportService.TransferChunk(filename, chunk, partcount)))
                            {
                                break;
                            }
                            else
                            {
                                TrayIconSetText(trayicon, string.Format(Properties.Resources.ERROR_TRANSMIT_SENDSTAT, 1.0 * partno / partcount), false);
                                TrayIconPercent(trayicon, 1.0 * partno / partcount);
                            }
                        }
                        if (success)
                        {
                            success = errorReportService.TransferFinish(filename, partcount);
                        }
                    }
                }

                if (!success)
                {
                    TrayIconSetText(trayicon, Properties.Resources.ERROR_TRANSMIT_SERVERERROR, showMessages);
                }
            }
            catch
            {
                success = false;
                TrayIconSetText(trayicon, Properties.Resources.ERROR_TRANSMIT_ERROR, showMessages);
            }
            finally
            {
                if (errorReportService != null)
                    errorReportService.Abort();
            }

            SendingSuccess = success;

            if (!SendingSuccess && !SendingCanceled && showMessages) //in case an error message needs to be shown, delay the thread termination
            {
                //set the events to enable close form on click
                this.Invoke((MethodInvoker)delegate()
                {
                    if (!success && showMessages)
                        SetTrayIconClickCloseForm(trayicon);

                });

                //wait before closing the form anyway
                System.Threading.Thread.Sleep(10000);
            }

            this.Invoke((MethodInvoker)delegate()
            {
                if (this.IsHandleCreated && !this.IsDisposed)
                    this.Close();
            });
        }
Пример #2
0
        /// <summary>
        /// Handles the Load event of the ErrorHandlerForm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev07, 2009-07-15</remarks>
        private void ErrorHandlerForm_Load(object sender, EventArgs e)
        {
            this.Height = NotExpandedSize;

            // Load the appropriate text in the header
            if (Fatal)
                labelErrorOccuredInformationMessage.Text = Resources.ERROR_OCCURED_INFORMATION_MESSAGE_FATAL;
            else
                labelErrorOccuredInformationMessage.Text = Resources.ERROR_OCCURED_INFORMATION_MESSAGE_NOT_FATAL;

            //restart MemoryLifter
            checkBoxRestartMemoryLifter.Checked = Fatal;

            // Load the zip file and display the content in the list view
            using (Stream stream = report.Open(FileMode.Open))
            {
                if (stream != null)
                {
                    foreach (ZipEntry i in GetZipContent(stream))
                    {
                        ListViewItem listViewItem = new ListViewItem();
                        listViewItem.Tag = i.Name;
                        listViewItem.ToolTipText = i.Name;
                        listViewItem.Text = string.Format("{0} ({1:0.0} KB)", i.Name, i.Size / 1024D);
                        listViewItem.Checked = i.Name.StartsWith("ErrorReport.") ? true : false;
                        listViewFiles.Items.Add(listViewItem);
                    }
                }
            }

            errorReportHandler = new ErrorReportHandler(report);
            try
            {
                labelErrorMessage.Text = errorReportHandler.GetValue(Resources.ERRORREPORTPATH_MESSAGE);
            }
            catch (Exception exp)
            {
                Trace.WriteLine("Reading error data from ErrorReport Exception: " + exp.ToString());
            }
        }
Пример #3
0
        /// <summary>
        /// Sends this instance.
        /// </summary>
        /// <remarks>Documented by Dev02, 2009-07-15</remarks>
        private void Send()
        {
            TrayIconSetText(trayicon, Properties.Resources.ERROR_TRANSMIT_SENDING, showMessages);

            //begin with chunking and transfer
            ErrorReportService.ErrorReportService errorReportService = null;
            bool success = false;

            try
            {
                if (!SendingCanceled)
                {
                    //read out report data
                    byte[] buffer   = File.ReadAllBytes(reportfile);
                    string filename = Path.GetFileName(reportfile);

                    ErrorReportHandler handler = new ErrorReportHandler(new FileInfo(reportfile));
                    string             email = String.Empty, description = String.Empty, stacktrace = String.Empty;
                    try
                    {
                        email       = handler.GetValue(Resources.ERRORREPORTPATH_USEREMAIL);
                        description = handler.GetValue(Resources.ERRORREPORTPATH_USERDESCRIPTION);
                    }
                    catch (Exception exp)
                    {
                        Trace.WriteLine("Reading user data from ErrorReport Exception: " + exp.ToString());
                    }
                    try
                    {
                        stacktrace = handler.GetValue(Resources.ERRORREPORTPATH_MESSAGE) + Environment.NewLine +
                                     handler.GetValue(Resources.ERRORREPORTPATH_STACKTRACE);
                    }
                    catch (Exception exp)
                    {
                        Trace.WriteLine("Reading error data from ErrorReport Exception: " + exp.ToString());
                    }

                    //try to connect to webservice
                    errorReportService                 = new ErrorReportService.ErrorReportService();
                    errorReportService.Url             = Properties.Settings.Default.MLifterErrorHandler_ErrorReportService_ErrorReportService;
                    errorReportService.CookieContainer = new System.Net.CookieContainer();

                    int chunksize = Settings.Default.Transfer_Chunksize;
                    int partcount = Convert.ToInt32(Math.Ceiling(buffer.Length * 1.0 / chunksize));
                    if (success = errorReportService.TransferStart(filename, buffer.Length, chunksize, email, description, stacktrace))
                    {
                        byte[] chunk = new byte[chunksize];
                        for (int partno = 0; partno < partcount; partno++)
                        {
                            if (SendingCanceled)
                            {
                                success = false;
                                break;
                            }

                            int length = partno == partcount - 1 ? buffer.Length % chunksize : chunksize;
                            Buffer.BlockCopy(buffer, partno * chunksize, chunk, 0, length);

                            if (!(success = errorReportService.TransferChunk(filename, chunk, partcount)))
                            {
                                break;
                            }
                            else
                            {
                                TrayIconSetText(trayicon, string.Format(Properties.Resources.ERROR_TRANSMIT_SENDSTAT, 1.0 * partno / partcount), false);
                                TrayIconPercent(trayicon, 1.0 * partno / partcount);
                            }
                        }
                        if (success)
                        {
                            success = errorReportService.TransferFinish(filename, partcount);
                        }
                    }
                }

                if (!success)
                {
                    TrayIconSetText(trayicon, Properties.Resources.ERROR_TRANSMIT_SERVERERROR, showMessages);
                }
            }
            catch
            {
                success = false;
                TrayIconSetText(trayicon, Properties.Resources.ERROR_TRANSMIT_ERROR, showMessages);
            }
            finally
            {
                if (errorReportService != null)
                {
                    errorReportService.Abort();
                }
            }

            SendingSuccess = success;

            if (!SendingSuccess && !SendingCanceled && showMessages)             //in case an error message needs to be shown, delay the thread termination
            {
                //set the events to enable close form on click
                this.Invoke((MethodInvoker) delegate()
                {
                    if (!success && showMessages)
                    {
                        SetTrayIconClickCloseForm(trayicon);
                    }
                });

                //wait before closing the form anyway
                System.Threading.Thread.Sleep(10000);
            }

            this.Invoke((MethodInvoker) delegate()
            {
                if (this.IsHandleCreated && !this.IsDisposed)
                {
                    this.Close();
                }
            });
        }