Ejemplo n.º 1
0
        /// <summary>
        /// Add an IfcApproval to the model based on COBieIssueRow data
        /// </summary>
        /// <param name="row">COBieIssueRow data</param>
        private void AddIssue(COBieIssueRow row)
        {

            if (CheckIfExistOnMerge(row)) //check on merge to see if IfcApproval exists
                return; //already exists

            //create the property set to attach to the approval
            IfcPropertySet ifcPropertySet = Model.Instances.New<IfcPropertySet>();
            ifcPropertySet.Name = "Pset_Risk";
            ifcPropertySet.Description = "An indication of exposure to mischance, peril, menace, hazard or loss";
           

            //Add Created By, Created On and ExtSystem to Owner History. 
            SetUserHistory(ifcPropertySet, row.ExtSystem, row.CreatedBy, row.CreatedOn);
            
            //using statement will set the Model.OwnerHistoryAddObject to ifcPropertySet.OwnerHistory as OwnerHistoryAddObject is used upon any property changes, 
            //then swaps the original OwnerHistoryAddObject back in the dispose, so set any properties within the using statement
            using (COBieXBimEditScope context = new COBieXBimEditScope(Model, ifcPropertySet.OwnerHistory))
            {
                //create the approval object
                IfcApproval ifcApproval = Model.Instances.New<IfcApproval>();
                //set relationship
                IfcRelAssociatesApproval ifcRelAssociatesApproval = Model.Instances.New<IfcRelAssociatesApproval>();
                ifcRelAssociatesApproval.RelatingApproval = ifcApproval;
                ifcRelAssociatesApproval.RelatedObjects.Add_Reversible(ifcPropertySet);

                if (ValidateString(row.Name))
                    ifcApproval.Name = row.Name;

                if (ValidateString(row.Type))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Type);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskType", "Identifies the predefined types of risk from which the type required may be set.", ifcValues, _riskTypeEnum, null);
                }

                if (ValidateString(row.Risk))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Risk);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskRating", "Rating of the risk that may be determined from a combination of the risk assessment and risk consequence.", ifcValues, _riskRatingEnum, null);
                }

                if (ValidateString(row.Chance))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Chance);
                    AddPropertyEnumeratedValue(ifcPropertySet, "AssessmentOfRisk", "Likelihood of risk event occurring.", ifcValues, _assessmentOfRiskEnum, null);
                }

                if (ValidateString(row.Impact))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Impact);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskConsequence", "Indicates the level of severity of the consequences that the risk would have in case it happens.", ifcValues, _riskConsequenceEnum, null);
                }

                if (ValidateString(row.SheetName1) && ValidateString(row.RowName1))
                {
                    SetRelObjectToApproval(row.SheetName1, row.RowName1,  ifcApproval,  ifcRelAssociatesApproval);
                }

                if (ValidateString(row.SheetName2) && ValidateString(row.RowName2))
                {
                    SetRelObjectToApproval(row.SheetName2, row.RowName2, ifcApproval, ifcRelAssociatesApproval);
                }

                if (ValidateString(row.Description))
                    ifcApproval.Description = row.Description;

                if (ValidateString(row.Owner))
                {
                    IfcValue[] ifcValues = GetValueArray(row.Owner);
                    AddPropertyEnumeratedValue(ifcPropertySet, "RiskOwner", "A determination of who is the owner of the risk by reference to principal roles of organizations within a project.", ifcValues, _riskOwnerEnum, null);
                }

                if (ValidateString(row.Mitigation))
                    AddPropertySingleValue(ifcPropertySet, "PreventiveMeassures", "Identifies preventive measures to be taken to mitigate risk.", new IfcText(row.Mitigation), null);

                //Add Identifier
                if (ValidateString(row.ExtIdentifier))
                    ifcApproval.Identifier = row.ExtIdentifier; // AddGlobalId(row.ExtIdentifier, ifcPropertySet); //IfcApproval gas no GlobalId
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check to see if IfcApproval exists in model
        /// </summary>
        /// <param name="row">COBieIssueRow data</param>
        /// <returns>bool</returns>
        private bool CheckIfExistOnMerge(COBieIssueRow row)
        {
            if (XBimContext.IsMerge)
            {
                if (ValidateString(row.Name)) //we have a primary key to check
                {
                    string testName = row.Name.ToLower().Trim();
                    IfcApproval testObj = Model.Instances.Where<IfcApproval>(bs => bs.Name.ToString().ToLower().Trim() == testName).FirstOrDefault();
                    if (testObj != null)
                    {
#if DEBUG
                        Console.WriteLine("{0} : {1} exists so skip on merge", testObj.GetType().Name, row.Name);
#endif
                        return true; //we have it so no need to create
                    }
                }
            }
            return false;
        }