/// <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; } } } }
/// <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); }
private string GetContact(IfcApproval ifcApproval) { string eMail = DEFAULT_STRING; if (ifcApprovalActorRelationships == null) { ifcApprovalActorRelationships = Model.FederatedInstances.OfType <IfcApprovalActorRelationship>().ToList(); } IfcPersonAndOrganization IfcPersonAndOrganization = ifcApprovalActorRelationships .Where(aar => aar.Approval.EntityLabel == ifcApproval.EntityLabel) .Select(aar => aar.Actor).OfType <IfcPersonAndOrganization>().FirstOrDefault(); if (IfcPersonAndOrganization != null) { eMail = GetTelecomEmailAddress(IfcPersonAndOrganization); } return(eMail); }
public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex) { switch (propIndex) { case 0: case 1: case 2: case 3: case 4: base.Parse(propIndex, value, nestedIndex); return; case 5: _relatingApproval = (IfcApproval)(value.EntityVal); return; default: throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper())); } }
public override void IfcParse(int propIndex, IPropertyValue value) { switch (propIndex) { case 0: case 1: case 2: case 3: case 4: base.IfcParse(propIndex, value); break; case 5: _relatingApproval = (IfcApproval)value.EntityVal; break; default: this.HandleUnexpectedAttribute(propIndex, value); break; } }
/// <summary> /// get all the IfcRoot objects attached to the ifcApproval /// </summary> /// <param name="ifcApproval">IfcApproval Object</param> /// <returns>List of IfcRoot Objects</returns> private List <IfcRoot> GetIfcObjects(IfcApproval ifcApproval) { List <IfcRoot> ifcRootObjs = new List <IfcRoot>(); if (ifcRelAssociatesApprovals == null) { ifcRelAssociatesApprovals = Model.FederatedInstances.OfType <IfcRelAssociatesApproval>().ToList(); } IEnumerable <IfcRoot> IfcRoots = ifcRelAssociatesApprovals.Where(ral => ral.RelatingApproval.EntityLabel == ifcApproval.EntityLabel) .SelectMany(ral => ral.RelatedObjects).OfType <IfcRoot>(); foreach (IfcRoot item in IfcRoots) { if (item.GetType() != typeof(IfcPropertySet)) { ifcRootObjs.Add(item); } } return(ifcRootObjs); }
/// <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 } } }
public IfcRelAssociatesApproval(IfcGloballyUniqueId __GlobalId, IfcOwnerHistory __OwnerHistory, IfcLabel?__Name, IfcText?__Description, IfcRoot[] __RelatedObjects, IfcApproval __RelatingApproval) : base(__GlobalId, __OwnerHistory, __Name, __Description, __RelatedObjects) { this._RelatingApproval = __RelatingApproval; }