コード例 #1
0
 public void OutputSchemaXml(XmlWriter xmlWriter, DifferenceCollection diffCollection)
 {
     if (diffCollection != null)
     {
         // Output the schema differences
         foreach (Difference schemaDiff in diffCollection)
         {
             xmlWriter.WriteStartElement(schemaDiff.ObjectType.ToString().ToLower());
             xmlWriter.WriteStartAttribute("name", string.Empty);
             xmlWriter.WriteString(schemaDiff.Name);
             xmlWriter.WriteEndAttribute();                      //name
             xmlWriter.WriteStartAttribute("objecttype", string.Empty);
             xmlWriter.WriteString(schemaDiff.ObjectType.ToString());
             xmlWriter.WriteEndAttribute();                      //objecttype
             xmlWriter.WriteStartAttribute("outcome", string.Empty);
             xmlWriter.WriteString(schemaDiff.Outcome.ToString());
             xmlWriter.WriteEndAttribute();                      //outcome
             xmlWriter.WriteStartAttribute("isleftdifferent", string.Empty);
             xmlWriter.WriteString(schemaDiff.IsLeftDifferent.ToString());
             xmlWriter.WriteEndAttribute();                      //isleftdifferent
             xmlWriter.WriteStartAttribute("change", string.Empty);
             xmlWriter.WriteString(schemaDiff.Change.ToString());
             xmlWriter.WriteEndAttribute();                      //change
             xmlWriter.WriteEndElement();                        //table
         }
     }
 }
コード例 #2
0
 public DifferenceSerializer(TableDifferenceCollection tableDiffCollection, DifferenceCollection viewDiffCollection, DifferenceCollection storedProcDiffCollection, DifferenceCollection functionDiffCollection)
 {
     _tableDiffCollection = tableDiffCollection;
     _viewDiffCollection = viewDiffCollection;
     _storedProcDiffCollection = storedProcDiffCollection;
     _functionDiffCollection = functionDiffCollection;
 }
コード例 #3
0
 public DifferenceSerializer(TableDifferenceCollection tableDiffCollection, DifferenceCollection viewDiffCollection, DifferenceCollection storedProcDiffCollection, DifferenceCollection functionDiffCollection)
 {
     _tableDiffCollection      = tableDiffCollection;
     _viewDiffCollection       = viewDiffCollection;
     _storedProcDiffCollection = storedProcDiffCollection;
     _functionDiffCollection   = functionDiffCollection;
 }
コード例 #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
 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;
 }
