static bool Work(Argument arguments) { bool completedSuccessfully = false; try { DBDiff.Schema.SQLServer.Generates.Model.Database origen; DBDiff.Schema.SQLServer.Generates.Model.Database destino; if (TestConnection(arguments.ConnectionString1, arguments.ConnectionString2)) { Generate sql = new Generate(); sql.ConnectionString = arguments.ConnectionString1; System.Console.WriteLine("Reading first database..."); sql.Options = SqlFilter; origen = sql.Process(); sql.ConnectionString = arguments.ConnectionString2; System.Console.WriteLine("Reading second database..."); destino = sql.Process(); System.Console.WriteLine("Comparing databases schemas..."); origen = Generate.Compare(origen, destino); System.Console.WriteLine("Generating SQL file..."); SaveFile(arguments.OutputFile, arguments.OutputAll ? origen.ToSql() : origen.ToSqlDiff().ToSQL()); completedSuccessfully = true; } } catch (Exception ex) { System.Console.WriteLine(String.Format("{0}\r\n{1}\r\n\r\nPlease report this issue at http://opendbiff.codeplex.com/workitem/list/basic\r\n\r\n", ex.Message, ex.StackTrace)); } return completedSuccessfully; }
static void Work(Argument arguments) { try { DBDiff.Schema.SQLServer.Generates.Model.Database origen; DBDiff.Schema.SQLServer.Generates.Model.Database destino; if (TestConnection(arguments.ConnectionString1, arguments.ConnectionString2)) { Generate sql = new Generate(); SqlOption opt = new SqlOption(true); opt.Ignore.FilterSchema = false; opt.Ignore.FilterUsers = false; opt.Ignore.FilterTableFileGroup = false; sql.Options = opt; sql.ConnectionString = arguments.ConnectionString1; System.Console.WriteLine("Reading first database..."); //sql.Options = SqlFilter; origen = sql.Process(); sql.ConnectionString = arguments.ConnectionString2; System.Console.WriteLine("Reading second database..."); destino = sql.Process(); System.Console.WriteLine("Comparing databases schemas..."); origen = Generate.Compare(origen, destino); System.Console.WriteLine("Generating SQL file..."); SaveFile(arguments.OutputFile, origen.ToSql()); } } catch (Exception ex) { System.Console.WriteLine(ex.Message); } }
public ProgressForm(string DatabaseName1, string DatabaseName2, Generate genData1, Generate genData2) { InitializeComponent(); databaseProgressControl1.Maximum = Generate.MaxValue; databaseProgressControl2.Maximum = Generate.MaxValue; databaseProgressControl1.DatabaseName = DatabaseName1; databaseProgressControl2.DatabaseName = DatabaseName2; this.genData1 = genData1; this.genData2 = genData2; }
private void ProcessMsSQL() { try { Database origin; Database destination; if ((!String.IsNullOrEmpty(mySqlConnectFront1.DatabaseName) && (!String.IsNullOrEmpty(mySqlConnectFront2.DatabaseName)))) { Generate sql1 = new Generate(); Generate sql2 = new Generate(); sql1.ConnectionString = mySqlConnectFront1.ConnectionString; sql1.Options = SqlFilter; sql2.ConnectionString = mySqlConnectFront2.ConnectionString; sql2.Options = SqlFilter; ProgressForm progres = new ProgressForm("Reference Database", "Target Database", sql2, sql1); progres.ShowDialog(this); origin = progres.Source; destination = progres.Destination; txtDifferences.ConfigurationManager.Language = "mssql"; txtDifferences.IsReadOnly = false; txtDifferences.Styles.LineNumber.BackColor = Color.White; txtDifferences.Styles.LineNumber.IsVisible = false; txtDifferences.Text = destination.ToSqlDiff().ToSQL(); txtDifferences.IsReadOnly = true; schemaView.DatabaseSource = destination; schemaView.DatabaseDestination = origin; schemaView.OnSelectItem += new SchemaTreeView.SchemaHandler(schemaView_OnSelectItem); btnCopy.Enabled = true; btnSaveAs.Enabled = true; } else MessageBox.Show(Owner, "Please select a valid connection string", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (SchemaException) { throw; } catch (Exception ex) { throw new SchemaException("Invalid database connection. Please check the database connection\r\n" + ex.Message); } }
public GenerateExtendedProperties(Generate root) { this.root = root; }
public GenerateDefaults(Generate root) { this.root = root; }
public GenerateIndex(Generate root) { this.root = root; }
public GeneratePartitionFunctions(Generate root) { this.root = root; }
public GenerateSynonyms(Generate root) { this.root = root; }
public GenerateFileGroups(Generate root) { this.root = root; }
public GeneratePartitionFunctions(Generate root) { this.root = root; }
public GenerateFunctions(Generate root) { this.root = root; }
public GenerateIndex(Generate root) { this.root = root; }
public GenerateUserDataTypes(Generate root) { this.root = root; }
public GenerateTextObjects(Generate root) { this.root = root; }
public GenerateConstraint(Generate root) { this.root = root; }
public GenerateUsers(Generate root) { this.root = root; }
public GenerateFullText(Generate root) { this.root = root; }
public GenerateFunctions(Generate root) { this.root = root; }
public GenerateViews(Generate root) { this.root = root; }
public GenerateRules(Generate root) { this.root = root; }
public GenerateAssemblies(Generate root) { this.root = root; }
public GenerateFullText(Generate root) { this.root = root; }
public GenerateTables(Generate root) { this.root = root; }
public GenerateUserDataTypes(Generate root) { this.root = root; }
public GenerateStoreProcedures(Generate root) { this.root = root; }
public GenerateDefaults(Generate root) { this.root = root; }
public GenerateTriggers(Generate root) { this.root = root; }
public GenerateFileGroups(Generate root) { this.root = root; }
public GenerateConstraint(Generate root) { this.root = root; }
public GenerateXMLSchemas(Generate root) { this.root = root; }
public GenerateUsers(Generate root) { this.root = root; }
public Model BuildComparisonObjects(IConnection sourceConnection, IConnection targetConnection) { SqlOption options = BuildOptions(); OnComparisonStarted(EventArgs.Empty); var source = new Generate {ConnectionString = sourceConnection.ConnectionString, Options = options}; source.OnProgress += args => OnFeedbackMessage(new FeedbackEventArgs { Message = args.Message, ProgressPercent = args.Progress*(40/Generate.MaxValue) }); _source = source.Process(); var target = new Generate {ConnectionString = targetConnection.ConnectionString, Options = options}; target.OnProgress += args => OnFeedbackMessage(new FeedbackEventArgs { Message = args.Message, ProgressPercent = 40 + (args.Progress*(40/Generate.MaxValue)) }); _target = target.Process(); OnFeedbackMessage(new FeedbackEventArgs {Message = "Running comparison...", ProgressPercent = 90}); _merged = Generate.Compare((Database) _target.Clone(null), _source); OnFeedbackMessage(new FeedbackEventArgs {Message = "Building Model...", ProgressPercent = 95}); var model = new Model(); _merged.Tables.ForEach( item => model.Add("Table", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Views.ForEach( item => model.Add("View", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Users.ForEach( item => model.Add("User", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.UserTypes.ForEach( item => model.Add("User Type", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.XmlSchemas.ForEach( item => model.Add("XML Schema", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Assemblies.ForEach( item => model.Add("CLR Assemblie", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.CLRFunctions.ForEach( item => model.Add("CLR Function", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.CLRProcedures.ForEach( item => model.Add("CLR Procedure", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.DDLTriggers.ForEach( item => model.Add("DDL Trigger", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Defaults.ForEach( item => model.Add("Default", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.ExtendedProperties.ForEach( item => model.Add("Extended Property", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.FileGroups.ForEach( item => model.Add("File Groups", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Functions.ForEach( item => model.Add("Functions", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.PartitionFunctions.ForEach( item => model.Add("Partition Function", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.PartitionSchemes.ForEach( item => model.Add("Partition Scheme", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Procedures.ForEach( item => model.Add("Stored Procedure", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Roles.ForEach( item => model.Add("Role", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Schemas.ForEach( item => model.Add("Schema", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); _merged.Synonyms.ForEach( item => model.Add("Synonym", item.FullName, new Guid(item.Guid), item.Id, ResolveAction(item.Status))); OnFeedbackMessage(new FeedbackEventArgs {Message = "Comparison Complete", ProgressPercent = 100}); OnComparisonCompleted(EventArgs.Empty); return model; }
public GenerateTextObjects(Generate root) { this.root = root; }
public GenerateSchemas(Generate root) { this.root = root; }
public GenerateExtendedProperties(Generate root) { this.root = root; }
public GenerateTriggers(Generate root) { this.root = root; }
public GenerateSynonyms(Generate root) { this.root = root; }
/*private void ProcesarSybase() { DBDiff.Schema.Sybase.Model.Database origen; DBDiff.Schema.Sybase.Model.Database destino; DBDiff.Schema.Sybase.Generate sql = new DBDiff.Schema.Sybase.Generate(); sql.ConnectioString = txtConnectionOrigen.Text; AseFilter.OptionFilter.FilterTrigger = false; origen = sql.Process(AseFilter); sql.ConnectioString = txtConnectionDestino.Text; destino = sql.Process(AseFilter); this.txtScript.SQLType = SQLEnum.SQLTypeEnum.Sybase; this.txtDiferencias.SQLType = SQLEnum.SQLTypeEnum.Sybase; //origen = DBDiff.Schema.Sybase.Generate.Compare(origen, destino); this.txtScript.Text = origen.ToSQL(); //this.txtDiferencias.Text = origen.ToSQLDiff(); }*/ /*private void ProcesarMySQL() { DBDiff.Schema.MySQL.Model.Database origen; DBDiff.Schema.MySQL.Model.Database destino; DBDiff.Schema.MySQL.Generate sql = new DBDiff.Schema.MySQL.Generate(); sql.ConnectioString = mySqlConnectFront1.ConnectionString; origen = sql.Process(MySQLfilter); sql.ConnectioString = mySqlConnectFront2.ConnectionString; destino = sql.Process(MySQLfilter); //this.txtScript.SQLType = SQLEnum.SQLTypeEnum.MySQL; //this.txtDiferencias.SQLType = SQLEnum.SQLTypeEnum.MySQL; origen = DBDiff.Schema.MySQL.Generate.Compare(origen, destino); this.txtDiferencias.Text = origen.ToSQLDiff(); } */ private void ProcesarSQL2005() { ProgressForm progres = null; string errorLocation = null; try { Database origen; Database destino; if ((!String.IsNullOrEmpty(mySqlConnectFront1.DatabaseName) && (!String.IsNullOrEmpty(mySqlConnectFront2.DatabaseName)))) { Generate sql1 = new Generate(); Generate sql2 = new Generate(); sql1.ConnectionString = mySqlConnectFront1.ConnectionString; sql1.Options = SqlFilter; sql2.ConnectionString = mySqlConnectFront2.ConnectionString; sql2.Options = SqlFilter; progres = new ProgressForm("Source Database", "Destination Database", sql2, sql1); progres.ShowDialog(this); if (progres.Error != null) { throw new SchemaException(progres.Error.Message, progres.Error); } origen = progres.Source; destino = progres.Destination; txtSyncScript.ConfigurationManager.Language = "mssql"; txtSyncScript.IsReadOnly = false; txtSyncScript.Styles.LineNumber.BackColor = Color.White; txtSyncScript.Styles.LineNumber.IsVisible = false; errorLocation = "Generating Synchronized Script"; txtSyncScript.Text = destino.ToSqlDiff(_selectedSchemas).ToSQL(); txtSyncScript.IsReadOnly = true; schemaTreeView1.DatabaseSource = destino; schemaTreeView1.DatabaseDestination = origen; schemaTreeView1.OnSelectItem += new SchemaTreeView.SchemaHandler(schemaTreeView1_OnSelectItem); textBox1.Text = origen.ActionMessage.Message; btnCopy.Enabled = true; btnSaveAs.Enabled = true; btnUpdateAll.Enabled = true; } else MessageBox.Show(Owner, "Please select a valid connection string", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { if (errorLocation == null && progres != null) { errorLocation = String.Format("{0} (while {1})", progres.ErrorLocation, progres.ErrorMostRecentProgress ?? "initializing"); } throw new SchemaException("Error " + (errorLocation ?? " Comparing Databases"), ex); } }
public GenerateStoreProcedures(Generate root) { this.root = root; }
public GenerateAssemblies(Generate root) { this.root = root; }
public GeneratePartitionScheme(Generate root) { this.root = root; }
public GenerateViews(Generate root) { this.root = root; }
public GenerateRules(Generate root) { this.root = root; }