internal static HttpResponseException fromErrorString2(string message, HttpStatusCode statusCode = HttpStatusCode.InternalServerError) { FunctionalException ex = new FunctionalException(message); return(fromEx2(ex, statusCode)); }
static ServiceError GetServiceError(Exception e) { ServiceError err = null; if ((e is TechnicalException)) { TechnicalException tx = (TechnicalException)e; err = new ServiceError(); err.ErrorId = tx.ErrorId; err.Message = tx.Message; err.Source = tx.Source; err.ServiceName = tx.ServiceName; FillServiceError(err, tx); } if ((e is FunctionalException)) { FunctionalException fx = (FunctionalException)e; err = new ServiceError(); err.ErrorId = fx.ErrorId; err.Message = fx.Message; err.Source = fx.Source; err.ServiceName = fx.ServiceName; err.Severity = Enum.GetName(typeof(FunctionalException.ExceptionSeverity), fx.Severity); FillServiceError(err, fx); } //if (e is System.TypeLoadException) //{ // System.Text.StringBuilder wMessage = new StringBuilder(); // err = new ServiceError(); // err.ErrorId = "7002"; // wMessage.Append("No se encuentra el o los assemblies para cargar el servicio " + pServiceConfiguration.Name); // wMessage.AppendLine(); // wMessage.AppendLine(e.Message); // err.Message = wMessage.ToString(); // FillServiceError(err, e); //} if (err == null) { err = new ServiceError(); if (e.InnerException != null) { e = e.InnerException; } err.Message = e.Message; FillServiceError(err, e); } return(err); }
protected void sendCustomError(string Campo, string Codigo, string NombreEntidad) { keyArray = new KeyArray(); keyArray.Codigo = Codigo; keyArray.Parametros.Add(NombreEntidad); keyArray.Parametros.Add(Campo); if (fe == null) { fe = new FunctionalException(); } fe.DataValidations.Add(keyArray); valida = false; }
/// <summary> /// Obtener los datos del Token de almacenamiento. /// </summary> /// <param name="refresh_token">El código del Token</param> /// <returns><c>null</c> si el token está vencido o revocado; la información del token si es válido.</returns> public RefreshToken FetchToken(string refreshtoken) { var refresh_token = _store.Get(refreshtoken); if (refresh_token == null || !refresh_token.IsActive) { var fe = new FunctionalException("Token invalido o no existe"); fe.ErrorId = "460"; throw fe; } return(refresh_token); }
private void ValidaDependencias(int Cantidad, int id, string Codigo) { if (Cantidad > 0) { fe = new FunctionalException(); KeyArray keyArray; keyArray = new KeyArray(); keyArray.Codigo = Codigo; keyArray.Parametros.Add(NombreEntidad); keyArray.Parametros.Add(id.ToString()); fe.DataValidations.Add(keyArray); throw fe; } }
protected void ValidateExiste(int Cantidad, string id, string Codigo) { if (Cantidad <= 0) { fe = new FunctionalException(); KeyArray keyArray; keyArray = new KeyArray(); keyArray.Codigo = Codigo; keyArray.Parametros.Add(NombreEntidad); keyArray.Parametros.Add(id); fe.DataValidations.Add(keyArray); throw fe; } }
protected void ValidateString(string Dato, string Campo, string Codigo, string NombreEntidad) { if (string.IsNullOrEmpty(Dato)) { //Codigo requerido keyArray = new KeyArray(); keyArray.Codigo = Codigo; keyArray.Parametros.Add(NombreEntidad); keyArray.Parametros.Add(Campo); if (fe == null) { fe = new FunctionalException(); } fe.DataValidations.Add(keyArray); valida = false; } }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <param name="domain"></param> /// <returns></returns> public String Authenticate(string username, string password, string domain) { FunctionalException fe = null; try { var emmpleadoBE = EpironDAC.VirifyUser(username); //Emp_Id, legajo correspondiente al usuario reseteador, si devuelve NULL mostrar el mensaje “Usuario no registrado en Epiron” y cerrar aplicación. //o Cue_Id, cuenta correspondiente al usuario reseteador, si devuelve NULL y el campo CAIS es 0, mostrar el mensaje “Usuario no habilitado” if (emmpleadoBE == null) { fe = new FunctionalException("Usuario no registrado en Epiron "); fe.ErrorId = HttpStatusCode.Unauthorized.ToString(); throw fe; //return BadRequest(new ApiErrorResponse(HttpStatusCode.Unauthorized, "Usuario no registrado en Epiron ")); } if (string.IsNullOrEmpty(emmpleadoBE.Cuenta) && emmpleadoBE.CAIS == false) { fe = new FunctionalException("Usuario no habilitado "); fe.ErrorId = HttpStatusCode.Unauthorized.ToString(); throw fe; //return BadRequest(new ApiErrorResponse(HttpStatusCode.Unauthorized, "Usuario no habilitado")); } emmpleadoBE.Dominio = domain; var jwtTokenString = TokenGenerator.GenerateTokenEpiron(emmpleadoBE); return(jwtTokenString); } catch (Exception ex) { throw ex; } }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <param name="domain"></param> /// <returns></returns> public String Authenticate(string username, string password, string domain) { FunctionalException fe = null; try { var domName = ActiveDirectoryService.Get_correct_DomainName(domain); ///Virifica contra domino var res = ActiveDirectoryService.User_Logon(username, password, domName); //var resp = apiHelper.fromObject<LoogonUserResult>(res); if (res.LogResult == "LOGIN_USER_OR_PASSWORD_INCORRECT") // if (res.Autenticated == false) { fe = new FunctionalException("El usuario y/o contraseña es incorrecto"); fe.ErrorId = HttpStatusCode.Unauthorized.ToString(); throw fe; //return BadRequest(new ApiErrorResponse(HttpStatusCode.Unauthorized, "El usuario y/o contraseña es incorrecto")); } if (res.LogResult == "LOGIN_USER_DOESNT_EXIST") { fe = new FunctionalException("El usuario no existe en el dominio "); fe.ErrorId = HttpStatusCode.Unauthorized.ToString(); throw fe; //return BadRequest(new ApiErrorResponse(HttpStatusCode.Unauthorized, "El usuario no existe en el dominio ")); } //si la verificacion contra dominio es OK //busco info del dmonio int dom_id = MeucciDAC.GetDimainId(domain); var emmpleadoBE = MeucciDAC.VirifyUser(username, dom_id); //Emp_Id, legajo correspondiente al usuario reseteador, si devuelve NULL mostrar el mensaje “Usuario no registrado en Meucci” y cerrar aplicación. //o Cue_Id, cuenta correspondiente al usuario reseteador, si devuelve NULL y el campo CAIS es 0, mostrar el mensaje “Usuario no habilitado” if (emmpleadoBE == null) { fe = new FunctionalException("Usuario no registrado en Meucci "); fe.ErrorId = HttpStatusCode.Unauthorized.ToString(); throw fe; //return BadRequest(new ApiErrorResponse(HttpStatusCode.Unauthorized, "Usuario no registrado en Meucci ")); } if (string.IsNullOrEmpty(emmpleadoBE.Cuenta) && emmpleadoBE.CAIS == false) { fe = new FunctionalException("Usuario no habilitado "); fe.ErrorId = HttpStatusCode.Unauthorized.ToString(); throw fe; //return BadRequest(new ApiErrorResponse(HttpStatusCode.Unauthorized, "Usuario no habilitado")); } emmpleadoBE.Dominio = domain; var jwtTokenString = TokenGenerator.GenerateTokenMeucci(emmpleadoBE); return(jwtTokenString); } catch (Exception ex) { throw ex; } }
public override void PreProcess() { valida = true; fe = new FunctionalException(); }
public override void PreProcess() { context = new OrdenesContext(); valida = true; fe = new FunctionalException(); }