public ClassifiedAssetTypesViewModel(Category initCategory)
 {
     CategoryCode = initCategory.Code;
     CategoryDescription = initCategory.Description;
     CategoryClassification = initCategory.Classification;
     AssetTypes = new ObservableCollection<AssetTypeViewModel>();
 }
示例#2
0
        /// <summary>
        /// This method searches through the facilities to look
        /// for properties inside the property sets of Assets
        /// to look for values that match Regex classification 
        /// formats, set out in the DataReader. It then adds any
        /// values that match the Regular Expression as a category
        /// of assets which conforms with the Schema.
        /// </summary>
        private static void AddClassificationsToAssets(Facility facility)
        {
            var dataReader = new ClassificationMappingReader();//DataReader Object which will create and populate the mappings table.
            //Get Each AssetType
            foreach (AssetType at in facility.AssetTypes)
            {
                //Get Each Asset
                foreach (Asset a in at.Assets)
                {
                    //Create a new Category for the Asset
                    a.Categories = new List<Category>();

                    //Get Each Property
                    foreach (var attr in a.Attributes)
                    {
                        if (attr.Value.GetStringValue() != null && a.Categories.Count == 0)
                        {
                            //Get the Inferred Classifications

                            var inferredClassifications = FindInferredClassifications(attr.Value.GetStringValue(), dataReader);

                            foreach (var ic in inferredClassifications)
                            {
                                bool UniclassMatch = false;
                                bool NbsMatch = false;
                                bool NrmMatch = false;

                                foreach (var cat in a.Categories)
                                {
                                    if (ic.UniclassCode != null && cat.Code == ic.UniclassCode)
                                    {
                                        UniclassMatch = true;
                                    }
                                    if (ic.NbsCode != null && cat.Code == ic.NbsCode)
                                    {
                                        NbsMatch = true;
                                    }
                                    if (ic.NrmCode != null && cat.Code == ic.NrmCode)
                                    {
                                        NrmMatch = true;
                                    }
                                }
                                //Add the Classifications as categories if they exist.
                                if (ic.UniclassCode != null && !UniclassMatch)
                                {
                                    var uniClass = new Xbim.COBieLiteUK.Category();
                                    uniClass.Classification = "Uniclass 2015 Reference (Inferred)";
                                    uniClass.Code = ic.UniclassCode;
                                    uniClass.Description = ic.UniclassDescription;
                                    a.Categories.Add(uniClass);
                                }
                                if (ic.NbsCode != null && !NbsMatch)
                                {
                                    Xbim.COBieLiteUK.Category Nbs = new Xbim.COBieLiteUK.Category();
                                    Nbs.Classification = "NBS Reference (Inferred)";
                                    Nbs.Code = ic.NbsCode;
                                    Nbs.Description = ic.NbsDescription;
                                    a.Categories.Add(Nbs);
                                }
                                if (ic.NrmCode != null && !NrmMatch)
                                {
                                    Xbim.COBieLiteUK.Category Nrm = new Xbim.COBieLiteUK.Category();
                                    Nrm.Classification = "NRM Reference (Inferred)";
                                    Nrm.Code = ic.NrmCode;
                                    Nrm.Description = ic.NrmDescription;
                                    a.Categories.Add(Nrm);
                                }
                            }

                        }
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// This method searches through the facilities to look
        /// for properties inside the property sets of Assets
        /// to look for values that match Regex classification
        /// formats, set out in the DataReader. It then adds any
        /// values that match the Regular Expression as a category
        /// of assets which conforms with the Schema.
        /// </summary>
        static private void AddClassificationsToAssets(Facility facility)
        {
            var dataReader = new ClassificationMappingReader();//DataReader Object which will create and populate the mappings table.

            //Get Each AssetType
            foreach (AssetType at in facility.AssetTypes)
            {
                //Get Each Asset
                foreach (Asset a in at.Assets)
                {
                    //Create a new Category for the Asset
                    a.Categories = new List <Category>();

                    //Get Each Property
                    foreach (var attr in a.Attributes)
                    {
                        if (attr.Value.GetStringValue() != null && a.Categories.Count == 0)
                        {
                            //Get the Inferred Classifications

                            var inferredClassifications = FindInferredClassifications(attr.Value.GetStringValue(), dataReader);

                            foreach (var ic in inferredClassifications)
                            {
                                bool UniclassMatch = false;
                                bool NbsMatch      = false;
                                bool NrmMatch      = false;

                                foreach (var cat in a.Categories)
                                {
                                    if (ic.UniclassCode != null && cat.Code == ic.UniclassCode)
                                    {
                                        UniclassMatch = true;
                                    }
                                    if (ic.NbsCode != null && cat.Code == ic.NbsCode)
                                    {
                                        NbsMatch = true;
                                    }
                                    if (ic.NrmCode != null && cat.Code == ic.NrmCode)
                                    {
                                        NrmMatch = true;
                                    }
                                }
                                //Add the Classifications as categories if they exist.
                                if (ic.UniclassCode != null && !UniclassMatch)
                                {
                                    var uniClass = new Xbim.COBieLiteUK.Category();
                                    uniClass.Classification = "Uniclass 2015 Reference (Inferred)";
                                    uniClass.Code           = ic.UniclassCode;
                                    uniClass.Description    = ic.UniclassDescription;
                                    a.Categories.Add(uniClass);
                                }
                                if (ic.NbsCode != null && !NbsMatch)
                                {
                                    Xbim.COBieLiteUK.Category Nbs = new Xbim.COBieLiteUK.Category();
                                    Nbs.Classification = "NBS Reference (Inferred)";
                                    Nbs.Code           = ic.NbsCode;
                                    Nbs.Description    = ic.NbsDescription;
                                    a.Categories.Add(Nbs);
                                }
                                if (ic.NrmCode != null && !NrmMatch)
                                {
                                    Xbim.COBieLiteUK.Category Nrm = new Xbim.COBieLiteUK.Category();
                                    Nrm.Classification = "NRM Reference (Inferred)";
                                    Nrm.Code           = ic.NrmCode;
                                    Nrm.Description    = ic.NrmDescription;
                                    a.Categories.Add(Nrm);
                                }
                            }
                        }
                    }
                }
            }
        }