示例#1
0
        private static void StartApplication()
        {
            CatchAllUnhandledExceptions();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            FrmSplashScreen frmSplashScreen = FrmSplashScreen.getInstance();

            frmSplashScreen.Show();
            Application.Run(FrmMain.Default);
        }
示例#2
0
        private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            if (!FrmSplashScreen.getInstance().IsDisposed)
            {
                FrmSplashScreen.getInstance().Close();
            }

            var window = new UnhandledExceptionWindow(e.ExceptionObject as Exception, e.IsTerminating);

            window.ShowDialog(FrmMain.Default);
        }
示例#3
0
        private static void ApplicationOnThreadException(object sender, ThreadExceptionEventArgs e)
        {
            if (!FrmSplashScreen.getInstance().IsDisposed)
            {
                FrmSplashScreen.getInstance().Close();
            }

            var window = new UnhandledExceptionWindow(e.Exception, false);

            window.ShowDialog(FrmMain.Default);
        }
示例#4
0
        public static Optional <SecureString> PasswordDialog(string passwordName = null, bool verify = true)
        {
            var splash = FrmSplashScreen.getInstance();

            if (!splash.IsDisposed && splash.Visible)
            {
                splash.Close();
            }

            var passwordForm = new PasswordForm(passwordName, verify);

            return(passwordForm.GetKey());
        }
        private static void CheckFipsPolicy(MessageCollector messageCollector)
        {
            if (Settings.Default.OverrideFIPSCheck)
            {
                messageCollector.AddMessage(MessageClass.InformationMsg, "OverrideFIPSCheck is set. Will skip check...",
                                            true);
                return;
            }

            messageCollector.AddMessage(MessageClass.InformationMsg, "Checking FIPS Policy...", true);
            if (!FipsPolicyEnabledForServer2003() && !FipsPolicyEnabledForServer2008AndNewer())
            {
                return;
            }

            var errorText = string.Format(Language.strErrorFipsPolicyIncompatible, GeneralAppInfo.ProductName);

            messageCollector.AddMessage(MessageClass.ErrorMsg, errorText, true);

            //About to pop up a message, let's not block it...
            FrmSplashScreen.getInstance().Close();

            var ShouldIStayOrShouldIGo = CTaskDialog.MessageBox(Application.ProductName,
                                                                Language.strCompatibilityProblemDetected, errorText, "",
                                                                "",
                                                                Language.strCheckboxDoNotShowThisMessageAgain,
                                                                ETaskDialogButtons.OkCancel, ESysIcons.Warning,
                                                                ESysIcons.Warning);

            if (CTaskDialog.VerificationChecked && ShouldIStayOrShouldIGo == DialogResult.OK)
            {
                messageCollector.AddMessage(MessageClass.ErrorMsg, "User requests that FIPS check be overridden", true);
                Settings.Default.OverrideFIPSCheck = true;
                Settings.Default.Save();
                return;
            }

            if (ShouldIStayOrShouldIGo == DialogResult.Cancel)
            {
                Environment.Exit(1);
            }
        }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="withDialog">
        /// Should we show the file selection dialog to allow the user to select
        /// a connection file
        /// </param>
        public static void LoadConnections(bool withDialog = false)
        {
            var connectionFileName = "";

            try
            {
                // disable sql update checking while we are loading updates
                ConnectionsService.RemoteConnectionsSyncronizer?.Disable();

                if (withDialog)
                {
                    var loadDialog = DialogFactory.BuildLoadConnectionsDialog();
                    if (loadDialog.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    connectionFileName            = loadDialog.FileName;
                    Settings.Default.UseSQLServer = false;
                    Settings.Default.Save();
                }
                else if (!Settings.Default.UseSQLServer)
                {
                    connectionFileName = ConnectionsService.GetStartupConnectionFileName();
                }

                ConnectionsService.LoadConnections(Settings.Default.UseSQLServer, false, connectionFileName);

                if (Settings.Default.UseSQLServer)
                {
                    ConnectionsService.LastSqlUpdate = DateTime.Now;
                }

                // re-enable sql update checking after updates are loaded
                ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
            }
            catch (Exception ex)
            {
                FrmSplashScreen.getInstance().Close();

                if (Settings.Default.UseSQLServer)
                {
                    MessageCollector.AddExceptionMessage(Language.strLoadFromSqlFailed, ex);
                    var commandButtons = string.Join("|", Language.strCommandTryAgain,
                                                     Language.strCommandOpenConnectionFile,
                                                     string.Format(Language.strCommandExitProgram,
                                                                   Application.ProductName));
                    CTaskDialog.ShowCommandBox(Application.ProductName, Language.strLoadFromSqlFailed,
                                               Language.strLoadFromSqlFailedContent,
                                               MiscTools.GetExceptionMessageRecursive(ex), "", "",
                                               commandButtons, false, ESysIcons.Error, ESysIcons.Error);
                    switch (CTaskDialog.CommandButtonResult)
                    {
                    case 0:
                        LoadConnections(withDialog);
                        return;

                    case 1:
                        Settings.Default.UseSQLServer = false;
                        LoadConnections(true);
                        return;

                    default:
                        Application.Exit();
                        return;
                    }
                }

                if (ex is FileNotFoundException && !withDialog)
                {
                    MessageCollector.AddExceptionMessage(
                        string.Format(Language.strConnectionsFileCouldNotBeLoadedNew,
                                      connectionFileName), ex,
                        MessageClass.InformationMsg);

                    string[] commandButtons =
                    {
                        Language.ConfigurationCreateNew,
                        Language.ConfigurationCustomPath,
                        Language.ConfigurationImportFile,
                        Language.strMenuExit
                    };

                    var answered = false;
                    while (!answered)
                    {
                        try
                        {
                            CTaskDialog.ShowTaskDialogBox(
                                GeneralAppInfo.ProductName,
                                Language.ConnectionFileNotFound,
                                "", "", "", "", "",
                                string.Join(" | ", commandButtons),
                                ETaskDialogButtons.None,
                                ESysIcons.Question,
                                ESysIcons.Question);

                            switch (CTaskDialog.CommandButtonResult)
                            {
                            case 0:
                                ConnectionsService.NewConnectionsFile(connectionFileName);
                                answered = true;
                                break;

                            case 1:
                                LoadConnections(true);
                                answered = true;
                                break;

                            case 2:
                                ConnectionsService.NewConnectionsFile(connectionFileName);
                                Import.ImportFromFile(ConnectionsService.ConnectionTreeModel.RootNodes[0]);
                                answered = true;
                                break;

                            case 3:
                                Application.Exit();
                                answered = true;
                                break;
                            }
                        }
                        catch (Exception exc)
                        {
                            MessageCollector.AddExceptionMessage(
                                string
                                .Format(Language.strConnectionsFileCouldNotBeLoadedNew,
                                        connectionFileName), exc,
                                MessageClass.InformationMsg);
                        }
                    }

                    return;
                }

                MessageCollector.AddExceptionStackTrace(
                    string.Format(Language.strConnectionsFileCouldNotBeLoaded,
                                  connectionFileName), ex);
                if (connectionFileName != ConnectionsService.GetStartupConnectionFileName())
                {
                    LoadConnections(withDialog);
                }
                else
                {
                    MessageBox.Show(FrmMain.Default,
                                    string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine,
                                                  Application.ProductName,
                                                  ConnectionsService.GetStartupConnectionFileName(),
                                                  MiscTools.GetExceptionMessageRecursive(ex)),
                                    @"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
            }
        }