コード例 #6
0
ファイル: Compare.cs プロジェクト: MickaelE/DaBCoS9
        /// <summary>
        /// Compare stored procedures
        /// </summary>
        public DifferenceCollection CompareSchemaObjects(SqlServer databaseLeft, SqlServer databaseRight, Difference.DatabaseObjectType schemaObjectType)
        {
            ArrayList leftSchemaList, rightSchemaList;
            DifferenceCollection schemaDifferences = new DifferenceCollection();
            int addedIndex;

            leftSchemaList = databaseLeft.GetObjectList(schemaObjectType);
            rightSchemaList = databaseRight.GetObjectList(schemaObjectType);

            // Fire event
            int numberObjects = leftSchemaList.Count;
            FireCompareSchemaStarted(schemaObjectType, numberObjects);

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

            // Compare first database against the second
            for(int i=0; i<leftSchemaList.Count; i++)
            {
                // Find existing and missing stored procs
                int schemaIndex = FindListItem(leftSchemaList[i].ToString(), rightSchemaList);
                if (schemaIndex==-1)
                {
                    // Right proc missing
                    addedIndex = schemaDifferences.Add(new Difference(false, leftSchemaList[i].ToString(), schemaObjectType, Difference.DifferenceOutcome.Missing));

                    // Load the schema for the stored procs
                    string leftSchema = databaseLeft.GetObjectDefinition(leftSchemaList[i].ToString());
                    string rightSchema = "";

                    // Check for schema differences (we know there will be lots!)
                    DifferenceEngine.TextMemory leftText = new DifferenceEngine.TextMemory(leftSchema);
                    schemaDifferences[addedIndex].LeftText = leftText;
                    DifferenceEngine.TextMemory rightText = new DifferenceEngine.TextMemory(rightSchema);
                    schemaDifferences[addedIndex].RightText = rightText;

                    DifferenceEngine.DiffEngine diffEngine = new DifferenceEngine.DiffEngine();
                    double timeTaken = diffEngine.ProcessDiff(leftText, rightText, DifferenceEngine.DiffEngineLevel.SlowPerfect);
                    DifferenceEngine.DiffResultSpanCollection textDifferenceList = diffEngine.DiffReport();

                    schemaDifferences[addedIndex].DifferenceResults = textDifferenceList;
                }
                else
                {
                    bool schemaDifferenceFound = false;

                    // Add a default difference item
                    addedIndex = schemaDifferences.Add(new Difference(false, leftSchemaList[i].ToString(), schemaObjectType, Difference.DifferenceOutcome.Unknown));

                    // Load the schema text
                    string leftSchema = databaseLeft.GetObjectDefinition(leftSchemaList[i].ToString());
                    string rightSchema = databaseRight.GetObjectDefinition(rightSchemaList[schemaIndex].ToString());

                    // Check for schema differences
                    DifferenceEngine.TextMemory leftText = new DifferenceEngine.TextMemory(leftSchema);
                    schemaDifferences[addedIndex].LeftText = leftText;
                    DifferenceEngine.TextMemory rightText = new DifferenceEngine.TextMemory(rightSchema);
                    schemaDifferences[addedIndex].RightText = rightText;

                    DifferenceEngine.DiffEngine diffEngine = new DifferenceEngine.DiffEngine();
                    double timeTaken = diffEngine.ProcessDiff(leftText, rightText, DifferenceEngine.DiffEngineLevel.SlowPerfect);
                    DifferenceEngine.DiffResultSpanCollection textDifferenceList = diffEngine.DiffReport();

                    // Check if we found any text differences
                    foreach(DifferenceEngine.DiffResultSpan diffResultSpan in textDifferenceList)
                    {
                        if (diffResultSpan.Status!=DifferenceEngine.DiffResultSpanStatus.NoChange)
                        {
                            schemaDifferenceFound = true;
                        }
                    }
                    schemaDifferences[addedIndex].DifferenceResults = textDifferenceList;
                    if (schemaDifferenceFound)
                    {
                        schemaDifferences[addedIndex].Outcome = Difference.DifferenceOutcome.Different;
                    }
                    else
                    {
                        schemaDifferences[addedIndex].Outcome = Difference.DifferenceOutcome.Same;
                    }
                }
            }

            // Find objects in second database not yet scanned
            for(int i=0; i<rightSchemaList.Count; i++)
            {
                if ((FindListItem(rightSchemaList[i].ToString(), leftSchemaList))==-1)
                {
                    // Left object missing
                    addedIndex = schemaDifferences.Add(new Difference(true, rightSchemaList[i].ToString(), schemaObjectType, Difference.DifferenceOutcome.Missing));

                    // Load the schema for the stored procs
                    string leftSchema = "";
                    string rightSchema = databaseRight.GetObjectDefinition(rightSchemaList[i].ToString());

                    // Check for schema differences (we know there will be lots!)
                    DifferenceEngine.TextMemory leftText = new DifferenceEngine.TextMemory(leftSchema);
                    schemaDifferences[addedIndex].LeftText = leftText;
                    DifferenceEngine.TextMemory rightText = new DifferenceEngine.TextMemory(rightSchema);
                    schemaDifferences[addedIndex].RightText = rightText;

                    DifferenceEngine.DiffEngine diffEngine = new DifferenceEngine.DiffEngine();
                    double timeTaken = diffEngine.ProcessDiff(leftText, rightText, DifferenceEngine.DiffEngineLevel.SlowPerfect);
                    DifferenceEngine.DiffResultSpanCollection textDifferenceList = diffEngine.DiffReport();

                    schemaDifferences[addedIndex].DifferenceResults = textDifferenceList;

                }
            }

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

            FireCompareSchemaFinished(schemaObjectType);

            return schemaDifferences;
        }
