Beispiel #1
0
        public override void PlanElementHandler(object sender, PlanElementEventArg e)
        {
            try
            {
                if (e.PlanElement.GetType() == typeof(Step))
                {
                    ProgramAttributes.PlanElementId = e.Program.Id;
                    var s = (Step)e.PlanElement;

                    if (e.Action.Completed)
                    {
                        if (s.Completed)
                        {
                            // see if responses have spawn elements
                            if (s.Responses != null)
                            {
                                SetCompletedStepResponses(e, s);
                            }

                            if (s.SpawnElement != null)
                            {
                                PEUtils.SpawnElementsInList(s.SpawnElement, e.Program, e.UserId, ProgramAttributes);
                                s.SpawnElement.ForEach(
                                    rse => { if (rse.ElementType > 100)
                                             {
                                                 HandlePlanElementActions(e, e.UserId, rse);
                                             }
                                    });
                            }
                        }
                        else
                        {
                            if (s.Responses != null)
                            {
                                s.Responses.ForEach(r => { r.Delete = true; });
                            }
                        }

                        // save program properties
                        PEUtils.SaveReportingAttributes(ProgramAttributes, e.DomainRequest);
                        // raise process event to register the id
                        OnProcessIdEvent(e.Program);
                    }
                }
                else if (Successor != null)
                {
                    Successor.PlanElementHandler(this, e);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("AD:StepPlanProcessor:PlanElementHandler()::" + ex.Message, ex.InnerException);
            }
        }
Beispiel #2
0
        public override void PlanElementHandler(object sender, PlanElementEventArg e)
        {
            try
            {
                if (e.PlanElement.GetType() == typeof(Module))
                {
                    Module module = e.PlanElement as Module;
                    //PlanElementUtil.SetProgramInformation(_programAttributes, e.Program);
                    ProgramAttributes.PlanElementId = e.Program.Id;

                    if (module.Actions != null)
                    {
                        module.Completed = PEUtils.GetCompletionStatus(module.Actions);
                        if (module.Completed)
                        {
                            module.CompletedBy    = e.UserId;
                            module.StateUpdatedOn = DateTime.UtcNow;
                            module.ElementState   = (int)ElementState.Completed;
                            module.DateCompleted  = System.DateTime.UtcNow;

                            // look at spawnelement and trigger enabled state.
                            if (module.SpawnElement != null)
                            {
                                PEUtils.SpawnElementsInList(module.SpawnElement, e.Program, e.UserId, ProgramAttributes);
                                module.SpawnElement.ForEach(
                                    rse => { if (rse.ElementType > 100)
                                             {
                                                 HandlePlanElementActions(e, e.UserId, rse);
                                             }
                                    });
                            }

                            // save any program attribute changes
                            PEUtils.SaveReportingAttributes(ProgramAttributes, e.DomainRequest);
                            OnProcessIdEvent(module);
                        }
                    }
                }
                else if (Successor != null)
                {
                    Successor.PlanElementHandler(this, e);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("AD:ModulePlanProcessor:PlanElementHandler()::" + ex.Message, ex.InnerException);
            }
        }