예제 #1
0
 public DifferenceSerializer(TableDifferenceCollection tableDiffCollection, DifferenceCollection viewDiffCollection, DifferenceCollection storedProcDiffCollection, DifferenceCollection functionDiffCollection)
 {
     _tableDiffCollection = tableDiffCollection;
     _viewDiffCollection = viewDiffCollection;
     _storedProcDiffCollection = storedProcDiffCollection;
     _functionDiffCollection = functionDiffCollection;
 }
예제 #2
0
 public DifferenceSerializer(TableDifferenceCollection tableDiffCollection, DifferenceCollection viewDiffCollection, DifferenceCollection storedProcDiffCollection, DifferenceCollection functionDiffCollection)
 {
     _tableDiffCollection      = tableDiffCollection;
     _viewDiffCollection       = viewDiffCollection;
     _storedProcDiffCollection = storedProcDiffCollection;
     _functionDiffCollection   = functionDiffCollection;
 }
예제 #3
0
 public DatabaseDifferences(TableDifferenceCollection tableDiffCollection,
                            DifferenceCollection constraintDiffCollection,
                            DifferenceCollection viewDiffCollection,
                            DifferenceCollection storedProcDiffCollection,
                            DifferenceCollection functionDiffCollection,
                            DifferenceCollection triggerDiffCollection)
 {
     _constraintDiffCollection = constraintDiffCollection;
     _functionDiffCollection   = functionDiffCollection;
     _storedProcDiffCollection = storedProcDiffCollection;
     _tableDiffCollection      = tableDiffCollection;
     _triggerDiffCollection    = triggerDiffCollection;
     _viewDiffCollection       = viewDiffCollection;
 }
예제 #4
0
 public DatabaseDifferences(TableDifferenceCollection tableDiffCollection, 
     DifferenceCollection constraintDiffCollection,
     DifferenceCollection viewDiffCollection,
     DifferenceCollection storedProcDiffCollection,
     DifferenceCollection functionDiffCollection,
     DifferenceCollection triggerDiffCollection)
 {
     _constraintDiffCollection = constraintDiffCollection;
     _functionDiffCollection = functionDiffCollection;
     _storedProcDiffCollection = storedProcDiffCollection;
     _tableDiffCollection = tableDiffCollection;
     _triggerDiffCollection = triggerDiffCollection;
     _viewDiffCollection = viewDiffCollection;
 }
예제 #5
0
파일: Compare.cs 프로젝트: MickaelE/DaBCoS9
        /// <summary>
        /// Compare tables
        /// </summary>
        public TableDifferenceCollection CompareTables(SqlServer databaseLeft, SqlServer databaseRight)
        {
            ArrayList leftTableList, rightTableList;
            ArrayList leftColumnList, rightColumnList;
            TableDifferenceCollection tableDifferences = new TableDifferenceCollection();

            // Read first database tables
            //ShowInfoMessage(String.Format("Reading available tables on {0}..{1}...", databaseLeft.Connection.DataSource, databaseLeft.Connection.Database));
            leftTableList = databaseLeft.GetTables();

            // Read second database tables
            //ShowInfoMessage(String.Format("Reading available tables on {0}..{1}...", databaseRight.Connection.DataSource, databaseRight.Connection.Database));
            rightTableList = databaseRight.GetTables();

            // Fire event
            int numberObjects = leftTableList.Count;
            FireCompareSchemaStarted(Difference.DatabaseObjectType.Table, numberObjects);

            // Compare databases
            //ShowInfoMessage(String.Format("Found a total of {0} tables ({1} + {2})", leftTableList.Count + rightTableList.Count, leftTableList.Count, rightTableList.Count));
            //ShowInfoMessage("Comparing tables and columns...");

            // Compare first database against the second
            for(int i=0; i<leftTableList.Count; i++)
            {
                // Find existing and missing tables
                if (FindListItem(leftTableList[i].ToString(), rightTableList)==-1)
                {
                    // Right table missing
                    tableDifferences.Add(new TableDifference(false, leftTableList[i].ToString(), Difference.DatabaseObjectType.Table, Difference.DifferenceOutcome.Missing));
                }
                else
                {
                    bool fieldDifferenceFound = false;

                    // Add a default table difference item
                    int addedIndex = tableDifferences.Add(new TableDifference(false, leftTableList[i].ToString(), Difference.DatabaseObjectType.Table, Difference.DifferenceOutcome.Unknown));

                    // Load columns
                    leftColumnList = databaseLeft.GetColumns(leftTableList[i].ToString());
                    rightColumnList = databaseRight.GetColumns(rightTableList[rightTableList.IndexOf(leftTableList[i])].ToString());

                    // Check for different columns from left-table
                    for (int j=0; j<leftColumnList.Count; j++)
                    {
                        // Check if the left-table column is in the right-table
                        if (FindListItem(leftColumnList[j].ToString(), rightColumnList)==-1)
                        {
                            // Right field missing
                            tableDifferences[addedIndex].FieldDifferences.Add(new Difference(false, leftColumnList[j].ToString(), Difference.DatabaseObjectType.Field, Difference.DifferenceOutcome.Missing));
                            fieldDifferenceFound=true;
                        }
                    }

                    // Check for different columns from right-table
                    for (int j=0; j<rightColumnList.Count; j++)
                    {
                        // Check if the left-table column is in the right-table
                        if (FindListItem(rightColumnList[j].ToString(), leftColumnList)==-1)
                        {
                            // Right field missing
                            tableDifferences[addedIndex].FieldDifferences.Add(new Difference(false, rightColumnList[j].ToString(), Difference.DatabaseObjectType.Field, Difference.DifferenceOutcome.Missing));
                            fieldDifferenceFound=true;
                        }
                    }

                    // Check if we found any column differences
                    if (!fieldDifferenceFound)
                    {
                        tableDifferences[addedIndex].Outcome = Difference.DifferenceOutcome.Same;
                    }
                    else
                    {
                        tableDifferences[addedIndex].Outcome = Difference.DifferenceOutcome.Different;
                    }
                }
            }

            // Find tables in second database not yet scanned
            for(int i=0; i<rightTableList.Count; i++)
            {
                if ((FindListItem(rightTableList[i].ToString(), leftTableList))==-1)
                {
                    // Left table missing
                    tableDifferences.Add(new TableDifference(true, rightTableList[i].ToString(), Difference.DatabaseObjectType.Table, Difference.DifferenceOutcome.Missing));
                }
            }

            // Sort by table name
            tableDifferences = tableDifferences.Sort("Name", SortDirection.Ascending);

            FireCompareSchemaFinished(Difference.DatabaseObjectType.Table);

            return tableDifferences;
        }
