private void ButtonCompare_Click(object sender, EventArgs e) { string connectionStringSource = GetConnectionString(InputGroup.Source); string connectionStringDestination = GetConnectionString(InputGroup.Destination); // test both connections if ((Util.TestConnection(connectionStringSource, false) == null) || (Util.TestConnection(connectionStringDestination, false) == null)) { MessageBox.Show("Connection could not be established."); return; } // check whether the input tables were obtained string[] tableNames = Util.GetTableNames(TextBoxInputFile.Text); if (tableNames == null) { MessageBox.Show("input file path does not exist"); return; } // check if the output path exists if (!Util.CheckPathExists(TextBoxOutputFile.Text)) { MessageBox.Show("Output path does not exist"); return; } string outputFilePath = Util.GetOutputFilePath(TextBoxOutputFile.Text); // build command (most of it anyway) TableDiffArgBuilder builder = CreateArgs(); // run the command on each input table foreach (string tableName in tableNames) { string args = builder.AppendSourceTable(tableName).AppendDestinationTable(tableName).ToString(); // append the table name string tableDiffUtilityPath = Util.GetTableDbDiffUtilityPath(); if (string.IsNullOrEmpty(tableDiffUtilityPath)) { return; } Util.RunTableDbDiff(tableDiffUtilityPath, args); } MessageBox.Show("Success! Check the output file at:\n" + TextBoxOutputFile.Text); }
// creates a TableDiff args builder with all argumnets specified except for the table name private TableDiffArgBuilder CreateArgs() { TableDiffArgBuilder builder = new TableDiffArgBuilder(); builder.AppendSourceServer(GetServerName(InputGroup.Source)). AppendSourceDatabase(GetDatabaseName(InputGroup.Source)). AppendSourceUser(GetLogin(InputGroup.Source)). AppendSourcePassword(GetPassword(InputGroup.Source)). AppendDestinationServer(GetServerName(InputGroup.Destination)). AppendDestinationDatabase(GetDatabaseName(InputGroup.Destination)). AppendDestinationUser(GetLogin(InputGroup.Destination)). AppendDestinationPassword(GetPassword(InputGroup.Destination)). AppendOutputFilePath(TextBoxOutputFile.Text); return(builder); }