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 }); } }
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 }); } }