Esempio 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(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
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Set the IfcRelAssociatesApproval object
        /// </summary>
        /// <param name="sheetName">Sheet name</param>
        /// <param name="rowName">Row name</param>
        /// <param name="ifcApproval">IfcApproval object</param>
        /// <param name="ifcRelAssociatesApproval">IfcRelAssociatesApproval object</param>
        private void SetRelObjectToApproval(string sheetName, string rowName, IfcApproval ifcApproval, IfcRelAssociatesApproval ifcRelAssociatesApproval)
        {
            IfcRoot ifcRoot = GetRootObject(sheetName, rowName);

            //sheetName = sheetName.ToLower().Trim();
            if (ifcRoot != null) //we have a object
            {
                ifcRelAssociatesApproval.RelatedObjects.Add(ifcRoot);
                return;
            }

            if (sheetName == Constants.WORKSHEET_CONTACT)
            {
                IfcActorSelect ifcActorSelect = GetActorSelect(rowName);
                if (ifcActorSelect != null)
                {
                    //see if the relation ship exists, if so no need to create
                    IfcActorSelect IfcActorSelectTest = Model.Instances.OfType <IfcApprovalActorRelationship>()
                                                        .Where(aar => aar.Approval == ifcApproval)
                                                        .Select(aar => aar.Actor).OfType <IfcActorSelect>()
                                                        .Where(po => po == ifcActorSelect)
                                                        .FirstOrDefault();
                    if (IfcActorSelectTest == null)
                    {
                        IfcApprovalActorRelationship ifcApprovalActorRelationship = Model.Instances.New <IfcApprovalActorRelationship>();
                        ifcApprovalActorRelationship.Actor    = ifcActorSelect;
                        ifcApprovalActorRelationship.Approval = ifcApproval;
                    }
                }
            }
        }