Exemplo n.º 1
0
        private void UpdateBackupOptionsGrid(string ConfigName)
        {
            DataTable OptionIDs      = new DataTable("OptionIDs");
            DataTable OptionToSelect = new DataTable("ConfigsToSelect");

            //Build SQL Command
            string SQLCommand = "SELECT opts.[OptionID] FROM [Backup].[Options] opts LEFT JOIN [Backup].[Configs] bakC ON bakC.OptionID = opts.OptionID " +
                                "LEFT JOIN [Configuration].[Configs] CC ON CC.ConfigID = bakC.ConfigID";

            if (ConfigName.ToLower() != "null")
            {
                SQLCommand = SQLCommand + " WHERE CC.[ConfigName] = \'" + ConfigName + "\'";
            }
            SQLCommand = SQLCommand + " ORDER BY opts.[OptionID];";

            OptionIDs = SQLQueryHandler.ExecuteSQLCommand(LoadTabData.CurrentUtilityServer, LoadTabData.UtilityDatabaseName, SQLCommand, true);
            this.dgvOptions.DataSource = OptionIDs;

            //Resize and reset selection
            DataGridViewColumn column = dgvOptions.Columns[0];

            column.MinimumWidth = dgvOptions.Width - 4;
            this.dgvOptions.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
            this.dgvOptions.ClearSelection();
        }
Exemplo n.º 2
0
        private void RemoveUtilityServer()
        {
            if ((LoadTabData.CurrentUtilityServer != null) && (LoadTabData.CurrentUtilityServer != ""))
            {
                string SQLCommand = "DELETE FROM Configuration.DataSources WHERE ConnectionName = \'" + LoadTabData.CurrentUtilityServer + "\'";

                SQLQueryHandler.ExecuteSQLCommand(LoadTabData.CurrentCentralUtilityServer, LoadTabData.CentalUtilityDatabaseName, SQLCommand, false);
            }

            RefreshUtilityServerList();
        }
Exemplo n.º 3
0
        private void UpdateBackupDatabaseGrid(string OptionID)
        {
            DataTable DatabaseNames     = new DataTable("DatabaseNames");
            DataTable DatabasesToSelect = new DataTable("DatabasesToSelect");

            //Build SQL Command
            string SQLCommand = "SELECT [DatabaseName] FROM [Configuration].[RegisteredDatabases] ORDER BY [DatabaseName];";

            DatabaseNames = SQLQueryHandler.ExecuteSQLCommand(LoadTabData.CurrentUtilityServer, LoadTabData.UtilityDatabaseName, SQLCommand, true);
            this.dgvDatabases.DataSource = DatabaseNames;

            //Resize and reset selection
            DataGridViewColumn column = dgvDatabases.Columns[0];

            column.MinimumWidth = dgvDatabases.Width - 4;
            this.dgvDatabases.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
            this.dgvDatabases.ClearSelection();

            //Select the appropriate Configs if necessary
            if (OptionID.ToLower() != "null")
            {
                //Load filtered list
                SQLCommand        = "SELECT DISTINCT [DatabaseName] FROM [Backup].[vwGetBackupPlan] WHERE [OptionID] = " + OptionID + " AND [DatabaseName] <> \'None\'";
                DatabasesToSelect = SQLQueryHandler.ExecuteSQLCommand(LoadTabData.CurrentUtilityServer, LoadTabData.UtilityDatabaseName, SQLCommand, true);

                //Loop through results to select each
                for (int index = 0; index < dgvDatabases.RowCount; index++)
                {
                    foreach (DataRow row in DatabasesToSelect.Rows)
                    {
                        foreach (DataColumn DataTableColumn in DatabasesToSelect.Columns)
                        {
                            if (dgvDatabases.Rows[index].Cells[0].Value.ToString() == row[DataTableColumn].ToString())
                            {
                                dgvDatabases[0, index].Selected = true;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void AddNewUtilityServer()
        {
            string       input   = Interaction.InputBox("Enter the name of the server that you wish to add.", "Add Utility Server", "<Enter Server Name Here>");
            DialogResult result  = new DialogResult();
            bool         IsValid = false;

            do
            {
                if ((input == null) || (input == string.Empty))
                {
                    result = DialogResult.Cancel;
                }
                else
                {
                    toolStripStatusLabel.Text = "Performing connection test on \'" + input + "\'...";
                    Application.DoEvents();
                    IsValid = SQLQueryHandler.IsValidSQLConnection(input, LoadTabData.UtilityDatabaseName);
                    toolStripStatusLabel.Text = "Ready";
                    Application.DoEvents();

                    if (IsValid)
                    {
                        string SQLCommand = "IF NOT EXISTS (SELECT ConnectionName FROM Configuration.DataSources WHERE ConnectionName = \'" + input +
                                            "\') BEGIN INSERT INTO Configuration.DataSources (ConnectionName, ConnectionString) VALUES (\'" + input +
                                            "\',\'Data Source=" + input + ";Initial Catalog=" + LoadTabData.UtilityDatabaseName + ";Provider=SQLNCLI10.1;Integrated " +
                                            "Security=SSPI;Application Name=Utility;Auto Translate=False;\') END";

                        SQLQueryHandler.ExecuteSQLCommand(LoadTabData.CurrentCentralUtilityServer, LoadTabData.CentalUtilityDatabaseName, SQLCommand, false);
                    }
                    else
                    {
                        result = MessageBox.Show("Connection test failed for \'" + input + "\'. Record was not inserted.", "Connection Test", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                    }
                }
            }while ((result == DialogResult.Retry) && (!IsValid));

            toolStripStatusLabel.Text = "Ready";
            Application.DoEvents();

            RefreshUtilityServerList();
        }