Example #1
0
        public static void ProcessEDBAccessLackingCoordinationExc(EDBAccessLackingCoordinationException AException)
        {
            string Reason = String.Empty;

            //Would normally use the code below but cannot due to circular referencing.
            //Form MainMenuForm = TFormsList.GFormsList.MainMenuForm;

            if (Application.OpenForms.Count != 0)              // in the Main Menu Form Test this will be false...
            {
                Form MainMenuForm = Application.OpenForms[0];  // This gets the first ever opened Form, which is the Main Menu

                // Ensure MessageBox is shown on the UI Thread!
                if (MainMenuForm.InvokeRequired)
                {
                    MainMenuForm.Invoke((MethodInvoker) delegate
                    {
                        TServerBusyHelperGui.ShowDBAccessLackingActionNotPossibleDialog(
                            AException, out Reason);
                    });
                }
                else
                {
                    TServerBusyHelperGui.ShowDBAccessLackingActionNotPossibleDialog(
                        AException, out Reason);
                }
            }
            else
            {
                TServerBusyHelperGui.ShowDBAccessLackingActionNotPossibleDialog(
                    AException, out Reason);
            }

            if (TLogging.DebugLevel >= TLogging.DEBUGLEVEL_COORDINATED_DB_ACCESS)
            {
                TLogging.Log(String.Format(Catalog.GetString(
                                               TLogging.LOG_PREFIX_INFO + "The OpenPetra Server was too busy to perform the requested action. (Reason: {0})"),
                                           Reason));
                TLogging.Log(AException.StackTrace);
            }
        }
Example #2
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="ASender"></param>
        /// <param name="AEventArgs"></param>
        public static void UnhandledExceptionHandler(object ASender, UnhandledExceptionEventArgs AEventArgs)
        {
            TUnhandledExceptionForm UEDialogue;
            string FunctionalityNotImplementedMsg = AppCoreResourcestrings.StrFunctionalityNotAvailableYet;
            string Reason = String.Empty;

            if (((Exception)AEventArgs.ExceptionObject is NotImplementedException))
            {
                if (((Exception)AEventArgs.ExceptionObject).Message != String.Empty)
                {
                    FunctionalityNotImplementedMsg = ((Exception)AEventArgs.ExceptionObject).Message;
                }

                TLogging.Log(FunctionalityNotImplementedMsg);
                TLogging.Log(((Exception)AEventArgs.ExceptionObject).StackTrace);

                MessageBox.Show(FunctionalityNotImplementedMsg, AppCoreResourcestrings.StrFunctionalityNotAvailableYetTitle,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (((Exception)AEventArgs.ExceptionObject is EDBAccessLackingCoordinationException))
            {
                //Would normally use the code below but cannot due to circular referencing.
                //Form MainMenuForm = TFormsList.GFormsList.MainMenuForm;
                Form MainMenuForm = Application.OpenForms[0];

                // Ensure MessageBox is shown on the UI Thread!
                if (MainMenuForm.InvokeRequired)
                {
                    MainMenuForm.Invoke((MethodInvoker) delegate {
                        TServerBusyHelperGui.ShowDBAccessLackingActionNotPossibleDialog(
                            (EDBAccessLackingCoordinationException)AEventArgs.ExceptionObject, out Reason);
                    });
                }
                else
                {
                    TServerBusyHelperGui.ShowDBAccessLackingActionNotPossibleDialog(
                        (EDBAccessLackingCoordinationException)AEventArgs.ExceptionObject, out Reason);
                }

                if (TLogging.DebugLevel >= TLogging.DEBUGLEVEL_COORDINATED_DB_ACCESS)
                {
                    TLogging.Log(String.Format(Catalog.GetString(
                                                   TLogging.LOG_PREFIX_INFO + "The OpenPetra Server was too busy to perform the requested action. (Reason: {0})"),
                                               Reason));
                    TLogging.Log(((Exception)AEventArgs.ExceptionObject).StackTrace);
                }
            }
            else if (((Exception)AEventArgs.ExceptionObject is ECachedDataTableLoadingRetryGotCancelledException))
            {
                if (TLogging.DebugLevel >= TLogging.DEBUGLEVEL_COORDINATED_DB_ACCESS)
                {
                    TLogging.Log(Catalog.GetString(
                                     TLogging.LOG_PREFIX_INFO +
                                     "The OpenPetra Server was too busy to retrieve the data for a Cacheable DataTable and the user cancelled the loading after the retry attempts were exhausted."));
                    TLogging.Log(((Exception)AEventArgs.ExceptionObject).StackTrace);
                }

                TServerBusyHelperGui.ShowLoadingOfDataGotCancelledDialog();
            }
            else if (((Exception)AEventArgs.ExceptionObject is ESecurityAccessDeniedException))
            {
                if (ProcessSecurityAccessDeniedException != null)
                {
                    ProcessSecurityAccessDeniedException((ESecurityAccessDeniedException)AEventArgs.ExceptionObject, ASender.GetType());
                }
                else
                {
                    MessageBox.Show(
                        "Unhandled Thread Exception Handler: encountered ESecurityAccessDeniedException, but Delegate " +
                        "'ProcessSecurityAccessDeniedException' isn't set up - which is a mistake that needs to be corrected." +
                        Environment.NewLine +
                        "Message of the ProcessSecurityAccessDeniedException instance:" + Environment.NewLine +
                        ProcessSecurityAccessDeniedException.ToString());
                }
            }
            else
            {
                //      MessageBox.Show("UnhandledExceptionHandler  Unhandled Exception: \r\n\r\n" +
                //                      ((Exception)(AEventArgs.ExceptionObject)).ToString() + "\r\n\r\n"+
                //      "IsTerminating: " + AEventArgs.IsTerminating.ToString());

                LogException((Exception)AEventArgs.ExceptionObject,
                             "Reported by UnhandledExceptionHandler: (Application is terminating: " + AEventArgs.IsTerminating.ToString() + ')');
                UEDialogue = new TUnhandledExceptionForm();

                UEDialogue.NonRecoverable = AEventArgs.IsTerminating;
                UEDialogue.TheException   = (Exception)AEventArgs.ExceptionObject;

                //Would normally use the code below but cannot due to circular referencing.
                //Form MainMenuForm = TFormsList.GFormsList.MainMenuForm;
                Form MainMenuForm = Application.OpenForms[0];  // This gets the first ever opened Form, which is the Main Menu

                // Ensure UEDialogue is shown on the UI Thread!
                if (MainMenuForm.InvokeRequired)
                {
                    MainMenuForm.Invoke((MethodInvoker) delegate { UEDialogue.ShowDialog(); });
                }
                else
                {
                    UEDialogue.ShowDialog();
                }
            }
        }