예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #3
0
        public override void PlanElementHandler(object sender, PlanElementEventArg e)
        {
            try
            {
                if (e.PlanElement.GetType() == typeof(Actions))
                {
                    Actions action = e.PlanElement as Actions;
                    //PlanElementUtil.SetProgramInformation(_programAttributes, e.Program);
                    _programAttributes.PlanElementId = e.Program.Id;

                    if (action != null && action.Completed)
                    {
                        action.CompletedBy    = e.UserId;
                        action.ElementState   = (int)ElementState.Completed;
                        action.DateCompleted  = DateTime.UtcNow;
                        action.StateUpdatedOn = DateTime.UtcNow;
                        PeUtils.DisableCompleteButtonForAction(action.Steps);

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

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