private void LoadConfiguration()
        {
            try
            {
                string strConfigFile = null;
                if (cmbConfigFile.Items.Count > 1)
                {
                    strConfigFile = cmbConfigFile.SelectedItem.ToString();
                }


                if (strConfigFile != NEW_CONFIG_FILE)
                {
                    //Set the Current Configuration in Settings file for future persistence
                    new MySettingsUserConfig().SetCurrentConfiguration(MySettingsUserConfig.KEY_CONFIG_NAME, strConfigFile);

                    //Change the Application Configuration
                    MySettingsEnvironments config = new MySettingsEnvironments(strConfigFile);
                    frmParent.UpdateConfig(config);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                UtilGeneral.ShowError(ex.Message);
            }
        }
 private void btnDefault_Click(object sender, EventArgs e)
 {
     try
     {
         LoadDefaultValues();
     }
     catch (Exception ex)
     {
         UtilGeneral.ShowError(ex.Message);
     }
 }
示例#3
0
 private void btnConfig_Click(object sender, EventArgs e)
 {
     try
     {
         ShowConfigForm();
     }
     catch (Exception ex)
     {
         UtilGeneral.ShowError(ex.Message);
     }
 }
示例#4
0
 private void btnReadXML_Click(object sender, EventArgs e)
 {
     try
     {
         ReadFromXML();
     }
     catch (Exception ex)
     {
         UtilGeneral.ShowError(ex.Message);
     }
 }
示例#5
0
 private void btnGenerate_Click(object sender, EventArgs e)
 {
     try
     {
         GenerateScript();
     }
     catch (Exception ex)
     {
         UtilGeneral.ShowError(ex.Message);
     }
 }
示例#6
0
        //Button Actions

        private void btnSaveXML_Click(object sender, EventArgs e)
        {
            try
            {
                SaveListToXML();
            }
            catch (Exception ex)
            {
                UtilGeneral.ShowError(ex.Message);
            }
        }
示例#7
0
 private void btnLoadData_Click(object sender, EventArgs e)
 {
     try
     {
         LoadTableListFromDatabase();
     }
     catch (Exception ex)
     {
         UtilGeneral.ShowError(ex.Message);
     }
 }
示例#8
0
        /// <summary>
        /// Initial routine for the form
        /// </summary>
        public frmMain()
        {
            InitializeComponent();
            this.Top  = 0;
            this.Left = 0;

            this.Width  = Screen.PrimaryScreen.WorkingArea.Width;
            this.Height = Screen.PrimaryScreen.WorkingArea.Height;

            tlpMain.Width   = this.Width;
            dgvTables.Width = (int)(tlpMain.Width * 0.9);

            tlpMain.Height   = this.Height - (sbrMain.Height * 5);
            dgvTables.Height = (int)(tlpMain.Height * 0.9);
            tlpRight.Height  = (int)(tlpMain.Height * 0.9);

            this.Show();

            try
            {
                CurrentConfigFileName = UtilGeneral.GetConfigValue(MySettingsUserConfig.KEY_CONFIG_NAME);

                if (CurrentConfigFileName == "")
                {
                    ShowConfigForm();
                }
                else
                {
                    SQLDwConfig = new MySettingsEnvironments(CurrentConfigFileName);

                    if (!SQLDwConfig.ConfigFileExists())
                    {
                        UtilGeneral.ShowMessage("Configuration File do not exist. Please create a Configuration file to continue");
                        ShowConfigForm();
                    }
                    else
                    {
                        LoadData();
                    }
                }


                if (dgvTables.ColumnCount > 0)
                {
                    dgvTables.Columns[MyTableList.TABLE_NAME].AutoSizeMode    = DataGridViewAutoSizeColumnMode.AllCells;
                    dgvTables.Columns[MyTableList.INDEX_TYPE].AutoSizeMode    = DataGridViewAutoSizeColumnMode.AllCells;
                    dgvTables.Columns[MyTableList.BCP_SPLIT_VALUE_TYPE].Width = 30;
                }
            }
            catch (Exception ex)
            {
                UtilGeneral.ShowError(ex.Message);
            }
        }
示例#9
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         SaveUpdates();
         this.Close();
     }
     catch (Exception ex)
     {
         UtilGeneral.ShowError(ex.Message);
     }
 }
示例#10
0
 //Form UI Actions
 private void dgvTables_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             frmTableDetails f = new frmTableDetails(this, dgvTables.Rows[e.RowIndex], SQLDwConfig);
             f.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         UtilGeneral.ShowError(ex.Message);
     }
 }
