public async Task <User> ValidarSenha(string login, string senha) { UsuarioValidarResponse usuarioValidarResponse; User usuario = new User(); using (var proxy = new GenericProxy <SegurancaSoap>(Binding, Endpoint)) { try { var usuariovalidar = new UsuarioValidarRequest { login = login, senha = senha, SegurancaSoapHeader = await MRVFrameworkHelper.ValidaAcessoAsync(Configuration["MRVFramework:ApiKey"], Configuration["MRVFramework:CodigoSistema"]) }; usuarioValidarResponse = await proxy.Execute(c => c.UsuarioValidarAsync(usuariovalidar)); usuario = new User() { Name = usuarioValidarResponse.UsuarioValidarResult.Nome, Login = usuarioValidarResponse.UsuarioValidarResult.Login, Email = usuarioValidarResponse.UsuarioValidarResult.Email }; foreach (var grupo in usuarioValidarResponse.UsuarioValidarResult.Grupos) { usuario.Profile = grupo.Nome; usuario.ProfileCode = grupo.Codigo; } } catch (FaultException faultException) { throw new Exception("Acesso Inválido"); } catch (Exception ex) { if (ex.Message.IndexOf("Logon failure: unknown user name or bad password", StringComparison.Ordinal) != -1) { throw new Exception("Acesso Inválido"); } else if (ex.Message.IndexOf("#E20", StringComparison.Ordinal) != -1 || ex.Message.IndexOf("#E21", StringComparison.Ordinal) != -1) { throw new Exception("Acesso Inválido"); } else { throw new Exception("Acesso Inválido"); } } return(usuario); } }
private void CheckDeviceHeartBeat() { try { if (!IsServerConnected) { payServiceConnect.Execute(C => { SocketConnectRequest socketConnect = new SocketConnectRequest() { Port = this.Port, Host = this.Host }; IsServerConnected = C.Connect(socketConnect); Debug.WriteLine("ConnectionWindowsService:- ServerConnected " + IsServerConnected); logger.Info("ConnectionWindowsService:- ServerConnected"); }); } else { Action <IPaymentService.IPayService> action = (x => { IsServerConnected = x.CheckHeartBeat(); Debug.WriteLine("ConnectionWindowsService:- ServerConnected " + IsServerConnected); logger.Info("ConnectionWindowsService:- ServerConnected " + IsServerConnected); }); payServiceConnect.Execute(action); } } catch (Exception Ex) { Console.WriteLine(Ex); throw Ex; } }