// GET: /<controller>/ public async Task <IActionResult> Index(OperateLogOption filter, int?page) { ViewBag.filter = filter; var currentPageNum = page.HasValue ? page.Value : 1; var result = await _IOperateLogApp.GetPageAsync(currentPageNum, DefaultPageSize, filter); var model = new BaseListViewModel <OperateLogDto>(); model.list = result.Data; model.Paging.CurrentPage = currentPageNum; model.Paging.ItemsPerPage = DefaultPageSize; model.Paging.TotalItems = result.ItemCount; return(View(model)); }
// GET: /<controller>/ public async Task <IActionResult> Index(OperateLogOption filter, int?page) { ViewBag.filter = filter; var currentPageNum = page ?? 1; var result = await OperateLogApp.GetPageAsync(currentPageNum, DefaultPageSize, filter); var model = new BaseListViewModel <OperateLogDto> { list = result.Data, Paging = { CurrentPage = currentPageNum, ItemsPerPage = DefaultPageSize, TotalItems = result.ItemCount } }; return(View(model)); }
/// <summary> /// /// </summary> /// <param name="option"></param> /// <returns></returns> public async Task <Page <OperateLogDto> > PagerAsync(OperateLogOption option) { var predicate = PredicateBuilder.True <OperateLog>(); if (option.StartDateTime != null && option.StartDateTime.HasValue) { predicate = predicate.And(o => o.CreateTime >= option.StartDateTime.Value); } if (option.EndDateTime != null && option.EndDateTime.HasValue) { predicate = predicate.And(o => o.CreateTime <= option.EndDateTime.Value); } if (!string.IsNullOrWhiteSpace(option.Tag)) { predicate = predicate.And(o => o.Tag == option.Tag); } List <OperateLogDto> data = new List <OperateLogDto>(); int total = await OperateLogRep.GetCountAsync(predicate); if (total > 0) { IEnumerable <OperateLog> result = (await OperateLogRep.Find(option.PageIndex, option.Limit, option.OrderBy, predicate).ToListAsync()); data = AutoMapperExt.MapToList <OperateLog, OperateLogDto>(result.ToList()); if (data != null && data.Count > 0) { var list = data.Select(o => o.OperatorId).ToList(); var userlist = await UserRep.Find(o => list.Contains(o.Id)).ToListAsync(); int i = 0; foreach (var item in data) { long oid = item.OperatorId; var uname = userlist.Where(o => o.Id == oid).FirstOrDefault(); data[i].OperatorName = uname?.RealName ?? ""; i++; } } } return(new Page <OperateLogDto>(total, data)); }
/// <summary> /// /// </summary> /// <param name="pageNumber"></param> /// <param name="rowsPrePage"></param> /// <param name="option"></param> /// <returns></returns> public async Task <PageResult <OperateLogDto> > GetPageAsync(int pageNumber, int rowsPrePage, OperateLogOption option) { List <OperateLogDto> data = new List <OperateLogDto>(); PageResult <OperateLogDto> list = new PageResult <OperateLogDto>(); string orderby = " id desc"; var predicate = PredicateBuilder.True <OperateLog>(); if (option.StartDateTime != null) { predicate = predicate.And(o => o.CreateTime >= option.StartDateTime.Value); } if (option.EndDateTime != null) { predicate = predicate.And(o => o.CreateTime <= option.EndDateTime.Value); } if (!string.IsNullOrWhiteSpace(option.Tag)) { predicate = predicate.And(o => o.Tag == option.Tag); } var tlist = await OperateLogRep.Find(pageNumber, rowsPrePage, orderby, predicate).ToListAsync(); data = tlist.ToList().MapToList <OperateLogDto>(); if (data != null && data.Count > 0) { var operatorIds = data.Select(o => o.OperatorId).ToList(); var userlist = await UserRep.Find(o => operatorIds.Contains(o.Id)).ToListAsync(); int i = 0; foreach (var item in data) { long oid = item.OperatorId; var uname = userlist.FirstOrDefault(o => o.Id == oid); data[i].OperatorName = uname?.RealName ?? ""; i++; } } list.Data = data.ToList(); int total = await OperateLogRep.GetCountAsync(predicate); list.ItemCount = total; return(list); }