示例#1
0
        /// <summary>
        /// 根据查询条件获取检测报告分页列表
        /// </summary>
        public async Task <PagedResultDto <ReportListDto> > GetPagedReportsAsync(GetReportInput input)
        {
            var query = _reportRepositoryAsNoTrack;

            //TODO:根据传入的参数添加过滤条件

            query = query.WhereIf(!string.IsNullOrEmpty(input.FilterText),
                                  p => p.ReportName.Contains(input.FilterText))
                    .WhereIf(input.Id != null, p => p.Id == input.Id)
                    .WhereIf(input.Status != null, p => p.IsShow == input.Status)
                    .WhereIf(input.BeginDate != null, p => p.CreationTime >= input.BeginDate)
                    .WhereIf(input.EndDate != null, p => p.CreationTime <= input.EndDate);


            var reportCount = await query.CountAsync();

            var reports = await query.OrderByDescending(r => r.CreationTime).PageBy(input).ToListAsync();

            var reportListDtos = reports.MapTo <List <ReportListDto> >();

            return(new PagedResultDto <ReportListDto>(
                       reportCount,
                       reportListDtos
                       ));
        }
示例#2
0
        public JsonResult GetDataPager(DataTableSearchModel searchInput)
        {
            if (searchInput.ActionType == "group_action")
            {
                if (string.IsNullOrEmpty(searchInput.CustomActionValue) || searchInput.id == null ||
                    searchInput.id.Count == 0)
                {
                    return(Json(new { actionType = searchInput.ActionType, customActionStatus = false, customActionMsg = "无效参数" }));
                }
                try
                {
                    _reportAppService.BatchUpdateStatusAsync(searchInput.id, bool.Parse(searchInput.CustomActionValue));
                    return(Json(new { actionType = searchInput.ActionType, customActionStatus = true, customActionMsg = "" }));
                }
                catch (Exception e)
                {
                    return(Json(new { actionType = searchInput.ActionType, customActionStatus = false, customActionMsg = "无效参数" }));
                }
            }


            int pageIndex = 0;

            GetReportInput defaultInput = new GetReportInput()
            {
                MaxResultCount = CarFactoryConsts.MaxPageSize,
                SkipCount      = pageIndex * CarFactoryConsts.MaxPageSize,
                Sorting        = "CreationTime",
                Page           = pageIndex + 1
            };

            if (searchInput != null && searchInput.ActionType == "filter")
            {
                defaultInput.Id         = searchInput.FilterId;
                defaultInput.BeginDate  = searchInput.FilterDateFrom;
                defaultInput.EndDate    = searchInput.FilterDateTo;
                defaultInput.FilterText = searchInput.FilterName ?? "";
                defaultInput.Status     = searchInput.FilterStatus;
            }


            var list = _reportAppService.GetPagedReportsAsync(defaultInput).Result;

            var pagedProducts = new StaticPagedList <ReportListDto>(list.Items, defaultInput.Page.Value, defaultInput.MaxResultCount,
                                                                    list.TotalCount);


            var viewModelList = GenerateTablePagerData(pagedProducts, "/admin/reports/detail/");

            return(Json(new { draw = Request.Form["draw"], recordsTotal = pagedProducts.TotalItemCount, recordsFiltered = pagedProducts.Count, data = viewModelList }, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        // GET: Qualification
        public ActionResult List(int?page)
        {
            int pageIndex = ((page != null && page.Value >= 1) ? page.Value : 1) - 1;


            GetReportInput pagedInput = new GetReportInput();

            pagedInput.SkipCount = pageIndex * pagedInput.MaxResultCount;

            var reports = _reportAppService.GetPagedReportsAsync(pagedInput).Result;

            var pagedReports = new StaticPagedList <ReportListDto>(reports.Items, pageIndex + 1, pagedInput.MaxResultCount,
                                                                   reports.TotalCount);

            ViewBag.SeoSetting = GetSeoSetting();

            return(View(pagedReports));
        }