예제 #1
0
        /// <summary>
        /// Default Routine to update information on Form
        /// </summary>
        public void LoadData()
        {
            dtTable = new MyTableList(SQLDwConfig);
            this.dgvTables.DataSource = dtTable.GetTableList();


            cmbDataType.Items.Clear();
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_ALL);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_DWH_TABLE_CREATE);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_EXTERNAL_TABLE_CREATE);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_INSERT_FROM_EXT_TABLE);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_DWH_TABLE_DROP);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_EXTERNAL_TABLE_DROP);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_DWH_TABLE_TRUNCATE);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_AZURE);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_BCP);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_TABLE_REFACTOR);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_BCP_EMPTY_FILE);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_DWH_TABLE_CREATE_DROP);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_EXTERNAL_TABLE_CREATE_DROP);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_SELECT_SQL);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_FILE_HEADER);
            cmbDataType.Items.Add(Constants.SCRIPT_TYPE_SQL_ETL);
            cmbDataType.SelectedIndex = 0;

            this.sbpConfig.Text   = CurrentConfigFileName;
            this.sbpServer.Text   = SQLDwConfig.ServerName;
            this.sbpDatabase.Text = SQLDwConfig.DatabaseName;

            optSelectAll.Checked = true;

            this.dgvTables.Columns[MyTableList.SCHEMA_NAME].ReadOnly          = true;
            this.dgvTables.Columns[MyTableList.TABLE_NAME].ReadOnly           = true;
            this.dgvTables.Columns[MyTableList.TOTAL_ROWS].ReadOnly           = true;
            this.dgvTables.Columns[MyTableList.DATA_SIZE_MB].ReadOnly         = true;
            this.dgvTables.Columns[MyTableList.DISTRIBUTION_TYPE].ReadOnly    = true;
            this.dgvTables.Columns[MyTableList.DISTRIBUTION_COLUMN].ReadOnly  = true;
            this.dgvTables.Columns[MyTableList.INDEX_TYPE].ReadOnly           = true;
            this.dgvTables.Columns[MyTableList.INDEX_COLUMN].ReadOnly         = true;
            this.dgvTables.Columns[MyTableList.BCP_SPLIT].ReadOnly            = true;
            this.dgvTables.Columns[MyTableList.BCP_SPLIT_COLUMN].ReadOnly     = true;
            this.dgvTables.Columns[MyTableList.BCP_SPLIT_VALUES].ReadOnly     = true;
            this.dgvTables.Columns[MyTableList.REPLACE_CRLF].ReadOnly         = true;
            this.dgvTables.Columns[MyTableList.BCP_SPLIT_VALUE_TYPE].ReadOnly = true;
            this.dgvTables.Columns[MyTableList.SELECT].ReadOnly = false;

            //Initial formatting for DataGrid
            this.dgvTables.Columns[MyTableList.TOTAL_ROWS].DefaultCellStyle.Format      = "#,##0";
            this.dgvTables.Columns[MyTableList.DATA_SIZE_MB].DefaultCellStyle.Format    = "#,##0";
            this.dgvTables.Columns[MyTableList.TOTAL_ROWS].DefaultCellStyle.Alignment   = DataGridViewContentAlignment.MiddleRight;
            this.dgvTables.Columns[MyTableList.DATA_SIZE_MB].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            this.dgvTables.Columns[MyTableList.TABLE_ID].Visible = false;
        }
        public frmMigrateToSQLDW(MyTableList TableList, frmMain ParentForm, MySettingsEnvironments Config)
        {
            InitializeComponent();
            frmParent               = ParentForm;
            this.dtTable            = TableList;
            this.SQLDwConfig        = Config;
            this.btnMigrate.Enabled = false;
            lblCaption.Text         = "";
            SQLDwConnFolder         = Properties.Settings.Default.ApplicationFolder + "\\" + Constants.SUB_FOLDER_SQLDW_CONN;

            dgvMigrate.Columns.Clear();
            dgvMigrate.Columns.Add(DGV_COL_STEPS, DGV_COL_STEPS);
            DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();

            dgvMigrate.Columns.Add(chk);
            chk.HeaderText = DGV_COL_SELECT;
            chk.Name       = DGV_COL_SELECT;

            gbxMigrationOption.Visible = false;
            gbxMigrationOption.Width   = gbxConnection.Width;
            gbxMigrationOption.Height  = gbxConnection.Height;
            gbxMigrationOption.Left    = gbxConnection.Left;
            gbxMigrationOption.Top     = gbxConnection.Top;
            dgvMigrate.Width           = gbxMigrationOption.Width - 30;
            dgvMigrate.Height          = gbxMigrationOption.Height - 30;


            dgvMigrate.Rows.Add(Constants.MIGRATE_STEP_BCP_DATA);
            dgvMigrate.Rows.Add(Constants.MIGRATE_STEP_UTF8_CONVERT);
            dgvMigrate.Rows.Add(Constants.MIGRATE_STEP_COMPRESS_FILES);
            dgvMigrate.Rows.Add(Constants.MIGRATE_STEP_BLOB_UPLOAD);
            dgvMigrate.Rows.Add(Constants.MIGRATE_STEP_AZURE_ENV_PREPARE);
            dgvMigrate.Rows.Add(Constants.MIGRATE_STEP_EXTERNAL_TABLE);
            dgvMigrate.Rows.Add(Constants.MIGRATE_STEP_DATA_WAREHOUSE_TABLE);
            dgvMigrate.Rows.Add(Constants.MIGRATE_STEP_INSERT);

            dgvMigrate.Columns[DGV_COL_STEPS].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dgvMigrate.Columns[DGV_COL_STEPS].ReadOnly     = true;

            foreach (DataGridViewRow row in dgvMigrate.Rows)
            {
                row.Cells[DGV_COL_SELECT].Value = true;
            }

            /*
             * btnPrevious.Enabled = false;
             * btnNext.Enabled = false;
             * btnMigrate.Enabled = false;
             */
            LoadInitialData();
        }
