Beispiel #1
0
 private void deployTypeSet(ConfigurationForm form, Configuration config)
 {
     if (form.DeployTypeRadioDropCreate.Checked)
     {
         config.type = 1;
     }
     else
     {
         if (form.DeployTypeRadioAlter.Checked)
         {
             config.type = 2;
         }
         else if (form.DeployTypeRadioTransfer.Checked)
         {
             config.type = 3;
         }
         else
         {
             config.type = 4;
         }
     }
 }
Beispiel #2
0
        private void configAddButton_Click(object sender, EventArgs e)
        {
            Source source = (Source)(sourceList.SelectedItem);

            if (source == null)
            {
                MessageBox.Show("Please select a source to which you want to add a configuration.");
            }
            else
            {
                bool AlreadyClosed = false;

                ConfigurationForm form = new ConfigurationForm();

                form.meta = meta;
                form.dbDeployForm = this;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    Configuration config = new Configuration();

                    config.title = form.TitleText.Text;
                    config.transferMaxRows = long.Parse(form.maxRowsText.Text);

                    //config.targetId = target.id;

                    deployTypeSet(form, config);

                    if (form.SchemaSelectRadioInclude.Checked)
                        config.tableSelectSchema = 1;
                    else
                        config.tableSelectSchema = 2;

                    if (form.DataSelectRadioInclude.Checked)
                        config.tableSelectData = 1;
                    else
                        config.tableSelectData = 2;

                    if (form.DataTransferCheckStatic.Checked)
                        config.transferStaticData = "Y";
                    else
                        config.transferStaticData = "N";

                    if (form.DataTransferCheckTypes.Checked)
                        config.transferTypesData = "Y";
                    else
                        config.transferTypesData = "N";

                    if (form.ddlLoggingRadioNone.Checked)
                        config.ddlLogging = Configuration.DdlLogging.none;
                    else if (form.ddlLoggingRadioChanges.Checked)
                        config.ddlLogging = Configuration.DdlLogging.changes;
                    else
                        config.ddlLogging = Configuration.DdlLogging.all;

                    // Could get this from the DB but iiSDLC says it should ALWAYS be done
                    if (form.backupPerformCheck.Checked)
                        config.backupPerform = "Y";
                    else
                        config.backupPerform = "N";

                    config.backupLocation = form.backupLocationText.Text;

                    if (form.excludeSchemaTempCheck.Checked)
                        config.tempExcludeSchema = "Y";
                    else
                        config.tempExcludeSchema = "N";

                    if (form.excludeDataTempCheck.Checked)
                        config.tempExcludeData = "Y";
                    else
                        config.tempExcludeData = "N";

                    if (form.SyncFKCheck.Checked)
                        config.FKCheckSync = "Y";
                    else
                        config.FKCheckSync = "N";

                    OdbcCommand command = new OdbcCommand();
                    command.Connection = meta;
                    command.CommandType = CommandType.Text;
                    command.CommandText = "insert into meta_db_deploy_configurations( " +
                        " meta_db_deploy_type, " +
                        " meta_db_deploy_tbl_sel_schema, " +
                        " meta_db_deploy_tbl_sel_data, " +
                        " meta_dbdc_title, " +
                        " meta_dbdc_transfer_static_data, " +
                        " meta_dbdc_transfer_types_data, " +
                        " meta_dbdc_transfer_max_rows, " +
                        " meta_db_deploy_log_type, " +
                        " meta_dbdc_temp_exclude_schema, " +
                        " meta_dbdc_temp_exclude_data, " +
                        " meta_dbdc_backup_perform, " +
                        " meta_dbdc_backup_location, " +
                        " meta_dbdc_exclude_fk " +
                        ") " +
                        " values (" +
                        config.type + ", " +
                        config.tableSelectSchema + ", " +
                        config.tableSelectData + ", " +
                        " ?, " +
                        " '" + config.transferStaticData + "', " +
                        " '" + config.transferTypesData + "', " +
                        config.transferMaxRows + ", " +
                        ((long)config.ddlLogging) + ", " +
                        " '" + config.tempExcludeSchema + "', " +
                        " '" + config.tempExcludeData + "', " +
                        " '" + config.backupPerform +"', " +
                        " ? " + ", " +
                        " '" + config.FKCheckSync + "'" +
                        ")";
                    command.Parameters.Add(new OdbcParameter("1", config.title));
                    command.Parameters.Add(new OdbcParameter("2", config.backupLocation));

                    try
                    {
                        meta.Open();
                        try
                        {
                            if (command.ExecuteNonQuery() == 1)
                            {
                                log.log(Logger.LogLevel.info, "Configuration added successfully.");

                                command.CommandText = "select max(meta_db_deploy_configuration) from meta_db_deploy_configurations";
                                config.id = (long)(command.ExecuteScalar());

                                meta.Close();
                                AlreadyClosed = true;

                                configurationList.Items.Add(config);
                                configurationList.SelectedItem = config;
                                TableSelectUpdate(config, form.SchemaTableList, form.DataTableList, form.FilterTableList);
                            }
                            else
                            {
                                log.log(Logger.LogLevel.error, "Configuration was not added.");
                            }
                        }
                        catch (Exception ex)
                        {
                            log.log(Logger.LogLevel.error, "Exception occurred while trying to add configuration...");
                            log.log(Logger.LogLevel.error, ex.Message);
                        }
                        finally
                        {
                            if (!AlreadyClosed)
                            {
                                meta.Close();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.log(Logger.LogLevel.error, "Exception occurred while trying to add configuration...");
                        log.log(Logger.LogLevel.error, ex.Message);
                    }
                }
            }
        }
Beispiel #3
0
        private void configEditButton_Click(object sender, EventArgs e)
        {
            Configuration config = (Configuration)(configurationList.SelectedItem);

            if (config == null)
            {
                MessageBox.Show("Please select a configuration to edit.");
            }
            else
            {
                ConfigurationForm form = new ConfigurationForm();

                form.meta = meta;
                form.dbDeployForm = this;

                form.TitleText.Text = config.title;
                form.maxRowsText.Text = config.transferMaxRows.ToString();

                switch (config.type)
                {
                    case 1:
                        form.DeployTypeRadioDropCreate.Checked = true;
                        break;

                    case 2:
                        form.DeployTypeRadioAlter.Checked = true;
                        break;

                    case 3:
                        form.DeployTypeRadioTransfer.Checked = true;
                        break;

                    case 4:
                        form.DeployTypeRadioLogOnly.Checked = true;
                        break;
                }

                if (config.tableSelectSchema == 1)
                    form.SchemaSelectRadioInclude.Checked = true;
                else
                    form.SchemaSelectRadioExclude.Checked = true;

                if (config.tableSelectData == 1)
                    form.DataSelectRadioInclude.Checked = true;
                else
                    form.DataSelectRadioExclude.Checked = true;

                if (config.transferStaticData == "Y")
                    form.DataTransferCheckStatic.Checked = true;
                else
                    form.DataTransferCheckStatic.Checked = false;

                if (config.transferTypesData == "Y")
                    form.DataTransferCheckTypes.Checked = true;
                else
                    form.DataTransferCheckTypes.Checked = false;

                switch (config.ddlLogging)
                {
                    case Configuration.DdlLogging.none:
                        form.ddlLoggingRadioNone.Checked = true;
                        break;

                    case Configuration.DdlLogging.changes:
                        form.ddlLoggingRadioChanges.Checked = true;
                        break;

                    case Configuration.DdlLogging.all:
                        form.ddlLoggingRadioAll.Checked = true;
                        break;
                }

                // Could get this from the DB but iiSDLC says it should ALWAYS be done
                form.backupPerformCheck.Checked = true;
                form.backupLocationText.Text = config.backupLocation;

                if (config.tempExcludeSchema == "Y")
                    form.excludeSchemaTempCheck.Checked = true;
                else
                    form.excludeSchemaTempCheck.Checked = false;

                if (config.tempExcludeData == "Y")
                    form.excludeDataTempCheck.Checked = true;
                else
                    form.excludeDataTempCheck.Checked = false;

                if (config.FKCheckSync == "Y")
                    form.SyncFKCheck.Checked = true;
                else
                    form.SyncFKCheck.Checked = false;

                TableSelectSet(form.SchemaTableList, config.schemaTables);
                TableSelectSet(form.DataTableList, config.dataTables);
                TableSelectSet(form.FilterTableList, config.filterTables);

                if (form.ShowDialog() == DialogResult.OK)
                {
                    config.title = form.TitleText.Text;
                    config.transferMaxRows = long.Parse(form.maxRowsText.Text);

                    deployTypeSet(form,config);

                    if (form.SchemaSelectRadioInclude.Checked)
                        config.tableSelectSchema = 1;
                    else
                        config.tableSelectSchema = 2;

                    if (form.DataSelectRadioInclude.Checked)
                        config.tableSelectData = 1;
                    else
                        config.tableSelectData = 2;

                    if (form.DataTransferCheckStatic.Checked)
                        config.transferStaticData = "Y";
                    else
                        config.transferStaticData = "N";

                    if (form.DataTransferCheckTypes.Checked)
                        config.transferTypesData = "Y";
                    else
                        config.transferTypesData = "N";

                    if (form.ddlLoggingRadioNone.Checked)
                        config.ddlLogging = Configuration.DdlLogging.none;
                    else if (form.ddlLoggingRadioChanges.Checked)
                        config.ddlLogging = Configuration.DdlLogging.changes;
                    else
                        config.ddlLogging = Configuration.DdlLogging.all;

                    // Could get this from the DB but iiSDLC says it should ALWAYS be done
                    if (form.backupPerformCheck.Checked)
                        config.backupPerform = "Y";
                    else
                        config.backupPerform = "N";

                    config.backupLocation = form.backupLocationText.Text;

                    if (form.excludeSchemaTempCheck.Checked)
                        config.tempExcludeSchema = "Y";
                    else
                        config.tempExcludeSchema = "N";

                    if (form.excludeDataTempCheck.Checked)
                        config.tempExcludeData = "Y";
                    else
                        config.tempExcludeData = "N";

                    if (form.SyncFKCheck.Checked)
                        config.FKCheckSync = "Y";
                    else
                        config.FKCheckSync = "N";

                    OdbcCommand command = new OdbcCommand();
                    command.Connection = meta;
                    command.CommandType = CommandType.Text;
                    command.CommandText = "update meta_db_deploy_configurations" +
                        //" set meta_db_deploy_target = " + config.targetId + "," +
                        " set meta_db_deploy_type = " + config.type + "," +
                        " meta_db_deploy_tbl_sel_schema = " + config.tableSelectSchema + "," +
                        " meta_db_deploy_tbl_sel_data = " + config.tableSelectData + "," +
                        " meta_dbdc_title = ?," +
                        " meta_dbdc_transfer_static_data = '" + config.transferStaticData + "'," +
                        " meta_dbdc_transfer_types_data = '" + config.transferTypesData + "', " +
                        " meta_dbdc_transfer_max_rows = " + config.transferMaxRows + ", " +
                        " meta_db_deploy_log_type = " + ((long)config.ddlLogging) + "," +
                        " meta_dbdc_temp_exclude_schema = '" + config.tempExcludeSchema + "'," +
                        " meta_dbdc_temp_exclude_data = '" + config.tempExcludeData + "'," +
                        " meta_dbdc_backup_perform = '" + config.backupPerform + "'," +
                        " meta_dbdc_backup_location = ?," +
                        " meta_dbdc_exclude_fk = '" + config.FKCheckSync + "'" +
                        " where meta_db_deploy_configuration = " + config.id;
                    command.Parameters.Add(new OdbcParameter("1", config.title));
                    command.Parameters.Add(new OdbcParameter("2", config.backupLocation));

                    try
                    {
                        meta.Open();
                        try
                        {
                            if (command.ExecuteNonQuery() == 1)
                            {
                                log.log(Logger.LogLevel.info, "Configuration udpated successfully.");
                            }
                            else
                            {
                                log.log(Logger.LogLevel.error, "Configuration was not updated.");
                            }
                        }
                        catch (Exception ex)
                        {
                            log.log(Logger.LogLevel.error, "Exception occurred while trying to update configuration...");
                            log.log(Logger.LogLevel.error, ex.Message);
                        }
                        finally
                        {
                            meta.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        log.log(Logger.LogLevel.error, "Exception occurred while trying to add target...");
                        log.log(Logger.LogLevel.error, ex.Message);
                    }

                    TableSelectUpdate(config, form.SchemaTableList,form.DataTableList, form.FilterTableList);

                    // Force the title in the list to be updated.
                    configurationList.Items.Remove(config);
                    configurationList.Items.Add(config);
                    configurationList.SelectedItem = config;
                }
            }
        }