private ExceptionReportsManager() { backgroundWork = new AbortableBackgroundWorker(); backgroundWork.DoWork += backgroundWork_DoWork; backgroundWork.RunWorkerCompleted += backgroundWork_RunWorkerCompleted; view = new ExceptionReportForm(); view.Closed += view_Closed; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.domain_UnhandledException); Application.ThreadException += new ThreadExceptionEventHandler(this.application_ThreadException); try { IPAddress[] hostAddresses = Dns.GetHostAddresses(Dns.GetHostName()); if (hostAddresses.Length > 0) { this.hostAddress = new string[hostAddresses.Length]; for (int i = 0; i < hostAddresses.Length; i++) { this.hostAddress[i] = hostAddresses[i].ToString(); } } else { this.hostAddress = new string[] { "无本机IP。" }; } } catch { this.hostAddress = new string[] { "获取本机IP失败。" }; } this.config = null; }
/// <summary> /// constructor accepting a view and the data/config of the report /// </summary> public ExceptionReportPresenter(IExceptionReportView view, ExceptionReportInfo info) { _reportGenerator = new ReportGenerator(info); _fileService = new FileService(); View = view; ReportInfo = info; }
/// <summary> /// Show the ExceptionReport dialog /// </summary> /// <remarks>The <see cref="ExceptionReporter"/> will analyze the <see cref="Exception"/>s and /// create and show the report dialog.</remarks> /// <param name="exceptions">The <see cref="Exception"/>s to show.</param> // ReSharper disable MemberCanBePrivate.Global public void Show(params Exception[] exceptions) { if (exceptions == null) return; //TODO perhaps show a dialog that says "No exception to show" ? try { _reportInfo.SetExceptions(exceptions); _view = ViewFactory.Create<IExceptionReportView>(_viewResolver, _reportInfo); _view.ShowExceptionReport(); } catch (Exception internalException) { _internalExceptionView.ShowException("Unable to show Exception Report", internalException); } }
/// <summary> /// Show the ExceptionReport dialog /// </summary> /// <remarks>The <see cref="ExceptionReporter"/> will analyze the <see cref="Exception"/>s and /// create and show the report dialog.</remarks> /// <param name="exceptions">The <see cref="Exception"/>s to show.</param> // ReSharper disable MemberCanBePrivate.Global public void Show(params Exception[] exceptions) { if (exceptions == null) { return; //TODO perhaps show a dialog that says "No exception to show" ? } try { _reportInfo.SetExceptions(exceptions); _view = ViewFactory.Create <IExceptionReportView>(_viewResolver, _reportInfo); _view.ShowExceptionReport(); } catch (Exception internalException) { _internalExceptionView.ShowException("Unable to show Exception Report", internalException); } }
/// <summary> /// Show the ExceptionReport dialog /// </summary> /// <remarks>The <see cref="ExceptionReporter"/> will analyze the <see cref="Exception"/>s and /// create and show the report dialog.</remarks> /// <param name="exceptions">The <see cref="Exception"/>s to show.</param> public void Show(params Exception[] exceptions) { if (exceptions == null) { return; //TODO perhaps show a dialog that says "No exception to show" ? } try { _reportInfo.SetExceptions(exceptions); _view = new ExceptionReportView(_reportInfo); _view.ShowExceptionReport(); } catch (Exception internalException) { MessageBox.Show(internalException.Message, "Error Reporting Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Show the ExceptionReport dialog /// </summary> /// <remarks>The <see cref="ExceptionReporter"/> will analyze the <see cref="Exception"/>s and /// create and show the report dialog.</remarks> /// <param name="exceptions">The <see cref="Exception"/>s to show.</param> public void Show(params Exception[] exceptions) { if (exceptions == null) { return; // silently ignore this mistake of passing null - user won't care } try { _reportInfo.SetExceptions(exceptions); _view = new ExceptionReportView(_reportInfo); _view.ShowExceptionReport(); } catch (Exception internalException) { MessageBox.Show(internalException.Message, "Failed while trying to report an Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// /// </summary> /// <param name="view"></param> /// <param name="info"></param> public ExceptionReportPresenter(IExceptionReportView view, ExceptionReportInfo info) { _view = view; ReportInfo = info; _reportGenerator = new ExceptionReportGenerator(ReportInfo); }
/// <summary> /// 重载错误报告界面。 /// </summary> /// <param name="view">错误报告视图接口。</param> public void OverrideReportView(IExceptionReportView view) { if (this.view != null) { view.Closed -= view_Closed; } this.view = view; view.Closed += view_Closed; }
/// <summary> /// constructor /// </summary> public ExceptionReportPresenter(IExceptionReportView view, ExceptionReportInfo info) { _view = view; ReportInfo = info; _reportGenerator = new ExceptionReportGenerator(ReportInfo); }