예제 #3
0
        private void btnMigrate_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable   dtgv    = GetDataTableFromGridView();
                MyTableList dtTable = new MyTableList();
                dtTable.ReplaceTableList(dtgv);

                frmMigrateToSQLDW f = new frmMigrateToSQLDW(dtTable, this, SQLDwConfig);
                f.ShowDialog();
            }
            catch (Exception ex)
            {
                UtilGeneral.ShowError(ex.Message);
            }
        }
예제 #4
0
        /// <summary>
        /// General Routing to generate Script based on the script type selected
        /// </summary>
        private void GenerateScript()
        {
            sbpMessage.Text = "Generating Files....";
            DataTable   dtgv    = GetDataTableFromGridView();
            MyTableList dtTable = new MyTableList();

            dtTable.ReplaceTableList(dtgv);

            string strScriptType;

            strScriptType = cmbDataType.SelectedItem.ToString();

            MyScriptWriter ScriptWriter = new MyScriptWriter(SQLDwConfig);

            switch (strScriptType)
            {
            case Constants.SCRIPT_TYPE_EXTERNAL_TABLE_CREATE:
                ScriptWriter.GenerateTableCreateExternal(dtTable, false, false);
                break;

            case Constants.SCRIPT_TYPE_DWH_TABLE_CREATE:
                ScriptWriter.GenerateTableCreateDWH(dtTable, false, false);
                break;

            case Constants.SCRIPT_TYPE_EXTERNAL_TABLE_CREATE_DROP:
                ScriptWriter.GenerateTableCreateExternal(dtTable, true, false);
                break;

            case Constants.SCRIPT_TYPE_DWH_TABLE_CREATE_DROP:
                ScriptWriter.GenerateTableCreateDWH(dtTable, true, false);
                break;

            case Constants.SCRIPT_TYPE_BCP:
                ScriptWriter.GenerateBCPScript(dtTable, false, false);
                break;

            case Constants.SCRIPT_TYPE_INSERT_FROM_EXT_TABLE:
                ScriptWriter.GenerateInsertFromExternalTable(dtTable, false);
                break;

            case Constants.SCRIPT_TYPE_EXTERNAL_TABLE_DROP:
                ScriptWriter.GenerateTableDrop(dtTable, Constants.TABLE_TYPE_EXTERNAL);
                break;

            case Constants.SCRIPT_TYPE_DWH_TABLE_DROP:
                ScriptWriter.GenerateTableDrop(dtTable, Constants.TABLE_TYPE_DWH);
                break;

            case Constants.SCRIPT_TYPE_DWH_TABLE_TRUNCATE:
                ScriptWriter.GenerateTableTruncate(dtTable);
                break;

            case Constants.SCRIPT_TYPE_AZURE:
                ScriptWriter.GeneratePSFileUTF8(false);
                ScriptWriter.GeneratePSFileZip(false);
                ScriptWriter.GenerateAZCopyFile(false);
                ScriptWriter.GenerateAzurePrepSQL(false);
                break;

            case Constants.SCRIPT_TYPE_FILE_HEADER:
                ScriptWriter.GenerateFileHeaderWithColumnNames(dtTable);
                break;

            case Constants.SCRIPT_TYPE_SELECT_SQL:
                ScriptWriter.GenerateTableSELECTFile(dtTable);
                break;

            case Constants.SCRIPT_TYPE_TABLE_REFACTOR:
                ScriptWriter.GenerateTableRefactor(dtTable);
                break;

            case Constants.SCRIPT_TYPE_BCP_EMPTY_FILE:
                ScriptWriter.GenerateBCPScript(dtTable, true, false);
                break;

            case Constants.SCRIPT_TYPE_SQL_ETL:
                ScriptWriter.GenerateTableCreateSTG(dtTable, false, false);
                ScriptWriter.GenerateTableCreatePersistent(dtTable, false, false);
                ScriptWriter.GenerateMergeSQL(dtTable, false);
                ScriptWriter.GenerateAlterTableForPSA(dtTable, false);
                break;

            case Constants.SCRIPT_TYPE_ALL:
                //Genreate All Scripts
                ScriptWriter.GenerateTableCreateExternal(dtTable, false, false);
                ScriptWriter.GenerateTableCreateDWH(dtTable, false, false);
                ScriptWriter.GenerateBCPScript(dtTable, false, false);
                ScriptWriter.GenerateInsertFromExternalTable(dtTable, false);
                ScriptWriter.GenerateTableDrop(dtTable, Constants.TABLE_TYPE_EXTERNAL);
                ScriptWriter.GenerateTableDrop(dtTable, Constants.TABLE_TYPE_DWH);
                ScriptWriter.GenerateTableTruncate(dtTable);
                ScriptWriter.GeneratePSFileUTF8(false);
                ScriptWriter.GeneratePSFileZip(false);
                ScriptWriter.GenerateAZCopyFile(false);
                ScriptWriter.GenerateAzurePrepSQL(false);
                break;
            }
            sbpMessage.Text = "File(s) Generated";
        }