Exemplo n.º 1
0
        public ControllerResultTO ExecuteFlow(string data)
        {
            var controllerResult = new ControllerResultTO();

            try
            {
                if (!StationBO.IsLoad())
                {
                    throw new ApplicationException("Estacao nao configurada");
                }
                else if (GetCurrentStatus() == ControllerStatus.WaitUserInput)
                {
                    SetCurrentStatus(ControllerStatus.Busy);

                    var resultTO = StationBO.Execute(data);

                    controllerResult.Result         = resultTO.Result;
                    controllerResult.ExecuteMessage = resultTO.ExecuteMessage;
                    controllerResult.PromptMessage  = resultTO.PromptMessage;
                    SetCurrentStatus(ControllerStatus.WaitUserInput);
                }
            }
            catch (Exception ex)
            {
                controllerResult.Result         = Result.Fail;
                controllerResult.ExecuteMessage = ex.Message;
                controllerResult.Exception      = ex;
                controllerResult.PromptMessage  = StationBO.GetCurrentStep()?.Data.Prompt;
                SetCurrentStatus(ControllerStatus.WaitUserInput);
            }
            return(controllerResult);
        }
Exemplo n.º 2
0
 public ControllerResultTO <LoginTO> ChangeStation(long stationNumber, bool autoLogin = false)
 {
     try
     {
         StationBO.ChangeStation(stationNumber);
         var resultTO = StationBO.GoFirstStep();
         if (resultTO.Result == Result.Pass)
         {
             if (!autoLogin)
             {
                 var loginTO = Mapper.Map <LoginTO>(StationBO.GetCurrent());
                 ProfileBO.WriteLogin(loginTO);
             }
             SetCurrentStatus(ControllerStatus.WaitUserInput);
         }
         return(new ControllerResultTO <LoginTO>
         {
             Result = resultTO.Result,
             PromptMessage = resultTO.Message,
             TO = Mapper.Map <LoginTO>(StationBO.GetCurrent())
         });
     }
     catch (Exception ex)
     {
         SetCurrentStatus(ControllerStatus.Idle);
         StationBO.SetCurrent(null);
         return(new ControllerResultTO <LoginTO>
         {
             Result = Result.Fail,
             ExecuteMessage = ex.Message,
             PromptMessage = "Falha ao carregar estacao!",
             Exception = ex
         });
     }
 }
Exemplo n.º 3
0
        public ControllerResultTO ResetFlow()
        {
            var controllerResult = new ControllerResultTO();

            try
            {
                if (!StationBO.IsLoad())
                {
                    throw new ApplicationException("Estacao nao configurada");
                }
                else if (GetCurrentStatus() == ControllerStatus.WaitUserInput)
                {
                    SetCurrentStatus(ControllerStatus.Busy);

                    SessionBO.GetInstance().ClearAllVariables();

                    var resultTO = StationBO.GoFirstStep();

                    controllerResult.Result        = resultTO.Result;
                    controllerResult.PromptMessage = resultTO.Message;
                }
            }
            catch (Exception ex)
            {
                controllerResult.Result         = Result.Fail;
                controllerResult.ExecuteMessage = ex.Message;
                controllerResult.PromptMessage  = StationBO.GetCurrentStep().Data.Prompt;
                controllerResult.Exception      = ex;
            }
            finally
            {
                SetCurrentStatus(ControllerStatus.WaitUserInput);
            }
            return(controllerResult);
        }
Exemplo n.º 4
0
        public ControllerResultTO <LoginTO> AutoLogin()
        {
            try
            {
                ControllerResultTO <LoginTO> RetLogin = null;
                var lastTO = ProfileBO.GetLastLogin();
                if (lastTO != null)
                {
                    var resultTO = ChangeStation(lastTO.StationNumber, true);
                    RetLogin    = Mapper.Map <ControllerResultTO <LoginTO> >(resultTO);
                    RetLogin.TO = lastTO;

                    if (RetLogin.Result == Result.Pass &&
                        StationBO.GetCurrent().Name != lastTO.StationName)
                    {
                        throw new ApplicationException("Valores no arquivo de configuração inválidos");
                    }
                }
                return(RetLogin);
            }
            catch (Exception ex)
            {
                SetCurrentStatus(ControllerStatus.Idle);
                StationBO.SetCurrent(null);
                return(new ControllerResultTO <LoginTO>
                {
                    Result = Result.Fail,
                    ExecuteMessage = ex.Message,
                    PromptMessage = "Falha ao carregar estacao!",
                    Exception = ex
                });
            }
        }
Exemplo n.º 5
0
 public ControllerResultTO <ICollection <StationTO> > GetStationList(int hostNumber)
 {
     try
     {
         return(new ControllerResultTO <ICollection <StationTO> >
         {
             Result = Result.Pass,
             TO = StationBO.ListByHost(hostNumber)
         });
     }
     catch (Exception ex)
     {
         return(new ControllerResultTO <ICollection <StationTO> >
         {
             Result = Result.Fail,
             ExecuteMessage = ex.Message,
             Exception = ex
         });
     }
 }