示例#1
0
        /// <summary>
        /// Call this before ShowDialog to initialise the dialog with entry values to be edited
        /// </summary>
        /// <param name="BranchLocation">The path to the active branch</param>
        /// <param name="Index">The index of the favourite to be edited</param>
        /// <param name="LocalSettings">A reference to the local settings object used to persist personal preferences</param>
        public void InitializeDialog(string BranchLocation, int Index, SettingsDictionary LocalSettings)
        {
            BuildConfiguration dbCfg = new BuildConfiguration(BranchLocation, LocalSettings);
            string dbms, dbName, port, password, location, version;
            bool isBlank;

            dbCfg.GetStoredConfiguration(Index, out dbms, out dbName, out port, out password, out isBlank, out location, out version);

            cboDBMS.SelectedIndex = BuildConfiguration.GetDBMSIndex(dbms);
            txtDBName.Text = dbName;
            txtPort.Text = port;
            txtPassword.Text = password;
            chkBlankPW.Checked = isBlank;
            txtLocation.Text = location;

            if (String.Compare(dbms, "postgresql", true) == 0)
            {
                SetPostgreSQLVersionIndex(version);
            }
            else
            {
                cboVersion.SelectedIndex = 0;
            }

            SetEnabledStates();
        }
示例#2
0
        private void btnEditDbBuildConfig_Click(object sender, EventArgs e)
        {
            int index = listDbBuildConfig.SelectedIndex;

            if (index < 0)
            {
                return;
            }

            DlgDbBuildConfig dlg = new DlgDbBuildConfig();
            dlg.InitializeDialog(BranchLocation, listDbBuildConfig.SelectedIndex, _localSettings);

            if (dlg.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            BuildConfiguration dbCfg = new BuildConfiguration(BranchLocation, _localSettings);
            dbCfg.EditConfig(listDbBuildConfig.SelectedIndex, dlg.ExitData);
            _localSettings.DbBuildConfigurations = dbCfg.FavouriteConfigurations;

            SetBranchDependencies();
            listDbBuildConfig.SelectedIndex = index;
        }
示例#3
0
        private void btnSaveDbBuildConfig_Click(object sender, EventArgs e)
        {
            if (listDbBuildConfig.SelectedIndex < 0)
            {
                return;
            }

            string msg =
                "This will save the selected details to your 'Database Build Configuration File'.  Your existing configuration will be overwritten.  Are you sure you want to do this?";

            if (MessageBox.Show(msg, Program.APP_TITLE, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            // Stop the server because we will restart it again with a different database connection
            int NumFailures = 0;
            int NumWarnings = 0;

            GetServerState();

            if (_serverIsRunning)
            {
                RunSimpleNantTarget(new NantTask(NantTask.TaskItem.stopPetraServer), ref NumFailures, ref NumWarnings);
            }

            //  Ok - we write the specified settings to the config file and remove the unspecified ones
            BuildConfiguration DbCfg = new BuildConfiguration(BranchLocation, _localSettings);

            if (!DbCfg.SetConfigAsDefault(listDbBuildConfig.SelectedIndex))
            {
                return;
            }

            SetBranchDependencies();

            // Optionally run initConfigFiles to get everything matched up
            msg = "Do you want to run the 'InitConfigFiles' task to initialize the other configuration files?";

            if (MessageBox.Show(msg, Program.APP_TITLE, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                RunInitConfigFiles();
            }
        }
示例#4
0
        private void btnRemoveDbBuildConfig_Click(object sender, EventArgs e)
        {
            int index = listDbBuildConfig.SelectedIndex;

            if (index < 0)
            {
                return;
            }

            string msg = "This will remove the selected item from the saved configurations list.  Are you sure?";

            if (MessageBox.Show(msg, Program.APP_TITLE, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            BuildConfiguration dbCfg = new BuildConfiguration(BranchLocation, _localSettings);
            dbCfg.RemoveConfig(index);
            _localSettings.DbBuildConfigurations = dbCfg.FavouriteConfigurations;

            SetBranchDependencies();

            if ((--index < 0) && (listDbBuildConfig.Items.Count > 0))
            {
                index = 0;
            }

            listDbBuildConfig.SelectedIndex = index;
        }
示例#5
0
        private void btnAddDbBuildConfig_Click(object sender, EventArgs e)
        {
            DlgDbBuildConfig dlg = new DlgDbBuildConfig();

            if (dlg.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            BuildConfiguration dbCfg = new BuildConfiguration(BranchLocation, _localSettings);
            dbCfg.AddConfig(dlg.ExitData);
            SetBranchDependencies();
            listDbBuildConfig.SelectedIndex = listDbBuildConfig.Items.Count - 1;
        }
示例#6
0
        private void SetBranchDependencies()
        {
            lblBranchLocation.Text = (BranchLocation == String.Empty) ? "Not defined" : BranchLocation;

            BuildConfiguration dbCfg = new BuildConfiguration(BranchLocation, _localSettings);

            if (BranchLocation == String.Empty)
            {
                lblDbBuildConfig.Text = "";
                lblDatabaseName.Text = "None";
            }
            else
            {
                lblDbBuildConfig.Text = dbCfg.CurrentConfig;
                lblDatabaseName.Text = dbCfg.CurrentDBName;
            }

            dbCfg.ListAllConfigs(listDbBuildConfig);        // This might add a new configuration, so we need to update our local settings
            _localSettings.DbBuildConfigurations = dbCfg.FavouriteConfigurations;
            btnRemoveDbBuildConfig.Enabled = listDbBuildConfig.Items.Count > 0;
            btnEditDbBuildConfig.Enabled = listDbBuildConfig.Items.Count > 0;
            btnSaveDbBuildConfig.Enabled = listDbBuildConfig.Items.Count > 0 && BranchLocation != String.Empty;

            if (BranchLocation == String.Empty)
            {
                txtAutoLogonUser.Text = String.Empty;
                txtAutoLogonPW.Text = String.Empty;
                txtAutoLogonAction.Text = String.Empty;
                chkUseAutoLogon.Checked = false;
                chkUseAutoLogon.Enabled = false;
            }
            else
            {
                ClientAutoLogOn calo = new ClientAutoLogOn(BranchLocation);
                txtAutoLogonUser.Text = calo.UserName;
                txtAutoLogonPW.Text = calo.Password;
                txtAutoLogonAction.Text = calo.TestAction.Replace(",", "\r\n");
                chkUseAutoLogon.Checked = (txtAutoLogonUser.Text != String.Empty);
                chkUseAutoLogon.Enabled = true;
            }
        }
示例#7
0
        private void btnDatabase_Click(object sender, EventArgs e)
        {
            BuildConfiguration dbBldConfig = new BuildConfiguration(BranchLocation, _localSettings);
            string dbName = dbBldConfig.CurrentDBName;
            NantTask task = new NantTask(cboDatabase.Items[cboDatabase.SelectedIndex].ToString());

            if ((task.Item == NantTask.TaskItem.resetDatabase) || (task.Item == NantTask.TaskItem.recreateDatabase))
            {
                if (String.Compare(dbName, "nantTest", true) != 0)
                {
                    // We don't mind nantTest, but any other database name (including demo) gives rise to a warning
                    string msg = String.Format("Warning!  Your current database is '{0}'.  " +
                        "If you proceed you will lose all the information in this database." +
                        "\r\nAre you sure that you want to continue?", dbName);

                    if (MessageBox.Show(msg, Program.APP_TITLE, MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }
                }
            }

            DateTime dtStart = DateTime.UtcNow;

            OutputText.ResetOutput();
            TickTimer.Enabled = false;
            int NumFailures = 0;
            int NumWarnings = 0;

            if (chkAutoStopServer.Checked && (task.Item == NantTask.TaskItem.recreateDatabase))
            {
                // This is a case where we need to auto-stop the server first
                GetServerState();

                if (_serverIsRunning)
                {
                    RunSimpleNantTarget(new NantTask(NantTask.TaskItem.stopPetraServer), ref NumFailures, ref NumWarnings);
                }
            }

            // Now we are ready to perform the original task
            if (NumFailures == 0)
            {
                RunSimpleNantTarget(task, ref NumFailures, ref NumWarnings);
            }

            txtOutput.Text = (chkVerbose.Checked) ? OutputText.VerboseOutput : OutputText.ConciseOutput;

            if ((NumFailures > 0) || ((NumWarnings > 0) && chkTreatWarningsAsErrors.Checked))
            {
                tabControl.SelectedTab = OutputPage;
                chkVerbose.Checked = true;
            }

            PrepareWarnings();

            if ((DateTime.UtcNow - dtStart > TimeSpan.FromSeconds(Convert.ToUInt32(txtFlashAfterSeconds.Text))) && !Focused)
            {
                FlashWindow.Flash(this, 5);
            }

            TickTimer.Enabled = true;
        }
示例#8
0
        private void btnMiscellaneous_Click(object sender, EventArgs e)
        {
            DateTime dtStart = DateTime.UtcNow;

            OutputText.ResetOutput();
            TickTimer.Enabled = false;
            NantTask task = new NantTask(cboMiscellaneous.Items[cboMiscellaneous.SelectedIndex].ToString());
            int NumFailures = 0;
            int NumWarnings = 0;

            if (task.Item == NantTask.TaskItem.uncrustify)
            {
                FolderBrowserDialog dlg = new FolderBrowserDialog();
                dlg.Description = "Select a folder to Uncrustify";
                dlg.SelectedPath = BranchLocation;
                dlg.RootFolder = Environment.SpecialFolder.MyComputer;
                dlg.ShowNewFolderButton = false;

                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                // check the selection is based on teh current branch
                if (!dlg.SelectedPath.StartsWith(BranchLocation, StringComparison.InvariantCultureIgnoreCase))
                {
                    MessageBox.Show("You must choose a folder within the current branch.", Program.APP_TITLE);
                    return;
                }

                // check that the folder contains a .build file
                string[] files = Directory.GetFiles(dlg.SelectedPath, "*.build", SearchOption.TopDirectoryOnly);

                if (files.Length == 0)
                {
                    MessageBox.Show("The selected folder cannot be Uncrustified.  You must choose a folder that contains a BUILD file.",
                        Program.APP_TITLE);
                    return;
                }

                // Ready to run - overriding the usual root location with the specified folder
                RunSimpleNantTarget(task, dlg.SelectedPath, ref NumFailures, ref NumWarnings);
            }
            else if ((task.Item == NantTask.TaskItem.test) || (task.Item == NantTask.TaskItem.testWithoutDisplay)
                     || (task.Item == NantTask.TaskItem.mainNavigationTests))
            {
                BuildConfiguration dbBldConfig = new BuildConfiguration(BranchLocation, _localSettings);
                string dbName = dbBldConfig.CurrentDBName;

                if (String.Compare(dbName, "nantTest", true) != 0)
                {
                    string msg = String.Format(
                        "You are about to run tests using the '{0}' database.  This is a friendly reminder that all the data in the database will be lost.\r\n\r\n",
                        dbName);
                    msg +=
                        "Click OK to continue, or 'Cancel' if you want to select a different database for testing (by moving to the 'database' tab of the Assistant).\r\n\r\n";
                    msg += "The best advice is to create a specific database for testing purposes using PgAdmin or equivalent.\r\n\r\n";
                    msg += "Tip: if you call your test database 'nantTest', it will be used without displaying this message!";

                    if (MessageBox.Show(msg, Program.APP_TITLE, MessageBoxButtons.OKCancel,
                            MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Cancel)
                    {
                        return;
                    }
                }

                RunSimpleNantTarget(task, ref NumFailures, ref NumWarnings);
            }
            else
            {
                RunSimpleNantTarget(task, ref NumFailures, ref NumWarnings);
            }

            txtOutput.Text = (chkVerbose.Checked) ? OutputText.VerboseOutput : OutputText.ConciseOutput;

            if ((NumFailures > 0) || ((NumWarnings > 0) && chkTreatWarningsAsErrors.Checked))
            {
                tabControl.SelectedTab = OutputPage;
                chkVerbose.Checked = true;
            }

            PrepareWarnings();

            if ((DateTime.UtcNow - dtStart > TimeSpan.FromSeconds(Convert.ToUInt32(txtFlashAfterSeconds.Text))) && !Focused)
            {
                FlashWindow.Flash(this, 5);
            }

            TickTimer.Enabled = true;
        }