コード例 #7
0
 //UPDATE
 internal DifferenceCollectionEnumerator(DifferenceCollection collection)
 {
     _index = -1;
     _collection = collection;
 }
コード例 #8
0
ファイル: Compare.cs プロジェクト: MickaelE/DaBCoS9
        /// <summary>
        /// Compare stored procedures
        /// </summary>
        public DifferenceCollection CompareSchemaObjects(SqlServer databaseLeft, SqlServer databaseRight, Difference.DatabaseObjectType schemaObjectType)
        {
            ArrayList            leftSchemaList, rightSchemaList;
            DifferenceCollection schemaDifferences = new DifferenceCollection();
            int addedIndex;

            leftSchemaList  = databaseLeft.GetObjectList(schemaObjectType);
            rightSchemaList = databaseRight.GetObjectList(schemaObjectType);

            // Fire event
            int numberObjects = leftSchemaList.Count;

            FireCompareSchemaStarted(schemaObjectType, numberObjects);

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

            // Compare first database against the second
            for (int i = 0; i < leftSchemaList.Count; i++)
            {
                // Find existing and missing stored procs
                int schemaIndex = FindListItem(leftSchemaList[i].ToString(), rightSchemaList);
                if (schemaIndex == -1)
                {
                    // Right proc missing
                    addedIndex = schemaDifferences.Add(new Difference(false, leftSchemaList[i].ToString(), schemaObjectType, Difference.DifferenceOutcome.Missing));

                    // Load the schema for the stored procs
                    string leftSchema  = databaseLeft.GetObjectDefinition(leftSchemaList[i].ToString());
                    string rightSchema = "";

                    // Check for schema differences (we know there will be lots!)
                    DifferenceEngine.TextMemory leftText = new DifferenceEngine.TextMemory(leftSchema);
                    schemaDifferences[addedIndex].LeftText = leftText;
                    DifferenceEngine.TextMemory rightText = new DifferenceEngine.TextMemory(rightSchema);
                    schemaDifferences[addedIndex].RightText = rightText;

                    DifferenceEngine.DiffEngine diffEngine = new DifferenceEngine.DiffEngine();
                    double timeTaken = diffEngine.ProcessDiff(leftText, rightText, DifferenceEngine.DiffEngineLevel.SlowPerfect);
                    DifferenceEngine.DiffResultSpanCollection textDifferenceList = diffEngine.DiffReport();

                    schemaDifferences[addedIndex].DifferenceResults = textDifferenceList;
                }
                else
                {
                    bool schemaDifferenceFound = false;

                    // Add a default difference item
                    addedIndex = schemaDifferences.Add(new Difference(false, leftSchemaList[i].ToString(), schemaObjectType, Difference.DifferenceOutcome.Unknown));

                    // Load the schema text
                    string leftSchema  = databaseLeft.GetObjectDefinition(leftSchemaList[i].ToString());
                    string rightSchema = databaseRight.GetObjectDefinition(rightSchemaList[schemaIndex].ToString());

                    // Check for schema differences
                    DifferenceEngine.TextMemory leftText = new DifferenceEngine.TextMemory(leftSchema);
                    schemaDifferences[addedIndex].LeftText = leftText;
                    DifferenceEngine.TextMemory rightText = new DifferenceEngine.TextMemory(rightSchema);
                    schemaDifferences[addedIndex].RightText = rightText;

                    DifferenceEngine.DiffEngine diffEngine = new DifferenceEngine.DiffEngine();
                    double timeTaken = diffEngine.ProcessDiff(leftText, rightText, DifferenceEngine.DiffEngineLevel.SlowPerfect);
                    DifferenceEngine.DiffResultSpanCollection textDifferenceList = diffEngine.DiffReport();

                    // Check if we found any text differences
                    foreach (DifferenceEngine.DiffResultSpan diffResultSpan in textDifferenceList)
                    {
                        if (diffResultSpan.Status != DifferenceEngine.DiffResultSpanStatus.NoChange)
                        {
                            schemaDifferenceFound = true;
                        }
                    }
                    schemaDifferences[addedIndex].DifferenceResults = textDifferenceList;
                    if (schemaDifferenceFound)
                    {
                        schemaDifferences[addedIndex].Outcome = Difference.DifferenceOutcome.Different;
                    }
                    else
                    {
                        schemaDifferences[addedIndex].Outcome = Difference.DifferenceOutcome.Same;
                    }
                }
            }

            // Find objects in second database not yet scanned
            for (int i = 0; i < rightSchemaList.Count; i++)
            {
                if ((FindListItem(rightSchemaList[i].ToString(), leftSchemaList)) == -1)
                {
                    // Left object missing
                    addedIndex = schemaDifferences.Add(new Difference(true, rightSchemaList[i].ToString(), schemaObjectType, Difference.DifferenceOutcome.Missing));

                    // Load the schema for the stored procs
                    string leftSchema  = "";
                    string rightSchema = databaseRight.GetObjectDefinition(rightSchemaList[i].ToString());

                    // Check for schema differences (we know there will be lots!)
                    DifferenceEngine.TextMemory leftText = new DifferenceEngine.TextMemory(leftSchema);
                    schemaDifferences[addedIndex].LeftText = leftText;
                    DifferenceEngine.TextMemory rightText = new DifferenceEngine.TextMemory(rightSchema);
                    schemaDifferences[addedIndex].RightText = rightText;

                    DifferenceEngine.DiffEngine diffEngine = new DifferenceEngine.DiffEngine();
                    double timeTaken = diffEngine.ProcessDiff(leftText, rightText, DifferenceEngine.DiffEngineLevel.SlowPerfect);
                    DifferenceEngine.DiffResultSpanCollection textDifferenceList = diffEngine.DiffReport();

                    schemaDifferences[addedIndex].DifferenceResults = textDifferenceList;
                }
            }

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

            FireCompareSchemaFinished(schemaObjectType);

            return(schemaDifferences);
        }
