public JsonResult Index(AuditoriaCriteria criteria) { var pageNumber = criteria.NumeroPagina; var pageSize = _parametroService.GetValor <int>(CodigosParametros.PARAMETRO_TAMAÑO_PAGINA_GRILLAS); var result = _repository.Buscar(criteria, (pageNumber - 1) * pageSize, pageSize); var sesionesVista = (from x in result.Data let Fecha = x.Fecha.ToString("o") orderby x.Id select new { x.Id, x.Accion, Fecha, x.Funcionalidad, x.Identificacion, x.IpAddress, x.Mensaje, x.Usuario }); var resultado = new { Data = sesionesVista, TotalRegistros = result.TotalRegistros }; return(Json(resultado, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Obtener la URL de la Imagen /// </summary> /// <param name="htmlHelper"></param> /// <param name="imagen"></param> /// <returns></returns> public static string UrlImagen(this HtmlHelper htmlHelper, string imagen) { IParametroService _parametroService = ServiceLocator.Current.GetInstance <IParametroService>(); var pathImagen = _parametroService.GetValor <string>(CodigosParametros.PARAMETRO_IMAGENES_URL_BASE); return(Path.Combine(pathImagen, imagen)); }
/// <summary> /// Renderizar el nombre de la aplicacion /// </summary> /// <param name="htmlHelper"></param> /// <returns></returns> public static MvcHtmlString RenderNombreAplicacion(this HtmlHelper htmlHelper) { IParametroService _parametroService = ServiceLocator.Current.GetInstance <IParametroService>(); string app = _parametroService.GetValor <string>(CodigosParametros.PARAMETRO_NOMBRE_APLICACION); return(new MvcHtmlString(app)); }
/// <summary> /// Verificar si es necesario recolectar informacion /// </summary> /// <param name="htmlHelper"></param> /// <returns></returns> public static bool RecolectarInformacionAnalisis(this HtmlHelper htmlHelper) { IParametroService _parametroService = ServiceLocator.Current.GetInstance <IParametroService>(); bool result = _parametroService.GetValor <bool>(CodigosParametros.PARAMETRO_RECOLECTAR_INFO_ANALISIS); return(result); }
public JsonResult Index(MenuCriteria catalogoCriteria) { var pageNumber = catalogoCriteria.NumeroPagina < 1 ? 1 : catalogoCriteria.NumeroPagina; var pageSize = _parametroService.GetValor <int>(CodigosParametros.PARAMETRO_TAMAÑO_PAGINA_GRILLAS); var menus = _menuService.GetList() .Where(c => catalogoCriteria.Nombre == null || catalogoCriteria.Nombre.IsEmpty() || c.Nombre.ToLower().Contains(catalogoCriteria.Nombre.ToLower())); var inicio = (pageNumber - 1) * pageSize; var fin = inicio + pageSize > menus.Count() ? menus.Count() - inicio : pageSize; var menusPagina = menus.ToList().GetRange(inicio, fin); var menusVista = (from x in menusPagina let Items = getItems(x.Items) orderby x.Id select new { x.Id, x.Nombre, x.Codigo, x.Descripcion, Items }); var resultado = new { Data = menusVista, TotalRegistros = menus.Count() }; return(Json(resultado, JsonRequestBehavior.AllowGet)); }
public JsonResult Index(ParametroCriteria criteria) { var pageNumber = criteria.NumeroPagina < 1 ? 1 : criteria.NumeroPagina; var pageSize = _iParametroService.GetValor <int>(CodigosParametros.PARAMETRO_TAMAÑO_PAGINA_GRILLAS); var roles = _iRolService.GetList() .Where(c => string.IsNullOrWhiteSpace(criteria.Nombre) || c.Nombre.ToLower().Contains(criteria.Nombre.ToLower())); var inicio = (pageNumber - 1) * pageSize; var fin = inicio + pageSize > roles.Count() ? roles.Count() - inicio : pageSize; var rolesPagina = roles.ToList().GetRange(inicio, fin); var rolesVista = (from x in rolesPagina let Permisos = getPermisos(x.Permisos) orderby x.Nombre select new { x.Id, x.Nombre, x.Codigo, x.EsAdministrador, x.EsExterno, x.Url, x.Parametros, Permisos }); var resultado = new { Data = rolesVista, TotalRegistros = roles.Count() }; return(Json(resultado, JsonRequestBehavior.AllowGet)); }
public JsonResult Index(ParametroCriteria criteria) { var pageNumber = criteria.NumeroPagina < 1 ? 1 : criteria.NumeroPagina; var pageSize = _iParametroService.GetValor <int>(CodigosParametros.PARAMETRO_TAMAÑO_PAGINA_GRILLAS); var parametros = _iParametroService.GetList() .Where(c => string.IsNullOrWhiteSpace(criteria.Nombre) || c.Nombre.ToLower().Contains(criteria.Nombre.ToLower())); var inicio = (pageNumber - 1) * pageSize; var fin = inicio + pageSize > parametros.Count() ? parametros.Count() - inicio : pageSize; var parametrosPagina = parametros.ToList().GetRange(inicio, fin); var parametrosVista = (from x in parametrosPagina let Opciones = getItems(x.Opciones) orderby x.Nombre select new { x.Id, x.Nombre, x.Codigo, x.Descripcion, x.Valor, x.TieneOpciones, x.Tipo, x.EsEditable, x.FechaCreacion, Opciones }); var resultado = new { Data = parametrosVista, TotalRegistros = parametros.Count() }; return(Json(resultado, JsonRequestBehavior.AllowGet)); }
public ActionResult Ayuda() { //string UrlAyuda = FormsAuthentication.DefaultUrl; string UrlAyuda = string.Empty; try { Rol rol = _application.GetCurrentRol(); var parametrosRol = JsonConvert.DeserializeObject <RolParametrosDTO>(rol.Parametros); if (parametrosRol != null) { UrlAyuda = _parametroService.GetValor <string>(parametrosRol.CodParametroUrlAyuda); return(Redirect(UrlAyuda)); } } catch (Exception ex) { var result = ManejadorExcepciones.HandleException(ex); } return(null); }
public JsonResult Index(FuncionalidadCriteria criteria) { var pageNumber = criteria.NumeroPagina < 1 ? 1 : criteria.NumeroPagina; var pageSize = _iParametroService.GetValor <int>(CodigosParametros.PARAMETRO_TAMAÑO_PAGINA_GRILLAS); var funcionalidades = _iFuncionalidadService.GetFuncionalidades() .Where(c => string.IsNullOrWhiteSpace(criteria.Nombre) || c.Nombre.ToLower().Contains(criteria.Nombre.ToLower())); var inicio = (pageNumber - 1) * pageSize; var fin = inicio + pageSize > funcionalidades.Count() ? funcionalidades.Count() - inicio : pageSize; var funcionalidadesPagina = funcionalidades.ToList().GetRange(inicio, fin); var parametrosVista = (from x in funcionalidadesPagina let Acciones = getItems(x.Acciones) let EstadoNombre = x.EstadoId == Estado.Activo? Estado.Activo.ToString():Estado.Inactivo.ToString() orderby x.Nombre select new { x.Id, x.Codigo, x.Nombre, x.Controlador, x.Descripcion, x.EstadoId, EstadoNombre, Acciones }); var resultado = new { Data = parametrosVista, TotalRegistros = funcionalidades.Count() }; return(Json(resultado, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Renderizar el logo de la aplicacion /// </summary> /// <param name="htmlHelper"></param> /// <returns></returns> public static IHtmlString RenderLogoAplicacion(this HtmlHelper htmlHelper) { IParametroService _parametroService = ServiceLocator.Current.GetInstance <IParametroService>(); string logo = _parametroService.GetValor <string>(CodigosParametros.PARAMETRO_APLICACION_LOGO); if (string.IsNullOrWhiteSpace(logo)) { return(new HtmlString(string.Empty)); } string urlLogo = htmlHelper.UrlImagen(logo); var mainAttrs = new Dictionary <string, object>(); mainAttrs.Add("src", urlLogo); mainAttrs.Add("class", "logo"); var img = new FluentTagBuilder("img") .AddAttributes(mainAttrs); return(img); }
public override async Task <UsuarioDto> Create(CrearUsuarioDto input) { //1. Crear Usuario Logger.DebugFormat("1. Set Values "); var user = input.MapTo <Usuario>(); //var user = ObjectMapper.Map<Usuario>(input); user.Estado = EstadoUsuario.Activo; var passwordRandom = GeneratePassword(); //Hash user.Password = new PasswordHasher().HashPassword(passwordRandom); //Para obligar a cambiar el password. user.SetNewPasswordResetCode(); //Roles user.Roles = new Collection <Rol>(); foreach (var nombreRol in input.Roles) { var role = await RoleManager.GetRoleByNameAsync(nombreRol); user.Roles.Add(role); } //Modulos user.Modulos = new Collection <Modulo>(); foreach (var nombre in input.Modulos) { var module = await ModuleManager.GetModuleByIdAsync(nombre); user.Modulos.Add(module); } Logger.DebugFormat("2. Create User"); CheckErrors(await UserManager.CreateAsync(user)); //2. Enviar Correo try { var modelBodyEmail = new NotificacionUsuarioCreado(); modelBodyEmail.PasswordRestCode = user.PasswordResetCode; modelBodyEmail.Nombres = user.NombresCompletos; modelBodyEmail.Usuario = user.Cuenta; modelBodyEmail.Password = passwordRandom; var sistemaURL = ParametroService.GetValor <string>(CodigosParametros.PARAMETRO_SISTEMA_URL); modelBodyEmail.Enlace = string.Format("{0}/{1}", sistemaURL, "Acceso/Ingreso"); Logger.DebugFormat("3. Process Template"); var body = await TemplateEngine.Process(Constantes.TEMPLATE_SEGURIDAD_ENVIO_CORREO_CREACION_USUARIO, modelBodyEmail); var msg = new IdentityMessage(); msg.Destination = user.Correo; msg.Subject = "Creación de Usuario"; msg.Body = body; Logger.DebugFormat("4. Send Email"); await EmailService.SendAsync(msg); } catch (Exception ex) { var result = ManejadorExcepciones.HandleException(ex); } Logger.DebugFormat("5. Return User"); return(MapToEntityDto(user)); }
public int getPageSize() { var pageSize = _parametroService.GetValor <int>(CodigosParametros.PARAMETRO_TAMAÑO_PAGINA_GRILLAS); return(pageSize); }
/// <summary> /// Generic Index /// </summary> /// <param name="msg"></param> /// <param name="TipoMensaje"></param> /// <returns></returns> public virtual ActionResult Index(string msg, TipoMensaje?TipoMensaje) { //1. Model var model = new TreeModelView(); if (!string.IsNullOrEmpty(Title)) { model.Title = Title; } var filters = AddFilter(new List <FilterEntity>()); //2. Get View var view = GetViewTree(); var treeView = view.Layout as Tree; model.View = treeView; //3. Get Data if (ApplyPagination) { var pageNumber = 1; var pageSize = ParametroService.GetValor <int>(CodigosParametros.PARAMETRO_TAMAÑO_PAGINA_GRILLAS); IPagedListMetaData <Entity> result; if (string.IsNullOrWhiteSpace(treeView.DefaultOrder)) { result = EntityService.GetList(filters, (pageNumber - 1) * pageSize, pageSize); } else { result = EntityService.GetList(filters, (pageNumber - 1) * pageSize, pageSize, treeView.DefaultOrder); } model.Model = result.Subset as IEnumerable <IEntity>; model.PagedListMetaData = new PagedListMetaDataModel(pageNumber, pageSize, result.TotalResultSetCount); } else { if (string.IsNullOrWhiteSpace(treeView.DefaultOrder)) { model.Model = EntityService.GetList(filters) as IEnumerable <IEntity>; } else { model.Model = EntityService.GetList(filters, treeView.DefaultOrder) as IEnumerable <IEntity>; } } //4. View Search if (ApplySearch) { var searchView = GetViewSearch(); //TODO: de la misma forma que formview, se puede generar metadatos.. //Ejemplo si el filtro es un entidad.. (Visualizar el listado de esa entidad) //Si el campo... enum. (Crear un combo con las opciones posibles) // //model.MetadataSearchView = GenerateMetadataView.Generate(searchView, view.ModelType); //var searchView = view.Layout as Search; //view.Name model.SearchView = searchView; } //5. Message model.Mensaje = new MensajeHelper(); if (TipoMensaje.HasValue) { model.Mensaje.Texto = msg; model.Mensaje.Tipo = TipoMensaje.Value; } // Order model.OrderBy = treeView.DefaultOrder; ////5. Pagination //if (ApplyPagination) //{ // model.PagedListMetaData = new PagedListMetaDataModel(); //} return(View(model)); }