Exemple #1
0
        public void RunDiff(string outputFileName, int?newModel = null, int?refModel = null, BIMRLDiffOptions options = null)
        {
            if (options == null)
            {
                options = BIMRLDiffOptions.SelectAllOptions();
            }

            if (newModel.HasValue)
            {
                compNewModel = newModel.Value;
            }
            if (refModel.HasValue)
            {
                compRefModel = refModel.Value;
            }

            if ((!compNewModel.HasValue || !compRefModel.HasValue) && (!newModel.HasValue || !refModel.HasValue))
            {
                throw new Exception("Model IDs must be supplied!");
            }

            string elemTableNew = DBOperation.formatTabName("BIMRL_ELEMENT", compNewModel.Value);
            string elemTableRef = DBOperation.formatTabName("BIMRL_ELEMENT", compRefModel.Value);

            // Create tables to keep track of the new or deleted objects
            runNonQuery("drop table newelements", true);
            runNonQuery("create table newelements as select elementid from " + elemTableNew + " minus select elementid from " + elemTableRef, true);
            runNonQuery("drop table deletedelements", true);
            runNonQuery("create table deletedelements as select elementid from " + elemTableRef + " minus select elementid from " + elemTableNew, true);

            if (options.CheckNewAndDeletedObjects)
            {
                AddResultDict("CheckNewAndDeletedObjects", DiffObjects());
            }

            if (options.CheckGeometriesDiffBySignature)
            {
                GraphicsZipFile = Path.Combine(Path.GetDirectoryName(outputFileName), Path.GetFileNameWithoutExtension(outputFileName) + "-GraphicsOutput.zip");
                AddResultDict("CheckGeometriesDiff", DiffGeometry(GraphicsZipFile, options.GeometryCompareTolerance));
            }

            if (options.CheckTypeAndTypeAssignments)
            {
                AddResultDict("CheckTypeAndTypeAssignments", DiffType());
            }

            if (options.CheckContainmentRelationships)
            {
                AddResultDict("CheckContainmentRelationships", DiffContainment());
            }

            if (options.CheckOwnerHistory)
            {
                AddResultDict("CheckOwnerHistory", DiffOwnerHistory());
            }

            if (options.CheckProperties)
            {
                AddResultDict("CheckProperties", DiffProperty());
            }

            if (options.CheckMaterials)
            {
                AddResultDict("CheckMaterials", DiffMaterial());
            }

            if (options.CheckClassificationAssignments)
            {
                AddResultDict("CheckClassificationAssignments", DiffClassification());
            }

            if (options.CheckGroupMemberships)
            {
                AddResultDict("CheckGroupMemberships", DiffGroupMembership());
            }

            if (options.CheckAggregations)
            {
                AddResultDict("CheckAggregations", DiffAggregation());
            }

            if (options.CheckConnections)
            {
                AddResultDict("CheckConnections", DiffConnection());
            }

            if (options.CheckElementDependencies)
            {
                AddResultDict("CheckElementDependencies", DiffElementDependency());
            }

            if (options.CheckSpaceBoundaries)
            {
                AddResultDict("CheckSpaceBoundaries", DiffSpaceBoundary());
            }

            try
            {
                string json = JsonConvert.SerializeObject(diffResultsDict, Formatting.Indented);
                using (StreamWriter file = File.CreateText(outputFileName))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, diffResultsDict);
                }
            }
            catch
            {
                throw new Exception("Fail to sereialize to " + outputFileName);
            }
        }
Exemple #2
0
        public static BIMRLDiffOptions SelectAllOptions()
        {
            BIMRLDiffOptions options = new BIMRLDiffOptions();

            return(options);
        }