コード例 #9
0
 //UPDATE
 internal DifferenceCollectionEnumerator(DifferenceCollection collection)
 {
     _index      = -1;
     _collection = collection;
 }
コード例 #10
0
 public void OutputSchemaXml(XmlWriter xmlWriter, DifferenceCollection diffCollection)
 {
     if (diffCollection!=null)
     {
         // Output the schema differences
         foreach(Difference schemaDiff in diffCollection)
         {
             xmlWriter.WriteStartElement(schemaDiff.ObjectType.ToString().ToLower());
             xmlWriter.WriteStartAttribute("name", string.Empty);
             xmlWriter.WriteString(schemaDiff.Name);
             xmlWriter.WriteEndAttribute();	//name
             xmlWriter.WriteStartAttribute("objecttype", string.Empty);
             xmlWriter.WriteString(schemaDiff.ObjectType.ToString());
             xmlWriter.WriteEndAttribute();	//objecttype
             xmlWriter.WriteStartAttribute("outcome", string.Empty);
             xmlWriter.WriteString(schemaDiff.Outcome.ToString());
             xmlWriter.WriteEndAttribute();	//outcome
             xmlWriter.WriteStartAttribute("isleftdifferent", string.Empty);
             xmlWriter.WriteString(schemaDiff.IsLeftDifferent.ToString());
             xmlWriter.WriteEndAttribute();	//isleftdifferent
             xmlWriter.WriteStartAttribute("change", string.Empty);
             xmlWriter.WriteString(schemaDiff.Change.ToString());
             xmlWriter.WriteEndAttribute();	//change
             xmlWriter.WriteEndElement();	//table
         }
     }
 }