/// <summary> /// Save Table list of XML file /// </summary> private void SaveListToXML() { txtTable.Text = ""; //Replace the Data Grid as we want to save the updated list. DataTable dtgv = new DataTable(); foreach (DataGridViewColumn col in this.dgvTables.Columns) { if (col.HeaderText == MyTableList.DATA_SIZE_MB || col.HeaderText == MyTableList.TOTAL_ROWS) { dtgv.Columns.Add(col.HeaderText, Type.GetType("System.Int32")); } else { dtgv.Columns.Add(col.HeaderText); } } foreach (DataGridViewRow row in this.dgvTables.Rows) { DataRow dRow = dtgv.NewRow(); foreach (DataGridViewCell cell in row.Cells) { dRow[cell.ColumnIndex] = cell.Value; } dtgv.Rows.Add(dRow); } dtTable.ReplaceTableList(dtgv); string strFolder, strFileName; strFolder = Properties.Settings.Default.ApplicationFolder + "\\" + Constants.SUB_FOLDER_LIST; strFileName = SQLDwConfig.ConfigFileName.Replace(".Config", ".xml"); dtTable.SaveListToXML(strFolder, strFileName); //After the XML file is saved. Read it back on the Grid from the file ReadFromXML(); }
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); } }
/// <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"; }