示例#11
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);
            }
        }
 private void btnRemoveItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (lstValues.Items.Count > 0)
         {
             while (lstValues.SelectedItems.Count > 0)
             {
                 lstValues.Items.Remove(lstValues.SelectedItem);
             }
         }
     }
     catch (Exception ex)
     {
         UtilGeneral.ShowError(ex.Message);
     }
 }
        // UI Actions
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                SaveConfig();

                DialogResult result = MessageBox.Show("Configuration Saved. Do you want to load the Configuration now!!", "Save", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

                if (result.Equals(DialogResult.OK))
                {
                    LoadConfiguration();
                }
            }
            catch (Exception ex)
            {
                UtilGeneral.ShowError(ex.Message);
            }
        }
        //Anchor function to fill values in the list based on Selection
        private void FillValues()
        {
            DataTable dtColValues = new DataTable();

            try
            {
                // Chose how list will be populated
                // (1) From Database (2) From Database but dates (3) From UI time selection
                if (optValueTable.Checked)
                {
                    if (optSplitColumn.Checked)
                    {
                        dtColValues = FillValuesFromDB();
                    }
                    else
                    {
                        dtColValues = FillValuesFromDBDateFormatted();
                    }
                }
                else
                {
                    dtColValues = FillValuesTimeSeries();
                }

                // Fill the list box but do not allow if number of values are more than 500
                lstValues.Items.Clear();
                if (dtColValues.Rows.Count < 500)
                {
                    foreach (DataRow row in dtColValues.Rows)
                    {
                        lstValues.Items.Add(row[0]);
                    }
                }
                else
                {
                    UtilGeneral.ShowMessage("Too Many Values in the Column : " + dtColValues.Rows.Count);
                }
            }
            catch (Exception ex)
            {
                UtilGeneral.ShowError(ex.ToString());
            }
        }
        private void TestConnection()
        {
            string strConnString;

            string strServer, strUser, strPassword, strDatabase, strConn = "";

            strServer   = txtAzServer.Text;
            strUser     = txtAzUser.Text;
            strPassword = txtAzPassword.Text;
            strDatabase = txtAzDatabase.Text;
            strConn     = strServer + "." + strDatabase;

            strConnString = "Server=tcp:" + strServer + ";Database=" + strDatabase + ";Uid=" + strUser + ";Password="******"Connection successful");

                MySettingsSQLDwConnList SQLDwList = new MySettingsSQLDwConnList(strConn);
                //strPassword = UtilCryptor.Crypt(strPassword);
                SQLDwList.SaveConnection(strServer, strDatabase, strUser, strPassword);

                this.btnNext.Enabled = true;
                this.AzConnString    = strConnString;
            }
            catch
            {
                this.btnMigrate.Enabled = false;
                this.AzConnString       = "";
                UtilGeneral.ShowError("Error connecting to database");
            }
            finally
            {
                conn.Close();
            }
        }
        private void MigrateData()
        {
            MyScriptWriter ScriptWriter = new MyScriptWriter(SQLDwConfig);
            string         strScript    = "";

            MyUtilityPowerShell  MPS = new MyUtilityPowerShell();
            MyUtilityCommandLine CLU = new MyUtilityCommandLine();

            if (CheckMigrationStep(Constants.MIGRATE_STEP_BCP_DATA))
            {
                ShowProgressMessage("Generating BCP Files");
                strScript = ScriptWriter.GenerateBCPScript(dtTable, false, true);
                CLU.ExecuteScript(strScript);
            }

            if (CheckMigrationStep(Constants.MIGRATE_STEP_UTF8_CONVERT))
            {
                ShowProgressMessage("Converting Files to UTF8");
                strScript = ScriptWriter.GeneratePSFileUTF8(true);
                MPS.ExecuteScript(strScript);
            }

            if (CheckMigrationStep(Constants.MIGRATE_STEP_COMPRESS_FILES))
            {
                ShowProgressMessage("Compressing Files");
                strScript = ScriptWriter.GeneratePSFileZip(true);
                MPS.ExecuteScript(strScript);
            }

            if (CheckMigrationStep(Constants.MIGRATE_STEP_BLOB_UPLOAD))
            {
                ShowProgressMessage("Copying Files to BLOB");
                strScript = ScriptWriter.GenerateAZCopyFile(true);
                CLU.ExecuteScript(strScript);
            }

            SqlConnection conn;

            conn = new SqlConnection(AzConnString);
            try
            {
                string SQL = "";
                conn.Open();
                SqlCommand comm;

                if (CheckMigrationStep(Constants.MIGRATE_STEP_AZURE_ENV_PREPARE))
                {
                    ShowProgressMessage("Preparing Azure Environment");
                    SQL  = ScriptWriter.GenerateAzurePrepSQL(true);
                    comm = new SqlCommand(SQL, conn);
                    comm.ExecuteNonQuery();
                }

                if (CheckMigrationStep(Constants.MIGRATE_STEP_EXTERNAL_TABLE))
                {
                    ShowProgressMessage("Creating External Tables");
                    SQL  = ScriptWriter.GenerateTableCreateExternal(dtTable, true, true);
                    comm = new SqlCommand(SQL, conn);
                    comm.CommandTimeout = 0;
                    comm.ExecuteNonQuery();
                }

                if (CheckMigrationStep(Constants.MIGRATE_STEP_DATA_WAREHOUSE_TABLE))
                {
                    ShowProgressMessage("Creating Data Warehouse Tables");
                    SQL  = ScriptWriter.GenerateTableCreateDWH(dtTable, true, true);
                    comm = new SqlCommand(SQL, conn);
                    comm.CommandTimeout = 0;
                    comm.ExecuteNonQuery();
                }

                if (CheckMigrationStep(Constants.MIGRATE_STEP_INSERT))
                {
                    ShowProgressMessage("Inserting data");
                    SQL  = ScriptWriter.GenerateInsertFromExternalTable(dtTable, true);
                    comm = new SqlCommand(SQL, conn);
                    comm.CommandTimeout = 0;
                    comm.ExecuteNonQuery();
                }

                ShowProgressMessage("Finished");
            }
            catch (Exception ex)
            {
                ShowProgressMessage("Error");
                UtilGeneral.ShowError(ex.Message);
            }
            finally
            {
                conn.Close();
            }
        }