public static bool HandleException( Exception exception, Form form, KeyEventHandler keyEventHandler, string eventDetailsMessage, bool emailException, out string emailErrorMessage, out string emailLogMessageText, List <EmailNotificationRecipient> emailNotificationRecipients) { try { emailErrorMessage = string.Empty; emailLogMessageText = string.Empty; bool closeApplication = false; if (exception == null) { throw new NullReferenceException("exception to be handled may not be null."); } if (GOCWindows.Instance.ShowMessageBoxOnException) { UIHelperWindows.DisplayException(exception, form, keyEventHandler, eventDetailsMessage); } if (GOCWindows.Instance.ShowWindowsFormsNotificationOnException && GOCWindows.Instance.NotifyIcon != null) { string applicationName = string.IsNullOrEmpty(GOCWindows.Instance.ApplicationName) ? "Notification" : GOCWindows.Instance.ApplicationName; GOCWindows.Instance.NotifyIcon.ShowBalloonTip(10, applicationName, exception.Message, ToolTipIcon.Error); } UserThrownException userThrownException = exception as UserThrownException; if (userThrownException != null) { closeApplication = userThrownException.CloseApplication; GOCWindows.Instance.Logger.LogMessage(new LogError(exception, eventDetailsMessage, userThrownException.LoggingLevel)); } else { GOCWindows.Instance.Logger.LogMessage(new LogError(exception, eventDetailsMessage, LoggingLevel.Normal)); } if (emailException && GOCWindows.Instance.SendEmailOnException) { if (GOCWindows.Instance.EmailClient == null) { throw new Exception(string.Format("{0} enabled, but {1} not set.", EntityReaderGeneric <GOCWindows> .GetPropertyName(p => p.SendEmailOnException, false), EntityReaderGeneric <GOCWindows> .GetPropertyName(p => p.EmailClient, false))); } GOCWindows.Instance.EmailClient.SendExceptionEmailNotification(exception, out emailErrorMessage, out emailLogMessageText, GOCWindows.Instance.AppendHostNameToExceptionEmails, emailNotificationRecipients); } return(closeApplication); } catch (Exception ex) { Exception wrappedException = new Exception(ex.Message, exception); Console.WriteLine(LogError.GetErrorMessageFromException(new Exception(ex.Message, exception), eventDetailsMessage)); GOCWindows.Instance.Logger.LogMessageToFile(new LogError(wrappedException, eventDetailsMessage, LoggingLevel.Minimum)); emailErrorMessage = string.Empty; emailLogMessageText = string.Empty; return(true); } }
public WaitProcessWindows(MenuStrip mainMenuToDisable, BorderlessFormWindows borderlessForm) { _mainMenu = mainMenuToDisable; UIHelperWindows.MenuEnabled(_mainMenu, false); _borderlessForm = borderlessForm; if (_borderlessForm != null) { _originalStatus = _borderlessForm.Status; } Cursor.Current = Cursors.WaitCursor; }
public WaitProcessWindows(MenuStrip mainMenuToDisable, Label statusLabel) { _mainMenu = mainMenuToDisable; UIHelperWindows.MenuEnabled(_mainMenu, false); _statusLabel = statusLabel; if (_statusLabel != null) { _originalStatus = _statusLabel.Text; } Cursor.Current = Cursors.WaitCursor; }
/// <summary> /// The current cursor will set back to a default cursor. /// </summary> public void Dispose() { if (_mainMenu != null) { UIHelperWindows.MenuEnabled(_mainMenu, true); } if (_statusBar != null && _statusBar.Text != _originalStatus) { _statusBar.Text = _originalStatus; } if (_statusLabel != null && _statusLabel.Text != _originalStatus) { _statusLabel.Text = _originalStatus; } if (_borderlessForm != null && _borderlessForm.Status != _originalStatus) { _borderlessForm.Status = _originalStatus; } Cursor.Current = Cursors.Default; }
public WaitProcessWindows(MenuStrip mainMenuToDisable) { _mainMenu = mainMenuToDisable; UIHelperWindows.MenuEnabled(_mainMenu, false); Cursor.Current = Cursors.WaitCursor; }