public static void Show(Window owner, IEnumerable <string> imessages, IEnumerable <Exception> iexceptions) { string split = Environment.NewLine + "--------------------" + Environment.NewLine; var messages = imessages.ToList(); var exceptions = iexceptions.ToList(); bool isconnerror = exceptions.All(e => (e as RestException)?.IsConnectionProblem == true); var dlg = new SyncErrorDialog(); dlg.CbSupress.Visibility = isconnerror ? Visibility.Visible : Visibility.Collapsed; dlg.ErrorMessage.Text = string.Join(Environment.NewLine, messages); dlg.ErrorTrace.Text = string.Join(split, exceptions.Select(FormatExecption)); if (owner != null && owner.IsLoaded) { dlg.Owner = owner; } else { dlg.WindowStartupLocation = WindowStartupLocation.CenterScreen; } dlg.ShowDialog(); if (isconnerror && dlg.CbSupress.IsChecked == true) { MainWindow.Instance.Settings.SuppressConnectionProblemPopup = true; MainWindow.Instance.Settings.Save(); } }
public static void Show(Window owner, Exception e) { var dlg = new SyncErrorDialog(); dlg.ErrorMessage.Text = e.Message; dlg.ErrorTrace.Text = FormatExecption(e); dlg.Owner = owner; dlg.ShowDialog(); }
public static void Show(Window owner, string message, string trace) { var dlg = new SyncErrorDialog(); dlg.ErrorMessage.Text = message; dlg.ErrorTrace.Text = trace; SetOwnerSafe(owner, dlg); dlg.ShowDialog(); }
public static void Show(Window owner, string message, string trace) { var dlg = new SyncErrorDialog(); dlg.ErrorMessage.Text = message; dlg.ErrorTrace.Text = trace; if (owner != null && owner.IsLoaded) { dlg.Owner = owner; } else { dlg.WindowStartupLocation = WindowStartupLocation.CenterScreen; } dlg.ShowDialog(); }
public void SyncError(List <Tuple <string, Exception> > errors) { if (errors.Count == 0) { return; } if (_lastSynchronized != null) { LastSynchronizedText = _lastSynchronized.Value.ToLocalTime().ToString("HH:mm:ss"); } else { LastSynchronizedText = "[ERROR]"; } SynchronizationState = SynchronizationState.Error; App.Logger.Error("Sync", string.Join(Environment.NewLine, errors.Select(p => p.Item1)), string.Join("\r\n\r\n\r\n", errors.Select(p => p.Item2.ToString()))); if (Settings.SuppressAllSyncProblemsPopup) { App.Logger.Info("Sync", "Suppress error display due to config [[SuppressAllSyncProblemsPopup]]"); } else if (Settings.SuppressConnectionProblemPopup && errors.All(e => (e.Item2 as RestException)?.IsConnectionProblem == true)) { App.Logger.Info("Sync", "Suppress error display due to config [[SuppressConnectionProblemPopup]]"); } else { if (Owner.Visibility == Visibility.Hidden) { Owner.TrayIcon.ShowBalloonTip( "Synchronization failed", string.Join(Environment.NewLine, errors.Select(p => p.Item1)), BalloonIcon.Error); } else { SyncErrorDialog.Show(Owner, errors.Select(p => p.Item1).ToList(), errors.Select(p => p.Item2).ToList()); } } }
public void StartSync() { if (SelectedProvider == null) { return; } if (Account == null) { return; } if (_syncThread != null && _syncThread.IsAlive) { _syncThread.Abort(); } if (_progressThread != null && _progressThread.IsAlive) { _progressThread.Abort(); } SyncInfoText = "Starting Synchronization"; var acc = new RemoteStorageAccount(Account.ID, Account.Plugin, Account.Config); _syncThread = new Thread(() => { try { Application.Current.Dispatcher.Invoke(() => { IsValidating = true; ConfigurationValidated = false; ValidationResultData = null; ValidationResultNotes = null; SyncProgress = 0; SyncInfoText = string.Empty; CanAbort = true; }); var r = DoSync(acc, App.Logger); Application.Current.Dispatcher.Invoke(() => { ConfigurationValidated = true; ValidationResultData = r.Item1; ValidationResultNotes = r.Item2; SyncProgress = r.Item3 == 0 ? -100 : -66; SyncInfoText = r.Item3 == 0 ? string.Empty : $"({r.Item3}/{r.Item4} notes had download errors)"; }); } catch (ThreadAbortException) { Application.Current.Dispatcher.Invoke(() => { ConfigurationValidated = false; ValidationResultData = null; ValidationResultNotes = null; SyncProgress = 0; SyncInfoText = string.Empty; }); return; } catch (Exception e) { Application.Current.Dispatcher.Invoke(() => { ConfigurationValidated = false; ValidationResultData = null; ValidationResultNotes = null; SyncProgress = -66; SyncInfoText = string.Empty; }); Application.Current.Dispatcher.BeginInvoke(new Action(() => { SyncProgress = -66; SyncErrorDialog.Show(_owner, e); })); } finally { Application.Current.Dispatcher.BeginInvoke(new Action(() => { IsValidating = false; SyncInfoText = string.Empty; })); } }); _progressThread = new Thread(() => { Thread.Sleep(350); for (;;) { if (!_syncThread.IsAlive) { break; } Thread.Sleep(150); Application.Current.Dispatcher.Invoke(() => { SyncProgress++; }); } Application.Current.Dispatcher.Invoke(() => { if (ConfigurationValidated) { SyncProgress = -100; } else { SyncProgress = -66; } SyncInfoText = string.Empty; }); }); _syncThread.Start(); _progressThread.Start(); }