示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// <returns>Crash report as string</returns>
        public void Write(Exception e)
        {
            ExceptionReportInfo info = new ExceptionReportInfo {
                MainException = e
            };
            ExceptionReportGenerator reportGenerator = new ExceptionReportGenerator(info);
            ExceptionReport          report          = reportGenerator.CreateExceptionReport();

            string crashDir = Path.Combine(Preferences.instance().getProperty("application.support.path"),
                                           "CrashReporter");

            Directory.CreateDirectory(crashDir);
            using (StreamWriter outfile = new StreamWriter(Path.Combine(crashDir, DateTime.Now.Ticks + ".txt")))
            {
                outfile.Write(report.ToString());
            }
            TaskDialog   prompt = new TaskDialog();
            DialogResult result = prompt.ShowCommandBox(Locale.localizedString("Do you want to report the last crash?", "Crash"),
                                                        Locale.localizedString("Do you want to report the last crash?", "Crash"),
                                                        Locale.localizedString(
                                                            "The application %@ has recently crashed. To help improve it, you can send the crash log to the author.", "Crash").Replace("%@", Preferences.instance().getProperty("application.name")),
                                                        String.Format("{0}|{1}",
                                                                      Locale.localizedString("Send", "Crash"),
                                                                      Locale.localizedString("Don't Send", "Crash")),
                                                        false, SysIcons.Error);

            if (DialogResult.OK == result)
            {
                if (0 == prompt.CommandButtonResult)
                {
                    Post(report.ToString());
                }
            }
        }
        /// <summary>
        /// copy the report to the clipboard, using the clipboard implementation supplied
        /// </summary>
        public void CopyReportToClipboard()
        {
            ExceptionReport exceptionReport = CreateExceptionReport();

            _clipboard.CopyTo(exceptionReport.ToString());
            _view.ProgressMessage = string.Format("{0} copied to clipboard", ReportInfo.TitleText);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// <returns>Crash report as string</returns>
        public void Write(Exception e)
        {
            ExceptionReportInfo info = new ExceptionReportInfo {
                MainException = e
            };
            ExceptionReportGenerator reportGenerator = new ExceptionReportGenerator(info);
            ExceptionReport          report          = reportGenerator.CreateExceptionReport();

            string crashDir = Path.Combine(PreferencesFactory.get().getProperty("application.support.path"),
                                           "CrashReporter");

            Directory.CreateDirectory(crashDir);
            using (StreamWriter outfile = new StreamWriter(Path.Combine(crashDir, DateTime.Now.Ticks + ".txt")))
            {
                outfile.Write(report.ToString());
            }
            TaskDialogResult result =
                TaskDialog.TaskDialog.Show(
                    title: LocaleFactory.localizedString("Do you want to report the last crash?", "Crash"),
                    mainInstruction: LocaleFactory.localizedString("Do you want to report the last crash?", "Crash"),
                    content:
                    LocaleFactory.localizedString(
                        "The application %@ has recently crashed. To help improve it, you can send the crash log to the author.",
                        "Crash").Replace("%@", PreferencesFactory.get().getProperty("application.name")),
                    commandLinks:
                    new string[]
            {
                LocaleFactory.localizedString("Send", "Crash"),
                LocaleFactory.localizedString("Don't Send", "Crash")
            }, mainIcon: TaskDialogIcon.Error);

            if (result.CommandButtonResult == 0)
            {
                Post(report.ToString());
            }
        }