Ejemplo n.º 1
0
        public void Run()
        {
            ShowDetailInfoException(_isDetailShow);


            string exceptionInfoText = string.Format(
                "An unexpected error occurred: {0}" + Environment.NewLine +
                "Time: {1} " + Environment.NewLine +
                "{2}" + Environment.NewLine +
                "InnerException: \n {3}" + Environment.NewLine +
                "InnerException StackTrace: \n  {4}" + Environment.NewLine,
                _exception.Message,
                DateTime.Now,
                _exception,
                _exception.InnerException,
                _exception.InnerException != null
                    ? _exception.InnerException.StackTrace
                    : string.Empty
                );

            Program.Logger.Error(exceptionInfoText);
            _view.ExceptionInfoText = exceptionInfoText;

            _view.ShowDialog();
        }
        public void Show(Exception ex)
        {
            IErrorHandlerForm form = new ErrorHandlerForm();

            string exceptionType = ex.GetType().ToString();
            string message       = ex.Message;
            string clr           = Environment.Version.ToString();
            string application   = Application.ProductName + " [" + Application.ProductVersion + "]";
            string targetSite    = ex.TargetSite.ToString();
            string timestamp     = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();

            form.ExceptionType = exceptionType;
            form.Message       = ex.Message;
            form.CLR           = clr;
            form.Application   = application;
            form.TargetSite    = targetSite;
            form.ExceptionObj  = ex;
            form.DateTime      = timestamp;
            form.ShowDialog();

            string report = string.Empty;

            report += "ExceptionType: " + exceptionType + "\r\n";
            report += "Message:" + message + "\r\n";
            report += "CLR:" + clr + "\r\n";
            report += "Appliction:" + application + "\r\n";
            report += "TargetSite:" + targetSite + "\r\n";
            report += "Timestamp:" + timestamp + "\r\n";
            report += "UserComment:" + form.UserComment + "\r\n";
            report += "/*************************************************/\r\n";
            report += "Stack Trace:" + ex.StackTrace;

            if (form.SendReport == true)
            {
                SendReport(application, report);
            }

            form.SendReport = false;
        }