예제 #1
0
        private void Bindear()
        {
            if (usuarioCurrent.Id != 0)
            {
                this.txtNombre.Text         = usuarioCurrent.NombreUsuario;
                this.ddlRoles.SelectedValue = usuarioCurrent.Roles[0].Id.ToString();

                RolDto rol = ServiceFactory.GetSecurityService().ObtenerRol(int.Parse(this.ddlRoles.SelectedValue));
                if (rol.Codigo == FacturaElectronica.Ui.Web.Code.Roles.Administrador)
                {
                    this.pnlCientes.Visible = false;
                }
                else
                {
                    this.pnlCientes.Visible = true;
                    if (usuarioCurrent.ClienteId.HasValue)
                    {
                        ClienteDto clienteDto = ServiceFactory.GetClienteService().ObtenerCliente(usuarioCurrent.ClienteId.Value);
                        this.txtRazonSocial.Text = clienteDto.RazonSocial;
                        this.hfClienteId.Value   = clienteDto.Id.ToString();
                    }
                }
            }
            else
            {
                this.pnlCientes.Visible = false;
            }
        }
        private string GenerarPlantillaHtmlDeRol(RolDto <EstructuraFormatoDto> rolPresentacion, IDictionary <string, object> contextosRol, DocumentoInstanciaXbrlDto documentoInstancia)
        {
            var plantillaHtml = "<xbrl-contenedor-formato xbrl:rol-uri=\"{{xbrlRol.Uri}}\" orientacion=\"landscape\" modo-vista-formato=\"{{documentoInstancia.modoVistaFormato}}\">";

            plantillaHtml += "<table class=\"table table-striped b-t b-light\" xbrl:tabla-excel selector=\"td:not(:first-child)\" selector-contenedor-x=\"#contenedorFormatos\" selector-contenedor-y=\"#contenedorFormatos\" tab-index=\"1\" on-space-or-enter-key=\"onSpaceOrEnterKey(evento, x, y)\" on-after-paste=\"onAfterPaste(valorPegado, x, y)\" on-after-range-paste=\"onAfterRangePaste(valorPegado, x, y, ancho, alto)\">";
            plantillaHtml += "<thead><tr><th class=\"th-sortable\" data-toggle=\"class\">Concepto</th>";
            foreach (var idContexto in contextosRol.Keys)
            {
                var descripcionPeriodo = "";
                IDictionary <string, object> periodo = (IDictionary <string, object>)((IDictionary <string, object>)contextosRol[idContexto])["Periodo"];

                if ((int)periodo["Tipo"] == Period.Instante)
                {
                    descripcionPeriodo = (string)periodo["FechaInstante"];
                }
                else
                {
                    descripcionPeriodo = (string)periodo["FechaInicio"] + " - " + (string)periodo["FechaFin"];
                }

                plantillaHtml += "<th style=\"min-width: 130px; width: 130px;\">" + descripcionPeriodo + "</th>";
            }
            plantillaHtml += "</tr></thead><tbody>";

            plantillaHtml += GenerarFragmentoPlantillaDeEstructura(rolPresentacion.Estructuras, contextosRol, documentoInstancia, 0);

            plantillaHtml += "</tbody></table></xbrl-contenedor-formato>";

            return(plantillaHtml);
        }
