Пример #1
0
        public virtual JsonResult List(long count, int page, int rows, AuditSearchFiltersViewModel searchFilters)
        {
            page--;
            var query = GetQuery(searchFilters);
            var respuesta = new PaginableResponse();
            query = query.OrderBy(x => x.Fecha).Desc;

            var queryCount = query.ToRowCountInt64Query().FutureValue<long>();
            respuesta.Records = queryCount.Value;
            respuesta.Rows = query.Take(rows).Skip(page * rows).Future();

            respuesta.Page = ++page;
            respuesta.Total = (long)Math.Ceiling(respuesta.Records / (double)rows);
            return Json(respuesta);
        }
Пример #2
0
        private IQueryOver<AuditLog, AuditLog> GetQuery(AuditSearchFiltersViewModel searchFilters)
        {
            var session = SessionFactory.GetCurrentSession();
            var query = session.QueryOver<AuditLog>()
                .Where(x => x.Fecha >= searchFilters.Desde)
                .Where(x => x.Fecha <= searchFilters.Hasta);

            if (!string.IsNullOrWhiteSpace(searchFilters.Entidad))
                query = query.And(Restrictions.On<AuditLog>(x => x.Entidad).IsInsensitiveLike(searchFilters.Entidad, MatchMode.Start));
            if (!string.IsNullOrWhiteSpace(searchFilters.Accion))
                query = query.And(x => x.Accion == searchFilters.Accion);
            if (searchFilters.EntidadId.HasValue)
                query = query.And(x => x.EntidadId == searchFilters.EntidadId);
            if (!string.IsNullOrWhiteSpace(searchFilters.Usuario))
                query = query.And(Restrictions.On<AuditLog>(x => x.Usuario).IsInsensitiveLike(searchFilters.Usuario, MatchMode.Start));

            if (!string.IsNullOrWhiteSpace(searchFilters.Filtro))
            {
                query.And(Restrictions.On<AuditLog>(x => x.EntidadAntes).IsInsensitiveLike(searchFilters.Filtro, MatchMode.Start)
                    || Restrictions.On<AuditLog>(x => x.EntidadDespues).IsInsensitiveLike(searchFilters.Filtro, MatchMode.Start));
            }

            return query;
        }
Пример #3
0
 public virtual ActionResult Index(AuditSearchFiltersViewModel viewModel = null)
 {
     if (viewModel == null)
         viewModel = new AuditSearchFiltersViewModel { Desde = DateTime.Now.AddDays(-7).ToMidnigth() };
     return View(viewModel);
 }