public async Task Init() { PleaseClickCompare = false; Comparer = null; a7DbStructureComparer structComparer = null; using (var busyVm = new BusyViewModel(AppViewModel.Instance, "Comparing database structures...")) { await Task.Factory.StartNew(() => { structComparer = new a7DbStructureComparer(_connData.Name, DbA, DbB, AddLog); }); } if (structComparer != null) { Comparer = structComparer; PleaseClickCompare = false; //a7DbStructCompResultWnd wnd = new a7DbStructCompResultWnd(structComparer); //wnd.ShowDialog(); } else { MessageBox.Show("Something is wrong..."); PleaseClickCompare = true; } }
public a7DbTableFieldDifferences(string tableNameA, a7DbStructureComparer comparer) { TableFieldsOnlyInA = new ObservableCollection <a7DbTableFieldCopyTo>(); TableFieldsOnlyInA.CollectionChanged += (sender, args) => { OnPropertyChanged(nameof(FieldsOnlyInAExist)); OnPropertyChanged(nameof(FieldsExistenceInSync)); OnPropertyChanged(nameof(FieldsInSync)); }; TableFieldsOnlyInB = new ObservableCollection <a7DbTableFieldCopyTo>(); TableFieldsOnlyInB.CollectionChanged += (sender, args) => { OnPropertyChanged(nameof(FieldsOnlyInBExist)); OnPropertyChanged(nameof(FieldsExistenceInSync)); OnPropertyChanged(nameof(FieldsInSync)); }; TableFieldsDifferentType = new ObservableCollection <a7DbTableFieldDifferent>(); TableFieldsDifferentType.CollectionChanged += (sender, args) => { OnPropertyChanged(nameof(FieldTypeDifferencesExist)); OnPropertyChanged(nameof(FieldsInSync)); }; Header = string.Format("Table '{0}':", tableNameA); TableName = tableNameA; Comparer = comparer; }
public a7DbTableOnlyIn(string tableName, a7DbComparedDataBases onlyIn, a7DbStructureComparer comparer) { TableName = tableName; AddToOtherDbName = comparer.GetOtherDb(onlyIn).Name; AddToOtherCommand = new a7LambdaCommand((o) => { comparer.IsBusy = true; Task.Factory.StartNew(() => { comparer.CopyTable(TableName, onlyIn); Application.Current.Dispatcher.Invoke(() => { if (onlyIn == a7DbComparedDataBases.A) { comparer.TablesOnlyInA.Remove(this); } else { comparer.TablesOnlyInB.Remove(this); } comparer.IsBusy = false; }); }).ContinueWith((t) => { if (t.Exception != null) { throw t.Exception; } }); } ); RemoveFromThisDbName = comparer.GetDb(onlyIn).Name; RemoveFromThisCommand = new a7LambdaCommand((o) => { comparer.IsBusy = true; Task.Factory.StartNew(() => { var tbl = comparer.GetTable(TableName, onlyIn); tbl.Drop(); Application.Current.Dispatcher.Invoke(() => { if (onlyIn == a7DbComparedDataBases.A) { comparer.TablesOnlyInA.Remove(this); } else { comparer.TablesOnlyInB.Remove(this); } comparer.IsBusy = false; }); }); } ); }
public a7DbTableFieldDifferent(Column colA, Column colB, Table tableA, Table tableB, Database dbA, Database dbB, a7DbStructureComparer comparer, a7DbTableFieldDifferences differences) { DbAName = comparer.DbAName; DbBName = comparer.DbBName; TypeInA = colA.DataType.ToString(); if (colA.DataType.SqlDataType == SqlDataType.VarChar || colA.DataType.SqlDataType == SqlDataType.NVarChar || colA.DataType.SqlDataType == SqlDataType.Char || colA.DataType.SqlDataType == SqlDataType.NChar) { TypeInA += "(" + colA.DataType.MaximumLength + ")"; } TypeInB = colB.DataType.ToString(); if (colB.DataType.SqlDataType == SqlDataType.VarChar || colB.DataType.SqlDataType == SqlDataType.NVarChar || colB.DataType.SqlDataType == SqlDataType.Char || colB.DataType.SqlDataType == SqlDataType.NChar) { TypeInB += "(" + colB.DataType.MaximumLength + ")"; } Text = colA.Name; CopyTypeToA = new a7LambdaCommand((o) => { comparer.IsBusy = true; Task.Factory.StartNew(() => { if ((colA.DataType.SqlDataType == SqlDataType.VarChar && colB.DataType.SqlDataType == SqlDataType.VarChar) || (colA.DataType.SqlDataType == SqlDataType.NVarChar && colB.DataType.SqlDataType == SqlDataType.NVarChar)) { colA.DataType.MaximumLength = colB.DataType.MaximumLength; tableA.Alter(); Application.Current.Dispatcher.Invoke(() => { differences.TableFieldsDifferentType.Remove(this); }); } else { Application.Current.Dispatcher.Invoke(() => { MessageBox.Show("Not supported for non-varchar types"); }); } Application.Current.Dispatcher.Invoke(() => { comparer.IsBusy = false; }); }).ContinueWith((t) => { if (t.Exception != null) { throw t.Exception; } }); } ); CopyTypeToB = new a7LambdaCommand((o) => { comparer.IsBusy = true; if ((colA.DataType.SqlDataType == SqlDataType.VarChar && colB.DataType.SqlDataType == SqlDataType.VarChar) || (colA.DataType.SqlDataType == SqlDataType.NVarChar && colB.DataType.SqlDataType == SqlDataType.NVarChar)) { colB.DataType.MaximumLength = colA.DataType.MaximumLength; tableB.Alter(); Application.Current.Dispatcher.Invoke(() => { differences.TableFieldsDifferentType.Remove(this); }); } else { Application.Current.Dispatcher.Invoke(() => { MessageBox.Show("Not supported for non-varchar types"); }); } Application.Current.Dispatcher.Invoke(() => { comparer.IsBusy = false; }); } ); }
public a7DbTableFieldCopyTo(string dbName, Column column, int colPos, Table tableExists, Table tableNotExists, Database isInDb, Database isNotIntDb, a7DbStructureComparer comparer, a7DbTableFieldDifferences tableFieldDifferencesExists) { Text = column.Name; AddToOtherDbName = isNotIntDb.Name; AddToOtherCommand = new a7LambdaCommand((o) => { comparer.IsBusy = true; Task.Factory.StartNew(() => { a7DbTableUtils.CopyColumn(column, tableExists, tableNotExists, new Server(dbName), colPos); tableNotExists.Alter(); Application.Current.Dispatcher.Invoke(() => { tableFieldDifferencesExists.TableFieldsOnlyInA.Remove(this); tableFieldDifferencesExists.TableFieldsOnlyInB.Remove(this); comparer.IsBusy = false; }); }).ContinueWith((t) => { if (t.Exception != null) { throw t.Exception; } }); } ); RemoveFromThisDbName = isInDb.Name; RemoveFromThisCommand = new a7LambdaCommand((o) => { comparer.IsBusy = true; Task.Factory.StartNew(() => { column.Drop(); Application.Current.Dispatcher.Invoke(() => { tableFieldDifferencesExists.TableFieldsOnlyInA.Remove(this); tableFieldDifferencesExists.TableFieldsOnlyInB.Remove(this); comparer.IsBusy = false; }); }); } ); }