Example #1
0
        public void Compare()
        {
            _differenceSchema   = DatabaseComparer.CompareDatabase(SourceDatabase, DestinationDatabase);
            _differenceDatabase = DatabaseComparer.CompareDatabase(DestinationDatabase, SourceDatabase);

            FillSchema(treeSchema, SourceDatabase);
            FillSchema(treeSchema_diff2, _differenceSchema);
            FillSchema(treeSchema_diff1, _differenceDatabase);
        }
Example #2
0
 public void StartComparing()
 {
     LblStatus.Text      = "Comparing ...";
     LblStatus.ForeColor = Color.Black;
     BtnScripts.Enabled  = BtnProject.Enabled = BtnRerun.Enabled = false;
     BtnCancel.Enabled   = true;
     compareAnimation1.Start();
     backgroundWorker1.ClearActions();
     Comparer = new DatabaseComparer(Project);
     backgroundWorker1.AddAction(Comparer, null);
     backgroundWorker1.RunWorkerAsync();
 }
Example #3
0
        private static void Compare()
        {
            string file = Path.Combine(Application.StartupPath, "Schema.bdb");

            var parameters = new ComparerParameters();

            parameters.SchemaPath       = file;
            parameters.TargetParameters = new DatabaseParameter()
            {
                ConnectionString = GetConnectionString("")
            };

            var comparer = new DatabaseComparer();

            if (comparer.IsDifferent(parameters))
            {
                comparer.SaveScript();
            }
        }
Example #4
0
 public void ComparerTest()
 {
     try
     {
         DatabaseComparer comp = new DatabaseComparer();
         comp.FirstDatabase = new SqlDataBaseConnector();
         var con1 = comp.FirstDatabase.ConnectToFile(@"D:\GitHub\R1.mdf");
         comp.SecondDatabase = new SqlDataBaseConnector();
         var con2 = comp.SecondDatabase.ConnectToFile(@"D:\GitHub\R2.mdf");
         if (con1 && con2)
         {
             comp.FirstDatabase.GetTableInfo("NewEmployees2");
             comp.FirstDatabase.SelectedTable  = "NewEmployees2";
             comp.SecondDatabase.SelectedTable = "NewEmployees2";
             foreach (var col in comp.FirstDatabase.TableColumns)
             {
                 comp.FirstDatabase.SelectedColumns.Add(col);
             }
             comp.SecondDatabase.GetTableInfo("NewEmployees2");
             foreach (var col in comp.SecondDatabase.TableColumns)
             {
                 comp.SecondDatabase.SelectedColumns.Add(col);
             }
             Stopwatch timer = new Stopwatch();
             timer.Start();
             comp.ReadDataFromDb();
             timer.Stop();
             comp.CompareFullData();
             var table1_row_count = comp.FirstData.Count;
             var table2_row_count = comp.SecondData.Count;
             var stop             = timer.Elapsed;
             System.Console.WriteLine($"Кількість записів у першій таблиці - {table1_row_count}");
             System.Console.WriteLine($"Кількість записів у другій таблиці - {table2_row_count}");
             System.Console.WriteLine($"Час виконання - {stop}");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         Assert.Fail();
     }
 }
        /// <summary>
        /// Очищення даних після того як користувач покидає сторінку
        /// </summary>
        /// <param name="i"></param>
        public void CleanNotUsedData(int i)
        {
            switch (i)
            {
            case 1:
            {
                db = new DatabaseComparer();
                PageClosedAction("");
                break;
            }

            case 2:
            {
                db.FirstDatabase.SelectedTable  = null;
                db.SecondDatabase.SelectedTable = null;
                break;
            }

            case 3:
            {
                db.FirstDatabase.TableColumns.Clear();
                db.SecondDatabase.TableColumns.Clear();
                db.FirstDatabase.SelectedColumns.Clear();
                db.SecondDatabase.SelectedColumns.Clear();
                break;
            }

            case 4:
            {
                db.ComparingResult = null;
                db.FirstData       = null;
                db.SecondData      = null;
                db.AdditionalInfo  = null;
                break;
            }
            }
        }
Example #6
0
        /// <summary>
        /// This method does the actual comparison; it is called by the RemoteCompare and the normal comparison
        /// </summary>
        private void CompareDatabaseStructure(Database sourceDatabase, Database targetDatabase)
        {
            // local
            SchemaComparison schemaComparison = new SchemaComparison();

            // verify both objects exist
            if (NullHelper.Exists(sourceDatabase, targetDatabase))
            {
                // test if any data was loaded before showing 'The target database is up to date message incorrectly'
                if (sourceDatabase.Tables.Count > 0)
                {
                    // Get the value for IgnoreDiagramProcedures
                    bool ignoreDiagramProcedures = this.IgnoreDiagramProceduresCheckBox.Checked;

                    // Create a new database comparer
                    DatabaseComparer comparer = new DatabaseComparer(sourceDatabase, targetDatabase, ignoreDiagramProcedures);

                    // Compare the two database schemas
                    schemaComparison = comparer.Compare();
                }
                else
                {
                    // Add this as a message
                    schemaComparison.SchemaDifferences.Add("The source database does not contain any tables; the comparison cannot continue.");
                }

                // compare the two schemas
                if (schemaComparison != null)
                {
                    // if the two database are equal
                    if (schemaComparison.IsEqual)
                    {
                        // Show the two databases are equal
                        this.ResultsTextBox.Text = "The target database is up to date.";
                    }
                    else
                    {
                        // Display the count
                        this.CountLabel.Text = "Count: " + schemaComparison.SchemaDifferences.Count;

                        // Create a string builder
                        StringBuilder sb = new StringBuilder("The target database is not valid.");

                        // Append a new line
                        sb.Append(Environment.NewLine);

                        // iterate the errors
                        foreach (string schemaDifference in schemaComparison.SchemaDifferences)
                        {
                            // Append an indention
                            sb.Append("    ");
                            sb.Append(schemaDifference);
                            sb.Append(Environment.NewLine);
                        }

                        // Show the schema differences
                        this.ResultsTextBox.Text = sb.ToString();

                        // This is a stub for an update for Version 3.0 that isn't ready to be released
                        //// create a message for how to
                        //message = "Would you like to attempt to fix any errors if possible?";

                        //// Get the users response
                        //DialogResult result = MessageBoxHelper.GetUserResponse(message, "Fix Schema Differences?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                        //// if the user choose yes
                        //if (result == DialogResult.Yes)
                        //{
                        //    // attempt to fix any schema differences
                        //    int fixedCount = SqlUpdater.FixSchemaDifferences(schemaComparison.SchemaDifferences, targetDatabaseConnector, sourceDatabase);
                        //}
                    }
                }
            }
            else if (NullHelper.IsNull(sourceDatabase))
            {
                // Show the user a message
                this.ResultsTextBox.Text = "The source database could not be loaded.";
            }
            else if (NullHelper.IsNull(targetDatabase))
            {
                // Show the user a message
                this.ResultsTextBox.Text = "The target database could not be loaded.";
            }
        }
Example #7
0
 private void Comparedatabase(DatabaseFactory db)
 {
     _db = DatabaseComparer.CompareDatabase(_db, db);
     FillSchema();
 }
Example #8
0
 public void SetUp()
 {
     comparer = new DatabaseComparer();
 }
 public HomeController(DatabaseComparer context, IHostingEnvironment hostingEnvironment, ICounter counter)
 {
     db = context;
     _hostingEnvironment = hostingEnvironment;
     _counterService     = counter;
 }