public void HydratePlanElementLists(List <object> processedElements, DTO.PlanElements planElems) { object _obj = null; try { if (planElems == null) { throw new ArgumentException("planElems is null."); } if (processedElements == null) { throw new ArgumentException("processedElements is null."); } if (processedElements != null && processedElements.Count > 0) { foreach (Object obj in processedElements) { _obj = obj; if (obj.GetType() == typeof(Program)) { try { if (!planElems.Programs.Contains(obj)) { Program p = CloneProgram((Program)obj); planElems.Programs.Add(p); } } catch (Exception ex) { throw new ArgumentException("plan elems programs collection null" + ex.Message); } } else if (obj.GetType() == typeof(Module)) { try { if (!planElems.Modules.Contains(obj)) { Module m = CloneModule((Module)obj); planElems.Modules.Add(m); } } catch (Exception ex) { throw new ArgumentException("plan elems modules collection null" + ex.Message); } } else if (obj.GetType() == typeof(Actions)) { try { if (!planElems.Actions.Contains(obj)) { Actions a = CloneAction((Actions)obj); planElems.Actions.Add(a); } } catch (Exception ex) { throw new ArgumentException("plan elems actions collection null" + ex.Message); } } else if (obj.GetType() == typeof(Step)) { try { if (!planElems.Steps.Contains(obj)) { Step s = CloneStep((Step)obj); planElems.Steps.Add(s); } } catch (Exception ex) { throw new ArgumentException("plan elems step collection null" + ex.Message); } } else if (obj.GetType() == typeof(PatientGoal)) { try { if (!planElems.Goals.Contains(obj)) { PatientGoal s = CloneGoal((PatientGoal)obj); planElems.Goals.Add(s); } } catch (Exception ex) { throw new ArgumentException("plan elems patientgoal collection null" + ex.Message); } } else if (obj.GetType() == typeof(PatientIntervention)) { try { if (!planElems.Interventions.Contains(obj)) { PatientIntervention s = CloneIntervention((PatientIntervention)obj); planElems.Interventions.Add(s); } } catch (Exception ex) { throw new ArgumentException("plan elems PatientIntervention collection null" + ex.Message); } } else if (obj.GetType() == typeof(PatientTask)) { try { if (!planElems.Tasks.Contains(obj)) { PatientTask s = CloneTask((PatientTask)obj); planElems.Tasks.Add(s); } } catch (Exception ex) { throw new ArgumentException("plan elems patienttask collection null" + ex.Message); } } } } } catch (Exception ex) { throw new Exception("AD:PlanElementUtil:HydratePlanElementLists()::" + _obj.GetType().ToString() + ex.Message, ex.InnerException); } }
public void Update_Action_Assign_To() { IPlanElementUtils pUtils = new PlanElementUtils(); var targetAction = ObjectId.GenerateNewId().ToString(); AD.Program prog = new AD.Program { Id = ObjectId.GenerateNewId().ToString(), Modules = new List <AD.Module> { new AD.Module { Id = ObjectId.GenerateNewId().ToString(), Actions = new List <AD.Actions> { new AD.Actions { Id = targetAction, ElementState = 2 }, new AD.Actions { Id = ObjectId.GenerateNewId().ToString() } } }, new AD.Module { Id = ObjectId.GenerateNewId().ToString(), Actions = new List <AD.Actions> { new AD.Actions { Id = ObjectId.GenerateNewId().ToString() }, new AD.Actions { Id = ObjectId.GenerateNewId().ToString() } } }, } }; var assignToId = ObjectId.GenerateNewId().ToString(); AD.PlanElement pe = new AD.PlanElement { Id = targetAction, AssignToId = assignToId }; var planElems = new DTO.PlanElements { Actions = new List <DTO.Actions>(), Modules = new List <DTO.Module>(), Programs = new List <DTO.Program>(), Steps = new List <DTO.Step>() }; pUtils.UpdatePlanElementAttributes(prog, pe, "111111111111111111111111", planElems); Assert.AreEqual(assignToId, prog.Modules[0].Actions[0].AssignToId); }