/// <summary>
        /// Metodo que sirve para Obtener la lista de tipo TipoIdentificacion
        /// </summary>
        /// <param name="pTipoIdentificacion">Filtro de tipo TipoIdentificacion</param>
        /// <returns></returns>
        public RespuestaListaTipoIdentificacion ObtenerListaTipoIdentificacion(TipoIdentificacion pTipoIdentificacion)
        {
            var respuesta = new RespuestaListaTipoIdentificacion();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pTipoIdentificacion.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    respuesta = dal.ObtenerTipoIdentificacion(pTipoIdentificacion);
                    return(respuesta);
                }
                else
                {
                    return new RespuestaListaTipoIdentificacion {
                               Respuesta = respS.Respuesta, ListaTipoIdentificacion = new List <TipoIdentificacion>()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pTipoIdentificacion);
                return(new RespuestaListaTipoIdentificacion {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Obtiene una lista de perfiles por rol
        /// </summary>
        /// <param name="pRol"></param>
        /// <returns></returns>
        public RespuestaListaPerfil ObtenerPerfilPorRol(Rol pRol)
        {
            var respuesta = new RespuestaListaPerfil();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pRol.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    respuesta = dal.ObtenerPerfilPorRol(pRol);

                    return(respuesta);
                }
                else
                {
                    return new RespuestaListaPerfil {
                               Respuesta = respS.Respuesta, ListaPerfil = new List <Perfil>()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pRol);
                return(new RespuestaListaPerfil {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Metodo que sirve para Obtener la lista de tipo Bitacora con paginacion
        /// </summary>
        /// <param name="pBitacora">Filtro de tipo Bitacora</param>
        /// <param name="pPaginacion">Uso de Paginacion</param>
        /// <returns></returns>
        public RespuestaListaBitacoraAplicacion ObtenerBitacoraPaginado(BitacoraAplicacion pBitacora, Paginacion pPaginacion)
        {
            var respuesta = new RespuestaListaBitacoraAplicacion();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pBitacora.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    pBitacora.IdEntidad = respS.Sesion.IdEntidad;
                    respuesta           = dal.ObtenerBitacoraPaginado(pBitacora, pPaginacion);
                    return(respuesta);
                }
                else
                {
                    return new RespuestaListaBitacoraAplicacion {
                               Respuesta = respS.Respuesta, ListaBitacora = new List <BitacoraAplicacion>()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pBitacora);

                BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.ErrorExcepcion,
                                                         TraceData.Utilities.Enums.TypeTrace.Exception, ex, MethodBase.GetCurrentMethod().Name);

                return(new RespuestaListaBitacoraAplicacion {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Metodo que se encarga de eliminar o desactivar un registro  de la tabla Sesion
        /// </summary>
        /// <param name="pSesion"></param>
        /// <returns></returns>
        public RespuestaSesion EliminarSesion(Sesion pSesion)
        {
            int             filasAfectadas;
            RespuestaSesion respuesta = new RespuestaSesion();

            //STRORE PROCEDURE DEFINITION
            DbCommand dbCommand = database1.GetStoredProcCommand(defaultSchema + StoredProcedure.EliminarSesion);

            //IN PARAMETERS

            database1.AddInParameter(dbCommand, parameterName(Sesion.tokenProperty), DbType.String, pSesion.Token);

            //OUT PARAMETERS
            database1.AddOutParameter(dbCommand, parameterName(BaseEntidad.codErrorProperty), DbType.String, Constantes.BaseDatos.codErrorTamano);
            database1.AddOutParameter(dbCommand, parameterName(BaseEntidad.mensajeProperty), DbType.String, Constantes.BaseDatos.mensajeTamano);

            filasAfectadas = database1.ExecuteNonQuery(dbCommand);

            //ERROR CODE AND MESSAGE COLLECTOR
            respuesta.Respuesta            = new Respuesta();
            respuesta.Respuesta.CodMensaje = DBHelper.ReadNullSafeString(database1.GetParameterValue(dbCommand, parameterName(BaseEntidad.codErrorProperty)));
            respuesta.Respuesta.Mensaje    = DBHelper.ReadNullSafeString(database1.GetParameterValue(dbCommand, parameterName(BaseEntidad.mensajeProperty)));

            if (respuesta.Respuesta.CodMensaje == Respuesta.CodExitoso)
            {
                respuesta.Respuesta = new Respuesta(Mensajes.bmDeleteSesion, respuesta.Respuesta.CodMensaje);
            }

            return(respuesta);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Metodo que sirve para Obtener la lista de tipo CuentaEmail
        /// </summary>
        /// <param name="pCuentaEmail">Filtro de tipo CuentaEmail</param>
        /// <returns></returns>
        public RespuestaListaCuentaEmail ObtenerListaCuentaEmail(CuentaEmail pCuentaEmail)
        {
            var respuesta = new RespuestaListaCuentaEmail();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pCuentaEmail.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    pCuentaEmail.IdEntidad = respS.Sesion.IdEntidad;

                    respuesta = dal.ObtenerCuentaEmail(pCuentaEmail);
                    return(respuesta);
                }
                else
                {
                    return new RespuestaListaCuentaEmail {
                               Respuesta = respS.Respuesta, ListaCuentaEmail = new List <CuentaEmail>()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pCuentaEmail);
                return(new RespuestaListaCuentaEmail {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 6
0
 public RespuestaSesion ValidarAcceso(string url, string usuario)
 {
     try
     {
         RespuestaSesion respuestaSesion = new RespuestaSesion();
         IDAOSistema     iDaoSistema     = new DAOSistema();
         RespuestaBD     resp            = iDaoSistema.ValidarAcceso(url, usuario);
         if (resp.EXISTE_ERROR)
         {
             respuestaSesion.Activa  = false;
             respuestaSesion.Mensaje = resp.MENSAJE;
             respuestaSesion.Code    = resp.respuesta;
         }
         else
         {
             respuestaSesion.Activa  = true;
             respuestaSesion.Mensaje = "Acceso permitido";
             respuestaSesion.Code    = "0";
         }
         return(respuestaSesion);
     }
     catch (Exception ex)
     {
         throw new Exception(new Util().ObtenerMsjExcepcion(ex));
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Metodo que sirve para Obtener la lista de tipo Pais
        /// </summary>
        /// <param name="pPais">Filtro de tipo Pais</param>
        /// <returns></returns>
        public RespuestaListaPais ObtenerListaPais(Pais pPais)
        {
            var respuesta = new RespuestaListaPais();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pPais.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    respuesta = dal.ObtenerPais(pPais);
                    return(respuesta);
                }
                else
                {
                    return new RespuestaListaPais {
                               Respuesta = respS.Respuesta, ListaPais = new List <Pais>()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pPais);
                return(new RespuestaListaPais {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 8
0
 public RespuestaSesion ValidarToken(string token)
 {
     try
     {
         RespuestaSesion respuestaSesion = new RespuestaSesion();
         IDAOSistema     iDaoSistema     = new DAOSistema();
         RespuestaBD     resp            = iDaoSistema.ValidarToken(token);
         if (resp.EXISTE_ERROR)
         {
             respuestaSesion.Activa  = false;
             respuestaSesion.Mensaje = resp.MENSAJE;
             respuestaSesion.Code    = resp.respuesta;
         }
         else
         {
             respuestaSesion.Activa  = true;
             respuestaSesion.Mensaje = "Token ok";
             respuestaSesion.Code    = "0";
         }
         return(respuestaSesion);
     }
     catch (Exception ex)
     {
         throw new Exception(new Util().ObtenerMsjExcepcion(ex));
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Obtiene una lista de roles por usuario
        /// </summary>
        /// <param name="pUsuario"></param>
        /// <returns></returns>
        public RespuestaListaRol ObtenerRolPorUsuario(Usuario pUsuario)
        {
            var respuesta = new RespuestaListaRol();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pUsuario.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    respuesta = dal.ObtenerRolPorUsuario(pUsuario);

                    return(respuesta);
                }
                else
                {
                    return new RespuestaListaRol {
                               Respuesta = respS.Respuesta, ListaRol = new List <Rol>()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pUsuario);

                BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.ErrorExcepcion,
                                                         TraceData.Utilities.Enums.TypeTrace.Exception, ex, MethodBase.GetCurrentMethod().Name);

                return(new RespuestaListaRol {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Metodo que sirve para Eliminar o Desactivar un objeto de tipo Sesion
        /// </summary>
        /// <param name="pSesion"></param>
        /// <returns></returns>
        public RespuestaSesion EliminarSesion(Sesion pSesion)
        {
            var respuesta = new RespuestaSesion();

            try
            {
                string        CodigoAlerta = "SesionDelete";
                List <string> mensajes     = new List <string>();


                //VALIDACION: Entidad no puede venir vacio
                if (ValidacionesEliminar(pSesion, ref mensajes))
                {
                    //CONSULTA A ACCESO A DATOS
                    respuesta = dal.EliminarSesion(pSesion);
                    //LnBitacoraAuditoria.RegistrarBitacora(respuesta, pSesion, ACCIONES.BORRAR);
                    Notificacion(pSesion, CodigoAlerta);
                }
                else
                {
                    //NO COMPLETA LA VALIDACION, SE ENVIAN DE REGRESO LOS MENSAJES
                    new RespuestaSesion {
                        Respuesta = new Respuesta(Respuesta.CodNoValido), Sesion = respuesta.Sesion
                    };
                }
                return(respuesta);
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pSesion);
                return(new RespuestaSesion {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Metodo que sirve para Obtener la lista de tipo Catalogo
        /// </summary>
        /// <param name="pCatalogo">Filtro de tipo Catalogo</param>
        /// <returns></returns>
        public RespuestaListaCatalogo ObtenerListaCatalogo(Catalogo pCatalogo)
        {
            var respuesta = new RespuestaListaCatalogo();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pCatalogo.UsrtokensAuthenticate
                });
                pCatalogo.IdEntidad = respS.Sesion.IdEntidad;
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    respuesta = dal.ObtenerCatalogos(pCatalogo);
                    return(respuesta);
                }
                else
                {
                    return new RespuestaListaCatalogo {
                               Respuesta = respS.Respuesta, ListaCatalogo = new List <Catalogo>()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pCatalogo);

                BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.ErrorExcepcion,
                                                         TraceData.Utilities.Enums.TypeTrace.Exception, ex, MethodBase.GetCurrentMethod().Name);

                return(new RespuestaListaCatalogo {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Metodo que sirve para Modificar un objeto de tipo Usuario
        /// </summary>
        /// <param name="pUsuario"></param>
        /// <returns></returns>
        public RespuestaUsuario ModificarUsuario(Usuario pUsuario)
        {
            var respuesta = new RespuestaUsuario();

            try
            {
                string        CodigoAlerta = "UsuarioEdit";
                List <string> mensajes     = new List <string>();

                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pUsuario.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    //VALIDACION: Entidad no puede venir vacio
                    pUsuario.UsrModificacion = respS.Sesion.CodigoUsuario;

                    if (ValidacionesModificacion(pUsuario, ref mensajes))
                    {
                        //obtenemos los roles del usuario
                        pUsuario.XMLData = Util.SerializarObjeto(pUsuario.Roles);

                        respuesta = dal.ModificarUsuario(pUsuario);
                        BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.RespuestaModificar,
                                                                 TraceData.Utilities.Enums.TypeTrace.Info, respuesta, MethodBase.GetCurrentMethod().Name);
                        Notificacion(pUsuario, CodigoAlerta);
                    }
                    else
                    {
                        //NO COMPLETA LA VALIDACION, SE ENVIAN DE REGRESO LOS MENSAJES
                        respuesta = new RespuestaUsuario {
                            Respuesta = new Respuesta(Respuesta.CodNoValido), Usuario = respuesta.Usuario
                        };
                    }
                    return(respuesta);
                }
                else
                {
                    return new RespuestaUsuario {
                               Respuesta = respS.Respuesta, Usuario = new Usuario()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pUsuario);

                BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.ErrorExcepcion,
                                                         TraceData.Utilities.Enums.TypeTrace.Exception, ex, MethodBase.GetCurrentMethod().Name);

                return(new RespuestaUsuario {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Metodo que sirve para Eliminar o Desactivar un objeto de tipo AlertaEntidad
        /// </summary>
        /// <param name="pAlertaEntidad"></param>
        /// <returns></returns>
        public RespuestaAlertaEntidad EliminarAlertaEntidad(AlertaEntidad pAlertaEntidad)
        {
            var respuesta = new RespuestaAlertaEntidad();

            try
            {
                string        CodigoAlerta = "AlertaEntidadDelete";
                List <string> mensajes     = new List <string>();

                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pAlertaEntidad.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    //VALIDACION: Entidad no puede venir vacio
                    pAlertaEntidad.IdEntidad = respS.Sesion.IdEntidad;

                    if (ValidacionesEliminar(pAlertaEntidad, ref mensajes))
                    {
                        //CONSULTA A ACCESO A DATOS
                        respuesta = dal.EliminarAlertaEntidad(pAlertaEntidad);
                        BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.RespuestaEliminar,
                                                                 TraceData.Utilities.Enums.TypeTrace.Info, respuesta, MethodBase.GetCurrentMethod().Name);
                        Notificacion(pAlertaEntidad, CodigoAlerta);
                    }
                    else
                    {
                        //NO COMPLETA LA VALIDACION, SE ENVIAN DE REGRESO LOS MENSAJES
                        respuesta = new RespuestaAlertaEntidad {
                            Respuesta = new Respuesta(Respuesta.CodNoValido), AlertaEntidad = respuesta.AlertaEntidad
                        };
                    }
                    return(respuesta);
                }
                else
                {
                    return new RespuestaAlertaEntidad {
                               Respuesta = respS.Respuesta, AlertaEntidad = new AlertaEntidad()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pAlertaEntidad);

                BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.ErrorExcepcion,
                                                         TraceData.Utilities.Enums.TypeTrace.Exception, ex, MethodBase.GetCurrentMethod().Name);

                return(new RespuestaAlertaEntidad {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Metodo para insertar un valor de tipo AutorizacionDetalle
        /// </summary>
        /// <param name="pAutorizacionDetalle"></param>
        /// <returns></returns>
        public RespuestaAutorizacionDetalle InsertarAutorizacionDetalle(AutorizacionDetalle pAutorizacionDetalle)
        {
            var respuesta = new RespuestaAutorizacionDetalle();

            try
            {
                string        CodigoAlerta = "AutorizacionDetalleCreate";
                List <string> mensajes     = new List <string>();

                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pAutorizacionDetalle.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    pAutorizacionDetalle.UsrCreacion = respS.Sesion.CodigoUsuario;

                    //EJECUTAR: se guarda la entidad
                    if (ValidacionesCreacion(pAutorizacionDetalle, ref mensajes))
                    {
                        respuesta = dal.InsertarAutorizacionDetalle(pAutorizacionDetalle);
                        BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.RespuestaInsertar,
                                                                 TraceData.Utilities.Enums.TypeTrace.Info, respuesta, MethodBase.GetCurrentMethod().Name);
                        Notificacion(pAutorizacionDetalle, CodigoAlerta);
                    }
                    else
                    {
                        //NO COMPLETA LA VALIDACION, SE ENVIAN DE REGRESO LOS MENSAJES
                        respuesta = new RespuestaAutorizacionDetalle {
                            Respuesta = new Respuesta(Respuesta.CodNoValido), AutorizacionDetalle = respuesta.AutorizacionDetalle
                        };
                    }
                    return(respuesta);
                }
                else
                {
                    return new RespuestaAutorizacionDetalle {
                               Respuesta = respS.Respuesta, AutorizacionDetalle = new AutorizacionDetalle()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pAutorizacionDetalle);

                BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.ErrorExcepcion,
                                                         TraceData.Utilities.Enums.TypeTrace.Exception, ex, MethodBase.GetCurrentMethod().Name);

                return(new RespuestaAutorizacionDetalle {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Método que procesa la siguiente autorizacion
        /// </summary>
        /// <param name="pAutorizacion"></param>
        /// <returns></returns>
        public RespuestaAutorizacion ProcesarAutorizacion(Autorizacion pAutorizacion)
        {
            var respuesta = new RespuestaAutorizacion();

            try
            {
                //string CodigoAlerta = "ValidarAutorizacionCreate";
                List <string> mensajes = new List <string>();

                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pAutorizacion.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    pAutorizacion.UsrCreacion = respS.Sesion.CodigoUsuario;

                    //EJECUTAR: se guarda la entidad

                    respuesta = dal.ProcesarAutorizacion(pAutorizacion);
                    BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.RespuestaValidacion,
                                                             TraceData.Utilities.Enums.TypeTrace.Info, respuesta, MethodBase.GetCurrentMethod().Name);

                    if (respuesta.Respuesta.CodMensaje == Respuesta.CodExitoso)
                    {
                        //se envia la notificacion segun corresponda
                        Task.Factory.StartNew(() => Notificacion(pAutorizacion));
                    }
                    return(respuesta);
                }
                else
                {
                    return new RespuestaAutorizacion {
                               Respuesta = respS.Respuesta, Autorizacion = new Autorizacion()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pAutorizacion);

                BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.ErrorExcepcion,
                                                         TraceData.Utilities.Enums.TypeTrace.Exception, ex, MethodBase.GetCurrentMethod().Name);

                return(new RespuestaAutorizacion {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Metodo que sirve para Eliminar o Desactivar un objeto de tipo CuentaEmail
        /// </summary>
        /// <param name="pCuentaEmail"></param>
        /// <returns></returns>
        public RespuestaCuentaEmail EliminarCuentaEmail(CuentaEmail pCuentaEmail)
        {
            var respuesta = new RespuestaCuentaEmail();

            try
            {
                string        CodigoAlerta = "CuentaEmailDelete";
                List <string> mensajes     = new List <string>();

                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pCuentaEmail.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    pCuentaEmail.IdEntidad = respS.Sesion.IdEntidad;

                    //VALIDACION: Entidad no puede venir vacio
                    if (ValidacionesEliminar(pCuentaEmail, ref mensajes))
                    {
                        //CONSULTA A ACCESO A DATOS
                        respuesta = dal.EliminarCuentaEmail(pCuentaEmail);
                        //LnBitacoraAuditoria.RegistrarBitacora(respuesta, pCuentaEmail, ACCIONES.BORRAR);
                        Notificacion(pCuentaEmail, CodigoAlerta);
                    }
                    else
                    {
                        //NO COMPLETA LA VALIDACION, SE ENVIAN DE REGRESO LOS MENSAJES
                        return(new RespuestaCuentaEmail {
                            Respuesta = new Respuesta(Respuesta.CodNoValido), CuentaEmail = respuesta.CuentaEmail
                        });
                    }
                    return(respuesta);
                }
                else
                {
                    return new RespuestaCuentaEmail {
                               Respuesta = respS.Respuesta, CuentaEmail = new CuentaEmail()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pCuentaEmail);
                return(new RespuestaCuentaEmail {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Metodo para insertar un valor de tipo CuentaEmail
        /// </summary>
        /// <param name="pCuentaEmail"></param>
        /// <returns></returns>
        public RespuestaCuentaEmail InsertarCuentaEmail(CuentaEmail pCuentaEmail)
        {
            var respuesta = new RespuestaCuentaEmail();

            try
            {
                string        CodigoAlerta = "CuentaEmailCreate";
                List <string> mensajes     = new List <string>();

                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pCuentaEmail.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    pCuentaEmail.UsrCreacion = respS.Sesion.CodigoUsuario;
                    pCuentaEmail.IdEntidad   = respS.Sesion.IdEntidad;
                    //EJECUTAR: se guarda la entidad
                    if (ValidacionesCreacion(pCuentaEmail, ref mensajes))
                    {
                        respuesta = dal.InsertarCuentaEmail(pCuentaEmail);
                        //LnBitacoraAuditoria.RegistrarBitacora(respuesta, pCuentaEmail, ACCIONES.AGREGAR);
                        Notificacion(pCuentaEmail, CodigoAlerta);
                    }
                    else
                    {
                        //NO COMPLETA LA VALIDACION, SE ENVIAN DE REGRESO LOS MENSAJES
                        return(new RespuestaCuentaEmail {
                            Respuesta = new Respuesta(Respuesta.CodNoValido), CuentaEmail = respuesta.CuentaEmail
                        });
                    }
                    return(respuesta);
                }
                else
                {
                    return new RespuestaCuentaEmail {
                               Respuesta = respS.Respuesta, CuentaEmail = new CuentaEmail()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pCuentaEmail);
                return(new RespuestaCuentaEmail {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Metodo que sirve para Modificar un objeto de tipo Perfil
        /// </summary>
        /// <param name="pPerfil"></param>
        /// <returns></returns>
        public RespuestaPerfil ModificarPerfil(Perfil pPerfil)
        {
            var respuesta = new RespuestaPerfil();

            try
            {
                string        CodigoAlerta = "PerfilEdit";
                List <string> mensajes     = new List <string>();

                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pPerfil.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    //VALIDACION: Entidad no puede venir vacio
                    pPerfil.UsrModificacion = respS.Sesion.CodigoUsuario;

                    if (ValidacionesModificacion(pPerfil, ref mensajes))
                    {
                        respuesta = dal.ModificarPerfil(pPerfil);
                        //LnBitacoraAuditoria.RegistrarBitacora(respuesta, pPerfil, ACCIONES.MODIFICAR);
                        Notificacion(pPerfil, CodigoAlerta);
                    }
                    else
                    {
                        //NO COMPLETA LA VALIDACION, SE ENVIAN DE REGRESO LOS MENSAJES
                        respuesta = new RespuestaPerfil {
                            Respuesta = new Respuesta(Respuesta.CodNoValido), Perfil = respuesta.Perfil
                        };
                    }
                    return(respuesta);
                }
                else
                {
                    return new RespuestaPerfil {
                               Respuesta = respS.Respuesta, Perfil = new Perfil()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pPerfil);
                return(new RespuestaPerfil {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Inserta informacion en la tabla Sesion
        /// </summary>
        /// <param name="pSesion"></param>
        /// <returns></returns>
        public RespuestaSesion InsertarSesion(Sesion pSesion)
        {
            int filasAfectadas;

            RespuestaSesion respuesta = new RespuestaSesion();

            respuesta.Sesion = new Sesion();

            //STRORE PROCEDURE DEFINITION
            DbCommand dbCommand = database1.GetStoredProcCommand(defaultSchema + StoredProcedure.InsertarSesion);

            //IN PARAMETERS

            database1.AddInParameter(dbCommand, parameterName(Sesion.idEntidadProperty), DbType.Int64, pSesion.IdEntidad);
            database1.AddInParameter(dbCommand, parameterName(Sesion.codigoUsuarioProperty), DbType.String, pSesion.CodigoUsuario);
            database1.AddInParameter(dbCommand, parameterName(Sesion.tokenProperty), DbType.AnsiString, pSesion.Token);
            database1.AddInParameter(dbCommand, parameterName(Sesion.ipProperty), DbType.AnsiString, pSesion.Ip);
            database1.AddInParameter(dbCommand, parameterName(Sesion.numCelularProperty), DbType.AnsiString, pSesion.NumCelular);
            database1.AddInParameter(dbCommand, parameterName(Sesion.ubicacionProperty), DbType.AnsiString, pSesion.Ubicacion);
            database1.AddInParameter(dbCommand, parameterName(Sesion.ambienteProperty), DbType.AnsiString, pSesion.Ambiente);

            //OUT PARAMETERS

            database1.AddOutParameter(dbCommand, parameterName(Sesion.idSesionProperty), DbType.Int64, 32);
            database1.AddOutParameter(dbCommand, parameterName(BaseEntidad.codErrorProperty), DbType.String, 2);
            database1.AddOutParameter(dbCommand, parameterName(BaseEntidad.mensajeProperty), DbType.String, 200);

            //EXECUTE PROCEDURE
            filasAfectadas = database1.ExecuteNonQuery(dbCommand);

            //ERROR CODE AND MESSAGE COLLECTOR

            pSesion.IdSesion               = DBHelper.ReadNullSafeInt(database1.GetParameterValue(dbCommand, parameterName(Sesion.idSesionProperty)));
            respuesta.Sesion               = pSesion;
            respuesta.Respuesta            = new Respuesta();
            respuesta.Respuesta.CodMensaje = DBHelper.ReadNullSafeString(database1.GetParameterValue(dbCommand, parameterName(BaseEntidad.codErrorProperty)));
            respuesta.Respuesta.Mensaje    = DBHelper.ReadNullSafeString(database1.GetParameterValue(dbCommand, parameterName(BaseEntidad.mensajeProperty)));

            if (respuesta.Respuesta.CodMensaje == Respuesta.CodExitoso)
            {
                respuesta.Respuesta = new Respuesta(Mensajes.bmCreateSesion, respuesta.Respuesta.CodMensaje);
            }

            return(respuesta);
        }
Exemplo n.º 20
0
        public string GenerarToken(string usuario)
        {
            try
            {
                //Genera token

                string bufer     = "USUARIO=" + usuario + ";Time=" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string token     = Convert.ToBase64String(Encriptacion.Encriptar(bufer, usuario));
                string nombre    = string.Empty;
                string correo    = string.Empty;
                string extension = string.Empty;

                //Busca informacion de usuario
                IDAOUsuario iDaoUsuario = new DAOUsuario();
                RespuestaBD resp        = iDaoUsuario.ObtenerListaUsuarios(null, usuario);
                if (!resp.EXISTE_ERROR)
                {
                    if (resp.dataSet.Tables[0].Rows.Count > 0)
                    {
                        DataRow r = resp.dataSet.Tables[0].Rows[0];

                        nombre    = (string)r["fc_nombre"] + " " + (string)r["fc_apellido_p"] + " " + (string)r["fc_apellido_m"];
                        correo    = (string)r["fc_correo"];
                        extension = (string)r["fc_extension_usuario"];
                    }
                }

                string cadRespuesta = nombre + ";" + correo + ";" + extension + ";" + usuario + ";" + token;

                RespuestaSesion respuestaSesion = new RespuestaSesion();
                IDAOSistema     iDaoSistema     = new DAOSistema();
                resp = iDaoSistema.RegistrarToken(token, DateTime.Now.AddMinutes(15), usuario);

                if (resp.EXISTE_ERROR)
                {
                    throw new Exception("No es posible registrar el Token");
                }
                return(Convert.ToBase64String(Encriptacion.Encriptar(cadRespuesta)));//Retorna cadena encriptada
            }
            catch (Exception ex)
            {
                throw new Exception(new Util().ObtenerMsjExcepcion(ex));
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Metodo que sirve para Obtener la lista de tipo AlertaEntidad
        /// </summary>
        /// <param name="pAlertaEntidad">Filtro de tipo AlertaEntidad</param>
        /// <returns></returns>
        public RespuestaAlertaEntidad ObtenerAlertaEntidad(AlertaEntidad pAlertaEntidad)
        {
            var respuesta = new RespuestaAlertaEntidad();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pAlertaEntidad.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    pAlertaEntidad.IdEntidad = respS.Sesion.IdEntidad;

                    respuesta.AlertaEntidad = dal.ObtenerAlertaEntidad(pAlertaEntidad).ListaAlertaEntidad?[0];
                    return(respuesta.AlertaEntidad != null ?
                           new RespuestaAlertaEntidad {
                        Respuesta = new Respuesta(string.Empty, Respuesta.CodExitoso), AlertaEntidad = respuesta.AlertaEntidad
                    } :
                           new RespuestaAlertaEntidad {
                        Respuesta = new Respuesta(Respuestas.GI03, Respuesta.CodExitoso), AlertaEntidad = new AlertaEntidad()
                    });
                }
                else
                {
                    return new RespuestaAlertaEntidad {
                               Respuesta = respS.Respuesta, AlertaEntidad = new AlertaEntidad()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pAlertaEntidad);

                BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.ErrorExcepcion,
                                                         TraceData.Utilities.Enums.TypeTrace.Exception, ex, MethodBase.GetCurrentMethod().Name);

                return(new RespuestaAlertaEntidad {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Metodo que sirve para Obtener la lista de tipo Bitacora
        /// </summary>
        /// <param name="pBitacora">Filtro de tipo Bitacora</param>
        /// <returns></returns>
        public RespuestaBitacoraAplicacion ObtenerBitacora(BitacoraAplicacion pBitacora)
        {
            var respuesta = new RespuestaBitacoraAplicacion();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pBitacora.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    respuesta.Bitacora = dal.ObtenerBitacora(pBitacora).ListaBitacora?[0];

                    return(respuesta.Bitacora != null ?
                           new RespuestaBitacoraAplicacion {
                        Respuesta = new Respuesta(string.Empty, Respuesta.CodExitoso), Bitacora = respuesta.Bitacora
                    } :
                           new RespuestaBitacoraAplicacion {
                        Respuesta = new Respuesta(Respuestas.GI03, Respuesta.CodExitoso), Bitacora = new BitacoraAplicacion()
                    });
                }
                else
                {
                    return new RespuestaBitacoraAplicacion {
                               Respuesta = respS.Respuesta, Bitacora = new BitacoraAplicacion()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pBitacora);

                BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.ErrorExcepcion,
                                                         TraceData.Utilities.Enums.TypeTrace.Exception, ex, MethodBase.GetCurrentMethod().Name);

                return(new RespuestaBitacoraAplicacion {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Metodo para insertar un valor de tipo Sesion
        /// </summary>
        /// <param name="pSesion"></param>
        /// <returns></returns>
        public RespuestaSesion InsertarSesion(Sesion pSesion)
        {
            var respuesta = new RespuestaSesion();

            try
            {
                string        CodigoAlerta = "SesionCreate";
                List <string> mensajes     = new List <string>();

                //creamos el token de la sesion
                string input = pSesion.IdEntidad + "-" + pSesion.CodigoUsuario + DateTime.Now.ToString();
                pSesion.Token = hexaNotation.StringAHexa(input);

                //EJECUTAR: se guarda la entidad
                if (ValidacionesCreacion(pSesion, ref mensajes))
                {
                    respuesta = dal.InsertarSesion(pSesion);
                    //LnBitacoraAuditoria.RegistrarBitacora(respuesta, pSesion, ACCIONES.AGREGAR);
                    Notificacion(pSesion, CodigoAlerta);
                }
                else
                {
                    //NO COMPLETA LA VALIDACION, SE ENVIAN DE REGRESO LOS MENSAJES
                    respuesta = new RespuestaSesion {
                        Respuesta = new Respuesta(Respuesta.CodNoValido), Sesion = respuesta.Sesion
                    };
                }
                return(respuesta);
                //
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pSesion);
                return(new RespuestaSesion {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Metodo que sirve para Obtener la lista de tipo CuentaEmail
        /// </summary>
        /// <param name="pCuentaEmail">Filtro de tipo CuentaEmail</param>
        /// <returns></returns>
        public RespuestaCuentaEmail ObtenerCuentaEmail(CuentaEmail pCuentaEmail)
        {
            var respuesta = new RespuestaCuentaEmail();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pCuentaEmail.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    pCuentaEmail.IdEntidad = respS.Sesion.IdEntidad;

                    respuesta.CuentaEmail = dal.ObtenerCuentaEmail(pCuentaEmail).ListaCuentaEmail?[0];
                    return(respuesta.CuentaEmail != null ?
                           new RespuestaCuentaEmail {
                        Respuesta = new Respuesta(string.Empty, Respuesta.CodExitoso), CuentaEmail = respuesta.CuentaEmail
                    } :
                           new RespuestaCuentaEmail {
                        Respuesta = new Respuesta(Respuestas.GI03, Respuesta.CodExitoso), CuentaEmail = new CuentaEmail()
                    });
                }
                else
                {
                    return new RespuestaCuentaEmail {
                               Respuesta = respS.Respuesta, CuentaEmail = new CuentaEmail()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pCuentaEmail);
                return(new RespuestaCuentaEmail {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Metodo que sirve para Obtener la lista de tipo Sesion
        /// </summary>
        /// <param name="pSesion">Filtro de tipo Sesion</param>
        /// <returns></returns>
        public RespuestaSesion ObtenerSesion(Sesion pSesion)
        {
            var respuesta = new RespuestaSesion();

            try
            {
                respuesta.Sesion = dal.ObtenerSesion(pSesion).ListaSesion?[0];
                return(respuesta.Sesion != null ?
                       new RespuestaSesion {
                    Respuesta = new Respuesta(string.Empty, Respuesta.CodExitoso), Sesion = respuesta.Sesion
                } :
                       new RespuestaSesion {
                    Respuesta = new Respuesta(Respuestas.GI03, Respuesta.CodExitoso), Sesion = new Sesion()
                });
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pSesion);
                return(new RespuestaSesion {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Metodo que sirve para Obtener la lista de tipo Pais
        /// </summary>
        /// <param name="pPais">Filtro de tipo Pais</param>
        /// <returns></returns>
        public RespuestaPais ObtenerPais(Pais pPais)
        {
            var respuesta = new RespuestaPais();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pPais.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    respuesta.Pais = dal.ObtenerPais(pPais).ListaPais?[0];

                    return(respuesta.Pais != null ?
                           new RespuestaPais {
                        Respuesta = new Respuesta(string.Empty, Respuesta.CodExitoso), Pais = respuesta.Pais
                    } :
                           new RespuestaPais {
                        Respuesta = new Respuesta(Respuestas.GI03, Respuesta.CodExitoso), Pais = new Pais()
                    });
                }
                else
                {
                    return new RespuestaPais {
                               Respuesta = respS.Respuesta, Pais = new Pais()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pPais);
                return(new RespuestaPais {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
        /// <summary>
        /// Metodo que sirve para Obtener la lista de tipo TipoIdentificacion
        /// </summary>
        /// <param name="pTipoIdentificacion">Filtro de tipo TipoIdentificacion</param>
        /// <returns></returns>
        public RespuestaTipoIdentificacion ObtenerTipoIdentificacion(TipoIdentificacion pTipoIdentificacion)
        {
            var respuesta = new RespuestaTipoIdentificacion();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pTipoIdentificacion.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    respuesta.TipoIdentificacion = dal.ObtenerTipoIdentificacion(pTipoIdentificacion).ListaTipoIdentificacion?[0];

                    return(respuesta.TipoIdentificacion != null ?
                           new RespuestaTipoIdentificacion {
                        Respuesta = new Respuesta(string.Empty, Respuesta.CodExitoso), TipoIdentificacion = respuesta.TipoIdentificacion
                    } :
                           new RespuestaTipoIdentificacion {
                        Respuesta = new Respuesta(Respuestas.GI03, Respuesta.CodExitoso), TipoIdentificacion = new TipoIdentificacion()
                    });
                }
                else
                {
                    return new RespuestaTipoIdentificacion {
                               Respuesta = respS.Respuesta, TipoIdentificacion = new TipoIdentificacion()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pTipoIdentificacion);
                return(new RespuestaTipoIdentificacion {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Metodo para insertar un valor de tipo Usuario
        /// </summary>
        /// <param name="pUsuario"></param>
        /// <returns></returns>
        public RespuestaUsuario InsertarUsuario(Usuario pUsuario)
        {
            var respuesta = new RespuestaUsuario();

            try
            {
                string        CodigoAlerta = "UsuarioCreate";
                List <string> mensajes     = new List <string>();

                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pUsuario.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    pUsuario.UsrCreacion = respS.Sesion.CodigoUsuario;

                    //**** Contraseña temporal para el nuevo usuario*****
                    //TODO: encriptar contraseña
                    string clave = new LnGenPassword().GetNewPassword();

                    //encriptamos la clave
                    pUsuario.Clave = oEncriptador.Encriptar(clave);

                    //EJECUTAR: se guarda la entidad
                    if (ValidacionesCreacion(pUsuario, ref mensajes))
                    {
                        //se define los datos necesarios para el usuario
                        pUsuario.IdEntidad = respS.Sesion.IdEntidad;

                        //obtenemos los roles del usuario
                        pUsuario.XMLData = Util.SerializarObjeto(pUsuario.Roles);

                        respuesta = dal.InsertarUsuario(pUsuario);
                        BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.RespuestaInsertar,
                                                                 TraceData.Utilities.Enums.TypeTrace.Info, respuesta, MethodBase.GetCurrentMethod().Name);
                        Notificacion(pUsuario, CodigoAlerta);

                        //Se valida error
                        if (respuesta.Respuesta.CodMensaje != Respuesta.CodExitoso)
                        {
                            //se procede a obtener el mensaje del error
                            var oResp = new Respuesta(respuesta.Respuesta.CodMensaje);

                            if (string.IsNullOrEmpty(oResp.Mensaje))
                            {
                                oResp.Mensaje = Mensajes.msjErrorGenerico;
                            }
                            respuesta.Respuesta = oResp;
                            return(respuesta);
                        }

                        //****Se envia a crear la primera autorización***
                        Task.Factory.StartNew(() => InsertarAutorizacion(respuesta.Usuario));
                        //***********************************************
                    }
                    else
                    {
                        //NO COMPLETA LA VALIDACION, SE ENVIAN DE REGRESO LOS MENSAJES
                        respuesta = new RespuestaUsuario {
                            Respuesta = new Respuesta(Respuesta.CodNoValido), Usuario = respuesta.Usuario
                        };
                    }
                    return(respuesta);
                }
                else
                {
                    return new RespuestaUsuario {
                               Respuesta = respS.Respuesta, Usuario = new Usuario()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pUsuario);

                BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.ErrorExcepcion,
                                                         TraceData.Utilities.Enums.TypeTrace.Exception, ex, MethodBase.GetCurrentMethod().Name);

                return(new RespuestaUsuario {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Metodo para insertar un valor de tipo Rol
        /// </summary>
        /// <param name="pRol"></param>
        /// <returns></returns>
        public RespuestaRol InsertarRol(Rol pRol)
        {
            var respuesta = new RespuestaRol();

            try
            {
                string        CodigoAlerta = "RolCreate";
                List <string> mensajes     = new List <string>();

                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pRol.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    pRol.UsrCreacion = respS.Sesion.CodigoUsuario;
                    //EJECUTAR: se guarda la entidad
                    if (ValidacionesCreacion(pRol, ref mensajes))
                    {
                        //obtenemos la lista de roles
                        pRol.XMLData = Util.SerializarObjeto(pRol.Perfiles);

                        respuesta = dal.InsertarRol(pRol);
                        BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.RespuestaInsertar,
                                                                 TraceData.Utilities.Enums.TypeTrace.Info, respuesta, MethodBase.GetCurrentMethod().Name);

                        //Se valida error
                        if (respuesta.Respuesta.CodMensaje != Respuesta.CodExitoso)
                        {
                            //se procede a obtener el mensaje del error
                            var oResp = new Respuesta(respuesta.Respuesta.CodMensaje);

                            if (string.IsNullOrEmpty(oResp.Mensaje))
                            {
                                oResp.Mensaje = Mensajes.msjErrorGenerico;
                            }
                            respuesta.Respuesta = oResp;
                            return(respuesta);
                        }

                        Notificacion(pRol, CodigoAlerta);

                        //****Se envia a crear la primera autorización***
                        Task.Factory.StartNew(() => InsertarAutorizacion(respuesta.Rol));
                        //***********************************************
                    }
                    else
                    {
                        //NO COMPLETA LA VALIDACION, SE ENVIAN DE REGRESO LOS MENSAJES
                        respuesta = new RespuestaRol {
                            Respuesta = new Respuesta(Respuesta.CodNoValido), Rol = respuesta.Rol
                        };
                    }
                    return(respuesta);
                }
                else
                {
                    return new RespuestaRol {
                               Respuesta = respS.Respuesta, Rol = new Rol()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pRol);

                BitacoraLogicaNegocios.RegistrarBitacora(MENSAJES_SISTEMA.ErrorExcepcion,
                                                         TraceData.Utilities.Enums.TypeTrace.Exception, ex, MethodBase.GetCurrentMethod().Name);

                return(new RespuestaRol {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }