public ErrorHandlerVm(ILogger logger, ISettingsService settingsService, IUnityContainer container, IEmailService emailSevice) { _logger = logger; _emailSevice = emailSevice; _config = settingsService.GetConfig(); _view = container.Resolve <ErrorHandlerForm>(); _view.OnSendButtonClick += View_OnSendButtonClick; _view.OnShowErrorLinkClick += View_OnShowErrorLink; _view.OnLogFileLinkClick += View_OnLogFileLinkClick; _view.OnDebugButtonClick += View_OnDebugButtonClick; }
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; }