/// <summary> /// Add the data to the IfcConstructionEquipmentResource object /// </summary> /// <param name="row">COBieResourceRow holding the data</param> private void AddResource(COBieResourceRow row) { //we are merging so check for an existing item name, assume the same item as should be the same building if (CheckIfExistOnMerge <IfcConstructionEquipmentResource>(row.Name)) { return;//we have it so no need to create } IfcConstructionEquipmentResource ifcConstructionEquipmentResource = Model.Instances.New <IfcConstructionEquipmentResource>(); //Add Created By, Created On and ExtSystem to Owner History. SetUserHistory(ifcConstructionEquipmentResource, row.ExtSystem, row.CreatedBy, row.CreatedOn); //using statement will set the Model.OwnerHistoryAddObject to ifcConstructionEquipmentResource.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, ifcConstructionEquipmentResource.OwnerHistory)) { //Add Name if (ValidateString(row.Name)) { ifcConstructionEquipmentResource.Name = row.Name; } //Add Category if (ValidateString(row.Category)) { ifcConstructionEquipmentResource.ObjectType = row.Category; } //Add GlobalId AddGlobalId(row.ExtIdentifier, ifcConstructionEquipmentResource); //add Description if (ValidateString(row.Description)) { ifcConstructionEquipmentResource.Description = row.Description; } } }
/// <summary> /// Fill sheet rows for Job sheet /// </summary> /// <returns>COBieSheet</returns> public override COBieSheet <COBieJobRow> Fill() { ProgressIndicator.ReportMessage("Starting Jobs..."); //create new sheet COBieSheet <COBieJobRow> jobs = new COBieSheet <COBieJobRow>(Constants.WORKSHEET_JOB); // get all IfcTask objects from IFC file IEnumerable <IfcTask> ifcTasks = Model.Instances.OfType <IfcTask>(); COBieDataPropertySetValues allPropertyValues = new COBieDataPropertySetValues(); //properties helper class //IfcTypeObject typObj = Model.Instances.OfType<IfcTypeObject>().FirstOrDefault(); IfcConstructionEquipmentResource cer = Model.Instances.OfType <IfcConstructionEquipmentResource>().FirstOrDefault(); ProgressIndicator.Initialise("Creating Jobs", ifcTasks.Count()); foreach (IfcTask ifcTask in ifcTasks) { ProgressIndicator.IncrementAndUpdate(); if (ifcTask == null) { continue; } COBieJobRow job = new COBieJobRow(jobs); job.Name = (string.IsNullOrEmpty(ifcTask.Name.ToString())) ? DEFAULT_STRING : ifcTask.Name.ToString(); job.CreatedBy = GetTelecomEmailAddress(ifcTask.OwnerHistory); job.CreatedOn = GetCreatedOnDateAsFmtString(ifcTask.OwnerHistory); job.Category = ifcTask.ObjectType.ToString(); job.Status = (string.IsNullOrEmpty(ifcTask.Status.ToString())) ? DEFAULT_STRING : ifcTask.Status.ToString(); job.TypeName = GetObjectType(ifcTask); job.Description = (string.IsNullOrEmpty(ifcTask.Description.ToString())) ? DEFAULT_STRING : ifcTask.Description.ToString(); allPropertyValues.SetAllPropertyValues(ifcTask); //set properties values to this task IfcPropertySingleValue ifcPropertySingleValue = allPropertyValues.GetPropertySingleValue("TaskDuration"); job.Duration = ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.NominalValue != null)) ? ConvertNumberOrDefault(ifcPropertySingleValue.NominalValue.ToString()) : DEFAULT_NUMERIC; string unitName = ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.Unit != null)) ? GetUnitName(ifcPropertySingleValue.Unit) : null; job.DurationUnit = (string.IsNullOrEmpty(unitName)) ? DEFAULT_STRING : unitName; ifcPropertySingleValue = allPropertyValues.GetPropertySingleValue("TaskStartDate"); job.Start = GetStartTime(ifcPropertySingleValue); unitName = ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.Unit != null)) ? GetUnitName(ifcPropertySingleValue.Unit) : null; job.TaskStartUnit = (string.IsNullOrEmpty(unitName)) ? DEFAULT_STRING : unitName; ifcPropertySingleValue = allPropertyValues.GetPropertySingleValue("TaskInterval"); job.Frequency = ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.NominalValue != null)) ? ConvertNumberOrDefault(ifcPropertySingleValue.NominalValue.ToString()) : DEFAULT_NUMERIC; unitName = ((ifcPropertySingleValue != null) && (ifcPropertySingleValue.Unit != null)) ? GetUnitName(ifcPropertySingleValue.Unit) : null; job.FrequencyUnit = (string.IsNullOrEmpty(unitName)) ? DEFAULT_STRING : unitName; job.ExtSystem = GetExternalSystem(ifcTask); job.ExtObject = ifcTask.GetType().Name; job.ExtIdentifier = ifcTask.GlobalId; job.TaskNumber = (string.IsNullOrEmpty(ifcTask.TaskId.ToString())) ? DEFAULT_STRING : ifcTask.TaskId.ToString(); job.Priors = GetPriors(ifcTask); job.ResourceNames = GetResources(ifcTask); jobs.AddRow(job); } jobs.OrderBy(s => s.Name); ProgressIndicator.Finalise(); return(jobs); }