Example #1
0
        public ResultTO GoFirstStep()
        {
            var firstStep = GetCurrent().Steps.OrderBy(i => i.Index).First();

            StepBO.SetCurrent(firstStep);
            return(new ResultTO
            {
                Result = Result.Pass,
                Message = firstStep.Data.Prompt
            });
        }
Example #2
0
        private ResultTO GoNextStep(ResultTO result)
        {
            var currentStep = StepBO.GetCurrent();

            if (result.Result == Result.Pass)
            {
                var secondStep = GetSecondStep(currentStep);
                if (secondStep == null)
                {
                    throw new ApplicationException("Second Step nao encontrado");
                }

                StepBO.SetCurrent(secondStep);
            }
            else if (currentStep.Fork > 0)
            {
                var stepData = currentStep.Data.Value;
                var forkStep = GetForkStep(currentStep);
                if (forkStep == null)
                {
                    throw new ApplicationException("Fork Step nao encontrado");
                }

                StepBO.SetCurrent(forkStep);
            }
            else if (!string.IsNullOrEmpty(currentStep.Special) &&
                     currentStep.Special != "N/A" &&
                     result.Message.Contains("JUMP="))
            {
                var jumpStep = GetJumpStep(currentStep, result.Message);
                if (jumpStep == null)
                {
                    throw new ApplicationException("Jump Step nao encontrado");
                }

                StepBO.SetCurrent(jumpStep);
            }

            if (result.Result == Result.Pass)
            {
                if (currentStep.Last)
                {
                    SessionBO.GetInstance().ClearUntilLastInput();
                }
                else if (currentStep.Rule == Rule.KeepInMemory ||
                         currentStep.Rule == Rule.UntilLastInput)
                {
                    SessionBO.GetInstance().AddVariable(new SessionTO
                    {
                        Name  = currentStep.Data.Name,
                        Value = currentStep.Data.Value,
                        Rule  = currentStep.Rule
                    });
                }
            }
            return(new ResultTO
            {
                Result = Result.Pass,
                Message = StepBO.GetCurrent().Data.Prompt
            });
        }