Esempio n. 1
0
        public static async Task HandleFailedSynced(SyncFailedEventArgs e, IMessageBoxService messageBoxService, INavigationService navigationService)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }
            if (navigationService == null)
            {
                throw new ArgumentNullException(nameof(navigationService));
            }

            string message = e.Message ?? string.Empty;
            string details = null;

            if (e.Exception != null)
            {
                details = ExceptionExtension.BeautifyAsyncStacktrace(e.Exception.ToString());
            }

            if (!string.IsNullOrEmpty(message))
            {
                if (!string.IsNullOrEmpty(details))
                {
                    var result = await messageBoxService.ShowAsync(
                        StringResources.Sync_FailedMessage,
                        message,
                        new[] { StringResources.General_LabelOk, StringResources.General_LabelDetails });

                    if (result.ButtonIndex == 1)
                    {
                        details = string.Format("{0}\r\n{1}", message, details);
                        await messageBoxService.ShowAsync(StringResources.Message_Information, details);
                    }
                }
                else
                {
                    await messageBoxService.ShowAsync(StringResources.Message_Warning, message);
                }

                if (message.Equals(StringResources.Exchange_InvalidSyncKeyWorkaround))
                {
                    navigationService.FlyoutTo(ViewLocator.SyncAdvancedSyncSettingsPage);
                }
            }
        }
Esempio n. 2
0
        private async void SuggestExceptionEmail(Exception e, string page)
        {
            var service         = Ioc.Resolve <IMessageBoxService>();
            var platformService = Ioc.Resolve <IPlatformService>();

            TrackingManagerHelper.Exception(e, "Crash handler");

            var result = await service.ShowAsync(StringResources.General_LabelError, StringResources.Crash_MessageContent, DialogButton.YesNo);

            if (result == DialogResult.Yes)
            {
                var builder = new StringBuilder();

                builder.AppendLine("IMPORTANT: Please give details about the context of this error");
                builder.AppendLine();
                builder.AppendLine();

                builder.Append(GetDiagnosticsInformation(page));

                builder.AppendLine();
                builder.AppendLine();

                builder.AppendLine($"Exception: {e.Message}");
                builder.AppendLine($"Stacktrace: {ExceptionExtension.BeautifyAsyncStacktrace(e.StackTrace)}");

                if (e is AggregateException)
                {
                    var aggregateException = (AggregateException)e;
                    foreach (var innerException in aggregateException.InnerExceptions)
                    {
                        builder.AppendLine($"   Exception: {innerException.Message}");
                        builder.AppendLine($"   Stacktrace: {ExceptionExtension.BeautifyAsyncStacktrace(innerException.StackTrace)}");
                    }
                }

                await platformService.SendDiagnosticEmailAsync("2Day for Windows Error Report", builder.ToString());
            }
        }