public static async Task ShowErrorDialog(this Exception exception, Logger logger = null)
        {
            if (logger != null)
            {
                logger.Error(exception);
            }
            else
            {
                typeof(ExceptionExtension).LogByType(exception);
            }

            bool needSendEmail = false;
            await MessageBox.ShowAsync(DialogTitle,
                                       $"{ErrorCode} 0x{exception.HResult:x8}\r\n{ErrorMessage} {exception.Message}",
                                       new Dictionary <string, UICommandInvokedHandler> {
                { SendErrorReport, u => needSendEmail = true }
            },
                                       DialogClose);

            if (needSendEmail)
            {
                string title = $"{AppInfo.Name} {AppInfo.Version} {EmailTitle}";
                string body  = $"{SystemVersion} {SystemInfo.BuildVersion}\r\n{ErrorCode} 0x{exception.HResult:x8}\r\n{ErrorMessage} {exception.Message}\r\n{StackInfo}\r\n{exception.ToString()}\r\n{LoggingInfo}\r\n{await LoggerService.ReadLogs(20)}";

                await EmailEx.SendAsync(Email, title, body);
            }
        }
Exemplo n.º 2
0
        private static async Task ShowErrorDialog(Exception ex)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine(CharacterLibrary.ErrorTable.GetString("OperationProcess"));
            builder.AppendLine();
            builder.AppendLine();
            builder.AppendLine();
            builder.AppendLine($"{CharacterLibrary.ErrorTable.GetString("SystemVersion")} {SystemInfo.BuildVersion}");
            builder.AppendLine(ex.ToLongString());

            string errorReportEmillTitle =
                $"{AppInfo.Name} {AppInfo.Version} {CharacterLibrary.MessageBox.GetString("ErrorReportEmillTitle")}";

            var buttons = new Dictionary <string, UICommandInvokedHandler>
            {
                {
                    CharacterLibrary.MessageBox.GetString("SendErrorReport"),
                    async c => await EmailEx.SendAsync(Emill, errorReportEmillTitle, builder.ToString())
                },
                { CharacterLibrary.MessageBox.GetString("Close"), null }
            };

            await MessageBox.ShowAsync(CharacterLibrary.MessageBox.GetString("ErrorReportDialogTitle"),
                                       ex.ToShortString(), buttons);
        }
Exemplo n.º 3
0
        public static async Task ShowErrorDialog(this Exception exception)
        {
            bool needSendEmail = false;
            await MessageBox.ShowAsync(DialogTitle,
                                       $"{ErrorCode} 0x{exception.HResult:x8}\r\n{ErrorMessage} {exception.Message}",
                                       new Dictionary <string, UICommandInvokedHandler> {
                { SendErrorReport, u => needSendEmail = true }
            },
                                       DialogClose);

            if (needSendEmail)
            {
                string title = $"{AppInfo.Name} {AppInfo.Version} {EmailTitle}";
                string body  = $"{SystemVersion} {SystemInfo.BuildVersion}\r\n{ErrorCode} {exception.HResult:x8}\r\n{ErrorMessage} {exception.Message}\r\n{StackInfo}\r\n{exception.StackTrace}";

                await EmailEx.SendAsync(Email, title, body);
            }
        }