예제 #3
0
        public async Task <IActionResult> Put(long id, [FromBody] RolDto valueDto)
        {
            var result = new ResultDto <bool>();

            try
            {
                var modelExists = await _rolService.GetByIdAsync(id);

                if (modelExists == null)
                {
                    throw new AwayException("No existe el registro que desea editar.");
                }

                valueDto.Id = modelExists.Id;
                result.Data = await _rolService.UpdateAsync(valueDto);
            }
            catch (AwayException ex)
            {
                _logger.Error(KOriginApp, ex.Message, ex);
                result.AddError(ex.Message);
            }
            catch (Exception ex)
            {
                _logger.Error(KOriginApp, ex.Message, ex);
                result.AddError("Ocurrió un error al intentar editar los datos del registro.");
            }
            return(Ok(result));
        }
        public IHttpActionResult EliminarRol([FromBody] RolDto rol)
        {
            try
            {
                usuariosNegocio = new UsuariosNegocio();
                string res = usuariosNegocio.CreaModificaRol("D", rol);

                return(Content(HttpStatusCode.OK, new Mensaje()
                {
                    codigoRespuesta = Catalogo.OK, mensajeRespuesta = "", objetoRespuesta = res
                }));
            }
            catch (ExcepcionOperacion exOp)
            {
                return(Content(HttpStatusCode.InternalServerError, new Mensaje()
                {
                    codigoRespuesta = Catalogo.ERROR, mensajeRespuesta = Catalogo.FALLO_CONSULTA_MENU + exOp.Message
                }));
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.InternalServerError, new Mensaje()
                {
                    codigoRespuesta = Catalogo.ERROR, mensajeRespuesta = Catalogo.FALLO_CONSULTA_MENU + ex.Message
                }));
            }
        }
예제 #5
0
 protected void ddlRoles_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.ddlRoles.SelectedIndex > 0)
     {
         RolDto rol = ServiceFactory.GetSecurityService().ObtenerRol(int.Parse(this.ddlRoles.SelectedValue));
         this.pnlCientes.Visible = !(rol.Codigo == Roles.Administrador);
     }
 }
예제 #6
0
        private static RolDto ToRolDto(Rol rol)
        {
            RolDto dto = new RolDto();

            dto.Id     = rol.Id;
            dto.Codigo = rol.Codigo;
            dto.Nombre = rol.Nombre;

            return(dto);
        }
예제 #7
0
        protected void cvRazonSocial_ServerValidate(object source, ServerValidateEventArgs args)
        {
            bool   valid = true;
            RolDto rol   = ServiceFactory.GetSecurityService().ObtenerRol(int.Parse(this.ddlRoles.SelectedValue));

            if (rol.Codigo == Roles.Cliente && string.IsNullOrEmpty(this.txtRazonSocial.Text.Trim()))
            {
                valid = false;
            }
            args.IsValid = valid;
        }
예제 #8
0
 public string CreaModificaRol(string trans, RolDto rol)
 {
     using (UnitOfWork uow = new UnitOfWork())
     {
         DataTable tblRol = uow.UsuariosRepositorio.CrudRol(trans, rol);
         if (tblRol.Rows[0]["ID"].ToString() != "1")
         {
             throw new Exception(tblRol.Rows[0]["Mensaje"].ToString());
         }
         return(tblRol.Rows[0]["Mensaje"].ToString());
     }
 }
