private GridFilterModel GetGridFilter(string filterName) { var wheres = new List <SqlWhere>(); wheres.Add(new SqlWhere(null, null, "GridFilter", "Name", filterName, null, SqlWhereComparison.SqlComparer.Equal, SqlWhereAndOrOptions.SqlWhereAndOr.And)); wheres.Add(new SqlWhere(null, null, "GridFilter", "PageName_Key", _page.PageKey(Session["ModelType"].GetType().Name.Replace("Model", "")), null, SqlWhereComparison.SqlComparer.Equal, SqlWhereAndOrOptions.SqlWhereAndOr.And)); GridFilterModel gridFilter = _coreService.LoadModel <GridFilterModel>(wheres, conName: Session["ConString"].ToString()).FirstOrDefault(); return(gridFilter); }
public ActionResult LoadFilter(string filter) { ClearFilter(); GridFilterModel gridFilter = GetGridFilter(filter); IEnumerable <GridFilterWhereModel> filterWheres = GetGridFilterWheres(gridFilter.GridFilter_Key); filterlist.AddRange(filterWheres); createDisplayList(gridFilter.GridFilter_Key); HttpRuntime.Cache["FilterList"] = displaylist; return(Json("", JsonRequestBehavior.AllowGet)); }
public ActionResult RemoveFilter(string filterName) { string db = Session["ConString"].ToString(); GridFilterModel gridFilter = GetGridFilter(filterName); IEnumerable <GridFilterWhereModel> filterWheres = GetGridFilterWheres(gridFilter.GridFilter_Key); foreach (var model in filterWheres) { _coreService.SprocDelete(model, db); } _coreService.SprocDelete(gridFilter, db); return(Json("", JsonRequestBehavior.AllowGet)); }
public ActionResult SaveReportFilter(string filterName) { string db = Session["ConString"].ToString(); bool filterExists = false; GridFilterModel gridFilter = GetGridFilter(filterName); if (gridFilter == null) { gridFilter = new GridFilterModel { PageName_Key = _page.PageKey(Session["ModelType"].GetType().Name.Replace("Model", "")), Name = filterName, CreatedByUser_Key = (int)Session["CurrentUserKey"], UpdatedByUser_Key = (int)Session["CurrentUserKey"], Tenant_Key = (int)Session["CurrentTenantKey"] }; _coreService.SprocInsert(gridFilter, db); gridFilter = GetGridFilter(filterName); } else { filterExists = true; gridFilter.UpdatedByUser_Key = (int)Session["CurrentUserKey"]; _coreService.SprocUpdate(gridFilter, db); } createFilterList(gridFilter.GridFilter_Key); if (filterExists) { IEnumerable <GridFilterWhereModel> filterWheres = GetGridFilterWheres(gridFilter.GridFilter_Key); if (filterWheres.Count() > 0) { foreach (var row in filterWheres) { _coreService.SprocDelete(row, db); } } } foreach (var row in filterlist) { _coreService.SprocInsert(row, db); } return(Json(filterName)); }
public ActionResult SaveValidation(string filterName) { GridFilterModel gridFilter = GetGridFilter(filterName); if (gridFilter != null) { IEnumerable <GridFilterWhereModel> filterWheres = GetGridFilterWheres(gridFilter.GridFilter_Key); if (filterWheres.Count() > 0) { return(Json(filterName + " exists and has data, do you want to overwrite?", JsonRequestBehavior.AllowGet)); } else { return(Json(filterName + " exists, do you want to overwrite?", JsonRequestBehavior.AllowGet)); } } else { SaveReportFilter(filterName); } return(Json("saved", JsonRequestBehavior.AllowGet)); }
public GridAuditoriaModel GetAll(GridFilterModel filtros, string UserName = null, string Entity = null, string Action = null, string Description = null) { var model = new GridAuditoriaModel { AuditoriaList = new List <AuditoriaModel>() }; try { var query = _uow.AuditoriaRepository.All().OrderByDescending(x => x.Date).AsQueryable(); //Filtros if (!String.IsNullOrWhiteSpace(UserName)) { query = query.Where(x => x.UserName.ToLower().Contains(UserName.ToLower())); } if (!String.IsNullOrWhiteSpace(Entity)) { query = query.Where(x => x.Entity.ToLower().Contains(Entity.ToLower())); } if (!String.IsNullOrWhiteSpace(Action)) { query = query.Where(x => x.Action.ToLower().Contains(Action.ToLower())); } if (!String.IsNullOrWhiteSpace(Description)) { query = query.Where(x => x.Descripcion.ToLower().Contains(Description.ToLower())); } if (!String.IsNullOrWhiteSpace(filtros.fechaDesde)) { var dateSplit = filtros.fechaDesde.Split(" ")[0].Split("/"); DateTime dateFromFilter = new DateTime(int.Parse(dateSplit[2]), int.Parse(dateSplit[1]), int.Parse(dateSplit[0]), 0, 0, 0); query = query.Where(x => x.Date >= dateFromFilter); } if (!String.IsNullOrWhiteSpace(filtros.fechaHasta)) { var dateSplit = filtros.fechaHasta.Split(" ")[0].Split("/"); DateTime dateToFilter = new DateTime(int.Parse(dateSplit[2]), int.Parse(dateSplit[1]), int.Parse(dateSplit[0]), 23, 59, 0); query = query.Where(x => x.Date <= dateToFilter); } if (!String.IsNullOrWhiteSpace(Action)) { query = query.Where(x => x.Action.ToLower().Contains(Action.ToLower())); } //----- var totalRows = query.Count(); query = query.Skip((filtros.page - 1 ?? 0) * (filtros.rows ?? filtros.rowPerPages)).Take(filtros.rows ?? filtros.rowPerPages); model.TotalRows = totalRows; var listado = query.OrderByDescending(x => x.Date) .Select(x => new AuditoriaModel() { AuditoriaId = x.AuditoriaId, TransactionId = x.TransactionId, Fecha = x.Date, UserName = x.UserName, Entity = x.Entity, EntityId = x.EntityId, Action = x.Action, Descripcion = x.Descripcion }).OrderByDescending(x => x.Fecha).ToList(); model.AuditoriaList = listado; return(model); } catch (Exception ex) { _logger.LogErrorException(ex, "Ocurrió un problema al intentar obtener lista completa de Auditoría"); return(new GridAuditoriaModel()); } }