Exemplo n.º 1
0
        public StationTO Get(long stationNumber)
        {
            var domain  = DefaultDAO.Get(stationNumber);
            var station = Mapper.Map <StationTO>(domain);

            station.Steps = StepBO.ListByStation(station.Type, station.Number);
            return(station);
        }
Exemplo n.º 2
0
 public StepTO GetCurrentStep()
 {
     if (this.IsLoad())
     {
         return(StepBO.GetCurrent());
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 3
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
            });
        }
Exemplo n.º 4
0
        public ExecuteResultTO Execute(string data)
        {
            var resultTO   = new ExecuteResultTO();
            var hasFork    = (StepBO.GetCurrent().Fork > 0);
            var isLast     = (StepBO.GetCurrent().Last);
            var executeTO  = StepBO.Execute(data);
            var nextStepTO = GoNextStep(executeTO);

            if (executeTO.Result == Result.Fail && hasFork && !isLast)
            {
                resultTO = Execute(data);
            }
            else
            {
                resultTO.Result         = executeTO.Result;
                resultTO.ExecuteMessage = executeTO.Message;
                resultTO.PromptMessage  = nextStepTO.Message;
            }
            return(resultTO);
        }
Exemplo n.º 5
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
            });
        }