public List <SysLog> GetList(Pagination pagination, string queryJson) { var expression = ExtLinq.True <SysLog>(); var queryParam = queryJson.ToJObject(); if (!queryParam["keyword"].IsEmpty()) { string keyword = queryParam["keyword"].ToString(); expression = expression.And(t => t.Account.Contains(keyword)); } if (!queryParam["timeType"].IsEmpty()) { string timeType = queryParam["timeType"].ToString(); DateTime startTime = DateTime.Now.ToString("yyyy-MM-dd").ToDate(); DateTime endTime = DateTime.Now.ToString("yyyy-MM-dd").ToDate().AddDays(1); switch (timeType) { case "1": break; case "2": startTime = DateTime.Now.AddDays(-7); break; case "3": startTime = DateTime.Now.AddMonths(-1); break; case "4": startTime = DateTime.Now.AddMonths(-3); break; default: break; } expression = expression.And(t => t.Date >= startTime && t.Date <= endTime); } return(_Respository.GetPagedList(expression, pagination)); }
public PagedList <SysLog> GetList(LogSearchView search, int pageIndex, int pageSize) { var expression = ExtLinq.True <SysLog>(); if (!string.IsNullOrWhiteSpace(search.Keyword)) { string keyword = search.Keyword; expression = expression.And(t => t.Account.Contains(keyword) || t.Description.Contains(keyword) || t.ModuleName.Contains(keyword) || t.NickName.Contains(keyword) || t.Type.Contains(keyword)); } if (!string.IsNullOrWhiteSpace(search.Admin)) { string admin = search.Admin; expression = expression.And(t => t.Account.Contains(admin)); } if (search.StartTime.HasValue) { expression = expression.And(t => t.Date >= search.StartTime && t.Date <= search.EndTime); } return(_Respository.GetPagedList(expression, pageIndex, pageSize, w => w.OrderByDescending(d => d.Date))); }