예제 #9
0
        /*Métodos para pantalla de Rol*/
        #region Rol
        public DataTable CrudRol(string tipoTrans, RolDto rol)
        {
            using (SqlConnection conn = new SqlConnection(Util.ObtenerCadenaConexion("POS_DB")))
            {
                try
                {
                    string     spName = @"[dbo].[prcSegRol]";
                    SqlCommand cmd    = new SqlCommand(spName, conn);

                    SqlParameter transaccion = new SqlParameter("@p_transaccion", SqlDbType.VarChar);
                    transaccion.Value = tipoTrans;
                    SqlParameter idperfil = new SqlParameter("@p_id_rol", SqlDbType.Int);
                    idperfil.Value = rol.id;
                    SqlParameter nombre = new SqlParameter("@p_nombre", SqlDbType.VarChar);
                    nombre.Value = rol.nombre;
                    SqlParameter descripcion = new SqlParameter("@p_descripcion", SqlDbType.VarChar);
                    descripcion.Value = rol.descripcion;
                    SqlParameter idcliente = new SqlParameter("@p_id_cliente", SqlDbType.VarChar);
                    idcliente.Value = rol.idCliente;
                    SqlParameter activo = new SqlParameter("@p_activo", SqlDbType.Int);
                    activo.Value = Convert.ToInt16(rol.activo);
                    SqlParameter usuario = new SqlParameter("@p_usuario", SqlDbType.VarChar);
                    usuario.Value = "POS";

                    cmd.Parameters.Add(transaccion);
                    cmd.Parameters.Add(idperfil);
                    cmd.Parameters.Add(nombre);
                    cmd.Parameters.Add(descripcion);
                    cmd.Parameters.Add(idcliente);
                    cmd.Parameters.Add(activo);
                    cmd.Parameters.Add(usuario);

                    DataTable tblMenu = new DataTable();

                    conn.Open();

                    cmd.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    da.ReturnProviderSpecificTypes = true;
                    da.Fill(tblMenu);
                    da.Dispose();

                    conn.Close();

                    return(tblMenu);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
예제 #10
0
        public static List <RolDto> ConvertToRolDto(this IRolesServicios service, IList <string> roles)
        {
            List <RolDto> _listaRoles = new List <RolDto>();

            foreach (var item in roles)
            {
                var rol = new RolDto();
                rol.Name = item;

                _listaRoles.Add(rol);
            }

            return(_listaRoles);
        }
예제 #11
0
        private void SetData()
        {
            usuarioCurrent.NombreUsuario = this.txtNombre.Text.Trim();
            if (this.pnlPassword.Visible)
            {
                usuarioCurrent.Password = SecurityHelper.CreatePasswordHash(this.txtPassword.Text.Trim(), SecurityHelper.CreateSalt(30));
            }
            usuarioCurrent.Roles = new List <RolDto>();
            RolDto rolDto = new RolDto();

            rolDto.Id = (int)UIHelper.GetIntFromInputCbo(this.ddlRoles);
            usuarioCurrent.Roles.Add(rolDto);
            usuarioCurrent.ClienteId = string.IsNullOrEmpty(this.hfClienteId.Value) ? default(long?) : long.Parse(this.hfClienteId.Value);
        }
예제 #12
0
        public static Rol ToRol(RolDto dto)
        {
            if (dto == null)
            {
                return(null);
            }

            return(new Rol
            {
                Id = dto.Id,
                Nombre = dto.Nombre,
                Activo = dto.Activo
            });
        }
예제 #13
0
        public async Task <IActionResult> Post([FromBody] RolDto valueDto)
        {
            var result = new ResultDto <RolDto>();

            try
            {
                result.Data = await _rolService.CreateAsync(valueDto);
            }
            catch (Exception ex)
            {
                _logger.Error(KOriginApp, ex.Message, ex);
                result.AddError("Ocurrió un error al intentar agregar el registro.");
            }
            return(Ok(result));
        }
예제 #14
0
 public List <RolDto> ConsultarRol()
 {
     using (UnitOfWork uow = new UnitOfWork())
     {
         RolDto        rol     = new RolDto(-1, "", "", -1, true);
         DataTable     tblRol  = uow.UsuariosRepositorio.CrudRol("C", rol);
         List <RolDto> listRol = new List <RolDto>();
         RolDto        RolTemp;
         foreach (DataRow dr in tblRol.Rows)
         {
             RolTemp = new RolDto(dr);
             listRol.Add(RolTemp);
         }
         return(listRol);
     }
 }
예제 #15
0
        public IHttpActionResult ActualizarRol()
        {
            var jsonString = getFormKeyValue("json");
            var dto        = new RolDto();

            JsonConvert.PopulateObject(jsonString, dto);
            var rol = RolService.ObtenerRolPorId(dto.IdRol).InformacionExtra as Rol;

            rol.Nombre      = dto.Nombre;
            rol.Descripcion = dto.Descripcion;


            var resultado = RolService.GuardarRol(rol, IdUsuarioExec);

            return(Ok(resultado));
        }
예제 #16
0
        /// <summary>
        /// Método para consultar un nuevo Rol
        /// </summary>
        /// <returns></returns>
        public static List <RolDto> GetRoles()
        {
            var roles = new List <RolDto>();

            using (DutiesFamilyEntities dataContext = new DutiesFamilyEntities())
            {
                foreach (var item in dataContext.Rol.ToList())
                {
                    var rol = new RolDto();
                    rol.IdRol   = item.IdRol;
                    rol.RolName = item.RolName;
                    roles.Add(rol);
                }
            }
            return(roles);
        }
예제 #17
0
        public async Task <RoleResult> UpdateAsync(RolDto dto)
        {
            var rol = await _roleManager.FindByIdAsync(dto.Id);

            if (rol == null)
            {
                resultError.Errores.Add(new ErrorMsg
                {
                    ErrorCode     = HttpStatusCode.NotFound.ToString(),
                    ErrorMessagge = "No se encontró el Rol"
                });
            }
            else
            {
                rol.Name = dto.Name;
                var result = await _roleManager.UpdateAsync(rol);

                if (result.Succeeded)
                {
                    return(new RoleResult
                    {
                        Errores = null,
                        Succesfull = true,
                        Body = JsonConvert.SerializeObject(
                            new { Http = HttpStatusCode.OK, Mensaje = "Rol Modificado con éxito" })
                    });
                }
                else
                {
                    foreach (var item in result.Errors)
                    {
                        resultError.Errores.Add((ErrorMsg)item);
                    }

                    return(resultError);
                }
            }

            resultError.Errores.Add(new ErrorMsg
            {
                ErrorCode     = HttpStatusCode.BadRequest.ToString(),
                ErrorMessagge = "Ocurrió un error" +
                                "al intentar modificar el  Rol"
            });
            return(resultError);
        }
예제 #18
0
        /// <summary>
        /// Obtiene en forma de lista plana, los conceptos utilizados en un rol de presentación de la taxonomía enviada como parámetro
        /// </summary>
        /// <param name="taxonomia">Taxonomía a evaluar</param>
        /// <param name="uriRolPresentacion">URI del rol o obtener su lista de conceptos utilizados</param>
        /// <returns></returns>
        public static IList <ConceptoDto> ObtenerListaConceptosDeRolPresentacion(TaxonomiaDto taxonomia, String uriRolPresentacion)
        {
            var listaConceptos = new List <ConceptoDto>();

            if (taxonomia != null && taxonomia.RolesPresentacion != null)
            {
                RolDto <EstructuraFormatoDto> rol = taxonomia.RolesPresentacion.FirstOrDefault(x => x.Uri.Equals(uriRolPresentacion));

                if (rol != null)
                {
                    foreach (var estructura in rol.Estructuras)
                    {
                        AgregarNodoEstructura(listaConceptos, estructura, taxonomia);
                    }
                }
            }
            return(listaConceptos);
        }
        private ResultadoOperacionDto GenerarPlantillaDeRol(RolDto <EstructuraFormatoDto> rolPresentacion, DocumentoInstanciaXbrlDto documentoInstancia, IList <string> nombresVariablesPlantilla)
        {
            var resultado = new ResultadoOperacionDto();

            resultado.Resultado = true;

            IDictionary <string, object> hechosRol    = new Dictionary <string, object>();
            IDictionary <string, object> contextosRol = new Dictionary <string, object>();
            IDictionary <string, object> unidadesRol  = new Dictionary <string, object>();

            if (rolPresentacion == null)
            {
                resultado.Resultado = false;
            }
            else
            {
                var EsDimesional = rolPresentacion.EsDimensional != null ? rolPresentacion.EsDimensional.Value : false;

                var resultadoGeneracion = GenerarInformacionHechos(rolPresentacion.Estructuras, EsDimesional, documentoInstancia, hechosRol, contextosRol, unidadesRol, nombresVariablesPlantilla);
                if (resultadoGeneracion.Resultado)
                {
                    string textoDefinicion = File.ReadAllText("PlantillasTs/DefinicionElementos.txt");
                    if (textoDefinicion != null)
                    {
                        var rolUri = rolPresentacion.Uri;
                        var nombreClaseDefiniciones = rolPresentacion.Uri.Replace(":", "_").Replace("/", "_").Replace(".", "_").Replace("-", "_");
                        var definicionContextos     = JsonConvert.SerializeObject(contextosRol, Formatting.Indented);
                        var definicionUnidades      = JsonConvert.SerializeObject(unidadesRol, Formatting.Indented);;
                        var definicionHechos        = JsonConvert.SerializeObject(hechosRol, Formatting.Indented);

                        textoDefinicion = textoDefinicion.Replace("#rolUri", rolUri);
                        textoDefinicion = textoDefinicion.Replace("#nombreClaseDefiniciones", nombreClaseDefiniciones);
                        textoDefinicion = textoDefinicion.Replace("#definicionContextos", definicionContextos);
                        textoDefinicion = textoDefinicion.Replace("#definicionUnidades", definicionUnidades);
                        textoDefinicion = textoDefinicion.Replace("#definicionHechos", definicionHechos);

                        File.WriteAllText(rolPresentacion.Uri.Replace(":", "_").Replace("/", "_") + ".ts", textoDefinicion);
                        File.WriteAllText(rolPresentacion.Uri.Replace(":", "_").Replace("/", "_") + ".html", GenerarPlantillaHtmlDeRol(rolPresentacion, contextosRol, documentoInstancia));
                    }
                }
            }

            return(resultado);
        }
예제 #20
0
        public ActionResult GuardarPerTransporte(RolDto objrol)
        {
            _tok = Session["StringToken"].ToString();

            var respuesta = CatalogoServicio.ActualizaPermisosTransporte(objrol, _tok);

            if (respuesta.Exito)
            {
                TempData["RespuestaDTO"]      = respuesta.Mensaje;
                TempData["RespuestaDTOError"] = null;
                return(RedirectToAction("Index"));
            }

            else
            {
                TempData["RespuestaDTOError"] = respuesta;//.Mensaje;
                return(RedirectToAction("Index"));
            }
        }
예제 #21
0
        public async Task <IActionResult> CrearRol(RolViewModel rol)
        {
            RolDto _rol = new RolDto
            {
                Name = rol.Name
            };

            var rest = await _services.Create(_rol);

            if (rest.Succesfull)
            {
                HttpJsonResModel <RolDto> res = JsonConvert.DeserializeObject <HttpJsonResModel <RolDto> >(rest.Body);
                res.Objeto = _rol;

                return(Ok(res));
            }

            return(BadRequest(rest));
        }
예제 #22
0
        /// <summary>
        /// Método para crear Roles
        /// </summary>
        /// <param name="rol">Rol Dto: Data transfer object para envair un Rol desde la IU</param>
        /// <returns>Retorna <see cref="RoleResult"/>En caso de éxtio o fracaso de la operación.</returns>
        #region Crear Rol
        public async Task <RoleResult> Create(RolDto rol)
        {
            //Mappeamos el RolDto a Rol Entity

            Roles _rol = new Roles
            {
                Name = rol.Name,
            };

            //Creamos el rol y lo insertamos en la base de datos

            var result = await _roleManager.CreateAsync(_rol);

            //Si la operación es exitosa retornamos un RoleResult con un StatusCode.Ok y Un Mensaje

            if (result.Succeeded)
            {
                return new RoleResult
                       {
                           Errores    = null,
                           Body       = JsonConvert.SerializeObject(new { http = HttpStatusCode.OK, Mensaje = "Rol Creado Con éxito" }),
                           Succesfull = true
                       }
            }
            ;


            //De lo contrario creamos un resultado de error
            //Recorremos la lista de errores en result

            foreach (var item in result.Errors)
            {
                //Casteamos de forma implícita a ErrorMsg
                resultError.Errores.Add((ErrorMsg)item);
            }

            //Retornamos el ResultError
            return(resultError);
        }
예제 #23
0
        public async Task <IActionResult> Crear(RolDto dto)
        {
            if (ModelState.IsValid)
            {
                //if (await RoleManager.RoleExistsAsync(dto.Nombre))
                //{
                //    ModelState.AddModelError(string.Empty, "Ya existe un Rol con ese nombre");
                //    return View(dto);
                //}
                var rol = new Rol {
                    Name = dto.Nombre
                };
                var resultado = await RoleManager.CreateAsync(rol);

                if (resultado.Succeeded)
                {
                    return(new AjaxEditSuccessResult());
                }
                AddErrors(resultado);
            }
            return(View(dto));
        }
예제 #24
0
        //Actualizar nombre ROL- funcionalidad --evento Guardar--
        public ActionResult GuardarCambioRol(RolDto rol)
        {
            if (Session["StringToken"] == null)
            {
                return(RedirectToAction("Index", "Home", AutenticacionServicio.InitIndex(new Models.Seguridad.LoginModel())));
            }
            _tok = Session["StringToken"].ToString();

            var respuesta = CatalogoServicio.ActualizaNombreRol(rol, _tok);

            if (respuesta.Exito)
            {
                TempData["RespuestaDTO"]      = respuesta.Mensaje;
                TempData["RespuestaDTOError"] = null;
                return(RedirectToAction("Index"));
            }

            else
            {
                TempData["RespuestaDTOError"] = respuesta;//.Mensaje;
                return(RedirectToAction("Index"));
            }
        }
예제 #25
0
        public ActionResult AgregarNuevoRol(RolDto ObjRol)
        {
            if (Session["StringToken"] == null)
            {
                return(RedirectToAction("Index", "Home", AutenticacionServicio.InitIndex(new Models.Seguridad.LoginModel())));
            }
            _tok = Session["StringToken"].ToString();

            var respuesta = CatalogoServicio.AgregarRoles(ObjRol, _tok);

            if (respuesta.Exito)
            {
                TempData["RespuestaDTO"]      = respuesta.Mensaje;
                TempData["RespuestaDTOError"] = null;
                return(RedirectToAction("Index"));
            }

            else
            {
                TempData["RespuestaDTOError"] = respuesta.Mensaje;
                return(RedirectToAction("Index"));
            }
        }
예제 #26
0
        /// <summary>
        /// Método para eliminar Roles
        /// </summary>
        /// <param name="rol"></param>
        /// <returns>Retorna <see cref="RoleResult"/>En caso de éxito o fracaso de la operación</returns>
        #region Eliminar Rol

        public async Task <RoleResult> Delete(RolDto rol)
        {
            var entity = await _roleManager.FindByNameAsync(rol.Name);



            if (entity == null)
            {
                resultError.Errores.Add(new ErrorMsg {
                    ErrorCode = HttpStatusCode.NotFound.ToString(), ErrorMessagge = "No se encontró el rol"
                });
                return(resultError);
            }
            else
            {
                var result = await _roleManager.DeleteAsync(entity);

                if (result.Succeeded)
                {
                    return new RoleResult
                           {
                               Errores    = null,
                               Succesfull = true,
                               Body       = JsonConvert.SerializeObject(new { Http = HttpStatusCode.OK, Mensaje = "Se eliminó con éxito el Rol" })
                           }
                }
                ;

                foreach (var item in result.Errors)
                {
                    resultError.Errores.Add((ErrorMsg)item);
                }

                return(resultError);
            }
        }
예제 #27
0
 /// <summary>
 /// Método para crear un nuevo Rol
 /// </summary>
 /// <param name="newRol"></param>
 /// <returns></returns>
 public static RolDto CreateRol(RolDto newRol)
 {
     return(newRol);
 }
예제 #28
0
 public async Task <RolDto> Post(RolDto input)
 {
     return(await EntityService.Create(input));
 }
예제 #29
0
 public async Task <RolDto> Put(RolDto input)
 {
     return(await EntityService.Update(input));
 }
예제 #30
0
 /// <summary>
 /// Agrega recursivamente al diccionario final los conceptos de la lista de estructuras
 /// </summary>
 /// <param name="finalList"></param>
 /// <param name="estructuras"></param>
 /// <param name="v"></param>
 private int addConceptsInList(Dictionary <string, object[]> finalList, IList <EstructuraFormatoDto> estructuras, RolDto <EstructuraFormatoDto> currRole, int currentOrder)
 {
     if (estructuras != null)
     {
         foreach (var current in estructuras)
         {
             if (!finalList.ContainsKey(current.IdConcepto))
             {
                 finalList[current.IdConcepto] = new object[] { currRole.Uri, currentOrder.ToString() };
                 currentOrder++;
             }
             currentOrder = addConceptsInList(finalList, current.SubEstructuras, currRole, currentOrder);
         }
     }
     return(currentOrder);
 }