/// <summary> /// set up IfcRelSequence for the task /// </summary> /// <param name="row">COBieJobRow holding the data</param> private void SetPriors(COBieJobRow row) { IEnumerable <IfcTask> ifcTaskFound = IfcTasks.Where(task => task.Name == row.Name && task.TaskId == row.TaskNumber); if (ifcTaskFound.Count() == 1) //should equal one { IfcTask ifcTask = ifcTaskFound.First(); if (ValidateString(row.Priors)) { string priors = row.Priors.ToString(); char splitKey = GetSplitChar(priors); string[] priorsArray = row.Priors.ToString().Split(splitKey); foreach (string prior in priorsArray) { string name = row.Name.ToLower().Trim(); string testName = prior.ToLower().Trim(); IEnumerable <IfcTask> ifcTaskRelating = IfcTasks.Where(task => (ifcTask.EntityLabel != task.EntityLabel) && (task.TaskId.ToString().ToLower().Trim() == testName) && (task.Name.ToString().ToLower().Trim() == name)); List <IfcTask> ifcTaskRelatingTasks = ifcTaskRelating.ToList(); //avoids crash of foreach loop, Steve to fix then this can be removed foreach (IfcTask ifcTaskitem in ifcTaskRelatingTasks) { IfcRelSequence relSequence = Model.Instances.New <IfcRelSequence>(); relSequence.RelatedProcess = ifcTask; relSequence.RelatingProcess = ifcTaskitem; } } } } //throw new Exception("COBieXBimJob.SetPriors(): did not find a single task matching name and task number"); }
/// <summary> /// Get the IfcTask object for the passed name /// </summary> /// <param name="name">IfcTask name</param> /// <returns>IfcTask Object</returns> private IfcTask GetTask(string name) { IfcTask ifcTask = null; if (IfcTasks == null) { IfcTasks = Model.Instances.OfType <IfcTask>(); } name = name.ToLower().Trim(); ifcTask = IfcTasks.Where(t => t.Name.ToString().ToLower().Trim() == name).FirstOrDefault(); return(ifcTask); }