/// <summary> /// Show or hide the error details section /// </summary> /// <param name="bShow"></param> private void ShowDetails(bool bShow) { try { if (bShow) { Height = 648; grpErrorDetails.Visible = true; CenterToScreen(); btnShowDetails.Text = "Hide Details <<"; } else { grpErrorDetails.Visible = false; Height = 295; CenterToScreen(); btnShowDetails.Text = "Show Details >>"; } showDetails = !bShow; } catch (Exception ex) { GuiException.HandleException(ex); } }
/// <summary> /// Constructor /// </summary> public ErrorDialog(ErrorInformation errorInfo) { // // Required for Windows Form Designer support // InitializeComponent(); try { GuiException.MessageBoxErrorHandler = true; myErrorInformation = errorInfo; //No wait cursor GuiUtility.Hourglass(false); //Get the constructor variables txtApplicationName.Text = myErrorInformation.ProgramName; txtCulture.Text = myErrorInformation.Culture; txtClassName.Text = myErrorInformation.ClassName; txtProcedureName.Text = myErrorInformation.ProcedureName; txtErrorMessage.Text = myErrorInformation.GUIException.Message; txtStack.Text = myErrorInformation.GUIException.StackTrace; txtAdditionalInfo.Text = myErrorInformation.AdditionalInfo; } catch (Exception ex) { GuiException.HandleException(ex); } }
/// <summary> /// Copy the error to notepad /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnNotepad_Click(object sender, EventArgs e) { try { GuiUtility.NotepadMessage(myErrorInformation.GetNotepadMessage()); } catch (Exception ex) { GuiException.HandleException(ex); } }
/// <summary> /// Email the error to technical support /// </summary> /// <returns></returns> private bool SendError() { string body; string subject = "Error in " + myErrorInformation.ProgramName; string attachments = string.Empty; EmailEngine email = new EmailEngine(); try { ValidateChildren(); if (epValidation.GetError(txtSteps).Length == 0) { //Send using mailto link if there is no smtp server specified if (myErrorInformation.SmtpServer == string.Empty) { TryLink(myErrorInformation.GetManualEmailMessage()); return(true); } //Send using smtp server email.ServerName = myErrorInformation.SmtpServer; myErrorInformation.Steps = txtSteps.Text; body = myErrorInformation.GetXMLMessage(); attachments += myErrorInformation.ScreenShot + ","; attachments += myErrorInformation.EventLogText + ","; email.SendMail(myErrorInformation.Email, myErrorInformation.SupportEmail, subject, body, attachments); return(true); } MessageBox.Show(this, epValidation.GetError(txtSteps), "Errors on Screen", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } catch (Exception ex) { //Smtp server send failed, send with a mailto link GuiException.HandleException(ex); TryLink(myErrorInformation.GetManualEmailMessage()); return(false); } }
/// <summary> /// Close the form and don't send the error to technical support /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDontSend_Click(object sender, EventArgs e) { try { if (File.Exists(myErrorInformation.ScreenShot)) { File.Delete(myErrorInformation.ScreenShot); } if (File.Exists(myErrorInformation.EventLogText)) { File.Delete(myErrorInformation.EventLogText); } GuiException.MessageBoxErrorHandler = false; Close(); } catch (Exception ex) { GuiException.HandleException(ex); Close(); } }
/// <summary> /// Send a message using mapi dll built into windows /// </summary> /// <returns></returns> private bool SendMapiMessage() { try { string subject = "Error in " + myErrorInformation.ProgramName; myErrorInformation.Steps = txtSteps.Text; Mapi myMapi = new Mapi(); myMapi.AddRecip("", myErrorInformation.SupportEmail, false); myMapi.Attach(myErrorInformation.ScreenShot); myMapi.Attach(myErrorInformation.EventLogText); myMapi.Send(subject, myErrorInformation.GetXMLMessage()); return(true); } catch (Exception ex) { //Smtp server send failed, send with a mailto link GuiException.HandleException(ex); return(false); } }
/// <summary> /// Verifies the control has all the required Information /// </summary> /// <returns>True if validation passes</returns> private bool ValidateForm() { try { string errorMessage = string.Empty; ValidateChildren(); errorMessage = epValidation.GetError(txtSteps); //If there was a validation issue, set the focus to the control and cancel the next button if (errorMessage.Length > 0) { txtSteps.Focus(); return(false); } return(true); } catch (Exception ex) { GuiException.HandleException(ex); return(false); } }