예제 #6
0
 //UPDATE
 internal TableDifferenceCollectionEnumerator(TableDifferenceCollection collection)
 {
     _index = -1;
     _collection = collection;
 }
예제 #7
0
파일: Compare.cs 프로젝트: MickaelE/DaBCoS9
        /// <summary>
        /// Compare tables
        /// </summary>
        public TableDifferenceCollection CompareTables(SqlServer databaseLeft, SqlServer databaseRight)
        {
            ArrayList leftTableList, rightTableList;
            ArrayList leftColumnList, rightColumnList;
            TableDifferenceCollection tableDifferences = new TableDifferenceCollection();

            // Read first database tables
            //ShowInfoMessage(String.Format("Reading available tables on {0}..{1}...", databaseLeft.Connection.DataSource, databaseLeft.Connection.Database));
            leftTableList = databaseLeft.GetTables();

            // Read second database tables
            //ShowInfoMessage(String.Format("Reading available tables on {0}..{1}...", databaseRight.Connection.DataSource, databaseRight.Connection.Database));
            rightTableList = databaseRight.GetTables();

            // Fire event
            int numberObjects = leftTableList.Count;

            FireCompareSchemaStarted(Difference.DatabaseObjectType.Table, numberObjects);

            // Compare databases
            //ShowInfoMessage(String.Format("Found a total of {0} tables ({1} + {2})", leftTableList.Count + rightTableList.Count, leftTableList.Count, rightTableList.Count));
            //ShowInfoMessage("Comparing tables and columns...");

            // Compare first database against the second
            for (int i = 0; i < leftTableList.Count; i++)
            {
                // Find existing and missing tables
                if (FindListItem(leftTableList[i].ToString(), rightTableList) == -1)
                {
                    // Right table missing
                    tableDifferences.Add(new TableDifference(false, leftTableList[i].ToString(), Difference.DatabaseObjectType.Table, Difference.DifferenceOutcome.Missing));
                }
                else
                {
                    bool fieldDifferenceFound = false;

                    // Add a default table difference item
                    int addedIndex = tableDifferences.Add(new TableDifference(false, leftTableList[i].ToString(), Difference.DatabaseObjectType.Table, Difference.DifferenceOutcome.Unknown));

                    // Load columns
                    leftColumnList  = databaseLeft.GetColumns(leftTableList[i].ToString());
                    rightColumnList = databaseRight.GetColumns(rightTableList[rightTableList.IndexOf(leftTableList[i])].ToString());

                    // Check for different columns from left-table
                    for (int j = 0; j < leftColumnList.Count; j++)
                    {
                        // Check if the left-table column is in the right-table
                        if (FindListItem(leftColumnList[j].ToString(), rightColumnList) == -1)
                        {
                            // Right field missing
                            tableDifferences[addedIndex].FieldDifferences.Add(new Difference(false, leftColumnList[j].ToString(), Difference.DatabaseObjectType.Field, Difference.DifferenceOutcome.Missing));
                            fieldDifferenceFound = true;
                        }
                    }

                    // Check for different columns from right-table
                    for (int j = 0; j < rightColumnList.Count; j++)
                    {
                        // Check if the left-table column is in the right-table
                        if (FindListItem(rightColumnList[j].ToString(), leftColumnList) == -1)
                        {
                            // Right field missing
                            tableDifferences[addedIndex].FieldDifferences.Add(new Difference(false, rightColumnList[j].ToString(), Difference.DatabaseObjectType.Field, Difference.DifferenceOutcome.Missing));
                            fieldDifferenceFound = true;
                        }
                    }

                    // Check if we found any column differences
                    if (!fieldDifferenceFound)
                    {
                        tableDifferences[addedIndex].Outcome = Difference.DifferenceOutcome.Same;
                    }
                    else
                    {
                        tableDifferences[addedIndex].Outcome = Difference.DifferenceOutcome.Different;
                    }
                }
            }

            // Find tables in second database not yet scanned
            for (int i = 0; i < rightTableList.Count; i++)
            {
                if ((FindListItem(rightTableList[i].ToString(), leftTableList)) == -1)
                {
                    // Left table missing
                    tableDifferences.Add(new TableDifference(true, rightTableList[i].ToString(), Difference.DatabaseObjectType.Table, Difference.DifferenceOutcome.Missing));
                }
            }

            // Sort by table name
            tableDifferences = tableDifferences.Sort("Name", SortDirection.Ascending);

            FireCompareSchemaFinished(Difference.DatabaseObjectType.Table);

            return(tableDifferences);
        }
예제 #8
0
 //UPDATE
 internal TableDifferenceCollectionEnumerator(TableDifferenceCollection collection)
 {
     _index      = -1;
     _collection = collection;
 }