Beispiel #1
0
        /// <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);
            }
        }
Beispiel #2
0
 /// <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);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Send the error to technical support
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSendError_Click(object sender, EventArgs e)
        {
            myErrorInformation.Steps = txtSteps.Text;

            if (GuiUtility.CheckInternetConnection(false) == false)
            {
                if (SendMapiMessage() == false)
                {
                    TryLink(myErrorInformation.GetManualEmailMessage());
                }

                return;
            }

            if (SendError())
            {
                GuiException.MessageBoxErrorHandler = false;
                Close();
            }
        }
        /// <summary>
        /// Display an Error using the Error Form
        /// </summary>
        /// <param name="ex">Exception that occured</param>
        /// <param name="additionalInfo">Additional Information About The Error</param>
        /// <returns>True if successfully logged and displayed</returns>
        public static bool HandleException(Exception ex, string additionalInfo)
        {
            string           message      = string.Empty;
            ErrorInformation errorInfo    = new ErrorInformation();
            string           currentError = string.Empty;
            bool             success      = true;

            try
            {
                //Exit when we are past the maximum number of errors
                if (ErrorCount >= MaxErrorCount)
                {
                    message = ProgramName + " has experienced a number of errors.\nPlease restart " + ProgramName + ".";
                    GuiUtility.MessageBoxCritical(message, "Restart " + ProgramName);
                    Application.Exit();
                }

                //Ignore duplicate errors
                currentError = ex.Message + ex.StackTrace;

                if (currentError == _previousError)
                {
                    success = false;
                    return(success); //We don't care if the same error happens over and over again
                }

                ErrorCount++;
                _previousError = currentError;


                CallingInfo callingInfo = ReflectionUtil.GetCallingInfo();

                //Fill the error information object
                errorInfo.ProgramName   = ProgramName;
                errorInfo.SupportEmail  = SupportEmail;
                errorInfo.SmtpServer    = SmtpServer;
                errorInfo.Login         = Login;
                errorInfo.Password      = Password;
                errorInfo.GUIException  = ex;
                errorInfo.AssemblyName  = callingInfo.AssemblyName;
                errorInfo.Version       = callingInfo.AssemblyVersion;
                errorInfo.ClassName     = callingInfo.ClassName;
                errorInfo.ProcedureName = callingInfo.MethodName;


                errorInfo.AdditionalInfo = additionalInfo;

                //Log the event log
                success &= SimpleLog.LogToEventLog(errorInfo.GetEventLogMessage(), EventLogEntryType.Error, ProgramName);

                //Get a screen shot
                errorInfo.ScreenShot = GuiUtility.ScreenShot();

                //Save the event log to a text file and return the path
                errorInfo.EventLogText = ReadFromEventLog();

                //Show the giant error handling dialog
                if (MessageBoxErrorHandler == false)
                {
                    ErrorDialog frmErrorDialog = new ErrorDialog(errorInfo);
                    frmErrorDialog.ShowDialog();
                }
                else //Generic message box
                {
                    GuiUtility.MessageBoxExclamation(errorInfo.GetMessageBoxMessage(), "Error");
                }

                return(success);
            }
            catch (Exception exHandler) //Really bad, there is an error in the error handler
            {
                success = false;

                //Super simple error message so nothing else goes wrong
                message  = "Error in Error Handler\n";
                message += exHandler.Message + "\n";
                message += exHandler.TargetSite + "\n";
                message += exHandler.StackTrace;

                GuiUtility.MessageBoxCritical(message, "Error in Error Handler");
                return(success);
            }
        }
 private void txtLicenseKey_Validating(object sender, CancelEventArgs e)
 {
     GuiUtility.epRequired(epValidation, txtLicenseKey, lblLicenseKey.Text);
 }
 private void txtUserName_Validating(object sender, CancelEventArgs e)
 {
     GuiUtility.epRequired(epValidation, txtUserName, lblUserName.Text);
 }