예제 #1
0
        private void SubmitBugReport()
        {
            var crashReport = AssemblyHelper.BuildCrashReport();

            var additionalInfo = new Dictionary <string, string>
            {
                { "BugReport", this.BugReportField.Value },
                { "ContactInfo", this.ContactInfoField.Value },
            };

            crashReport.Source         = "BugReport";
            crashReport.AdditionalInfo = additionalInfo;
            crashReport.Logs           = this.Logger.LogBuffer.Reverse().Take(100).ToList();

            var task        = RuneberryApiClient.SendCrashReportAsync(crashReport);
            var asyncPopout = new AsyncPopout(task, o =>
            {
                o.Title          = "Bug Report";
                o.Text           = "Submitting bug report...";
                o.SuccessMessage = "Bug report submitted. Thank you!";
                o.FailureMessage = "Failed to submit bug report.\r\nContact Runeberry Software for further support.";
            });

            asyncPopout.ShowDialog();

            this.Close();
        }
        public void HandleException(Exception e, string contextMessage = null)
        {
            if (e == null)
            {
                return;
            }

            e = e.GetPrimaryException();

            contextMessage ??= "Unknown Exception";
            var userMessage = "A fatal error has occured. Would you like to send an automated crash report to the developer?";

            var result = MessageBox.Show(
                userMessage,
                contextMessage,
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Error);

            if (result == DialogResult.Yes)
            {
                var crashReport = BuildCrashReport(e, contextMessage);
                var task        = RuneberryApiClient.SendCrashReportAsync(crashReport);

                var asyncPopout = new AsyncPopout(task, o =>
                {
                    o.Title          = "Crash Report";
                    o.Text           = "Sending crash report...";
                    o.SuccessMessage = "Crash report received. Thank you!";
                    o.FailureMessage = "Failed to send crash report.\r\nContact Runeberry Software for further support.";
                });

                asyncPopout.ShowDialog();
            }

            this.ExceptionHandled?.Invoke(this, EventArgs.Empty);
        }