void DealWithContainsTime(SecondLevelSafetyAssessmentSearchRequest req, IList <Func <SecondAssessment_SecondLevelSafetyAssessmentReportTable, bool> > ps) { if (req.StartTime.Year != 1) { ps.Add(m => m.ReportTime >= req.StartTime); ps.Add(m => m.ReportTime < req.EndTime); } ; }
public ActionResult GetSecondLevelSafetyAssessmentReportList(SafetyAssessmentReportSearchBaseView conditions) { Response.Cache.SetOmitVaryStar(true); var req = new SecondLevelSafetyAssessmentSearchRequest() { CurrentPageIndex = conditions.CurrentPageIndex, }; if (conditions.Time.Year != 1) { req.StartTime = new DateTime(conditions.Time.Year, conditions.Time.Month, 1); req.EndTime = req.StartTime.AddMonths(1); } ; var GetSecondLevelSafetyAssessmentReportListService = new GetSecondLevelSafetyAssessmentReportService(); var resp = GetSecondLevelSafetyAssessmentReportListService.GetSecondLevelSafetyAssessmentReportList(req); var models = new List <SafetyAssessmentReportViewModel>(); var resultView = new SafetyAssessmentReportSearchBaseView(); if (resp.Succeed) { foreach (var item in resp.SecondLevelSafetyAssessmentReport) { var resultItem = new SafetyAssessmentReportViewModel(); resultItem.ReportName = item.ReportPeriods; resultItem.ReporePath = item.ReprotPath; resultItem.ReportTime = DateTimeHelper.FormatDateTime(item.ReportTime); resultItem.AssessmentGrade = item.AssessmentResultState.AssessmentGrade; resultItem.AssessmentState = item.AssessmentResultState.AssessmentState; models.Add(resultItem); } resultView.SafetyAssessmentReportViewModels = models; resultView.PaginatorModel = new ViewModels.PaginatorModel { TotalPages = resp.TotalPages, CurrentPageIndex = conditions.CurrentPageIndex }; } else { return(Json(new { Color = StyleConstants.RedColor, message = resp.Message }, JsonRequestBehavior.AllowGet)); } return(PartialView("GetSecondLevelSafetyAssessmentListPartial", resultView)); }
public SecondLevelSafetyAssessmentReportResponse GetSecondLevelSafetyAssessmentReportList(SecondLevelSafetyAssessmentSearchRequest req) { var resp = new SecondLevelSafetyAssessmentReportResponse(); IList <Func <SecondAssessment_SecondLevelSafetyAssessmentReportTable, bool> > ps = new List <Func <SecondAssessment_SecondLevelSafetyAssessmentReportTable, bool> >(); try { DealWithContainsTime(req, ps); var numberOfResultsPrePage = ApplicationSettingsFactory.GetApplicationSettings().NumberOfResultsPrePage;//获取每页记录数 var source = _getSecondLevelSafetyAssessmentReportDAL.FindBy(ps, req.CurrentPageIndex, numberOfResultsPrePage, ServiceConstant.AssessmentResultStateNavigationProperty); if (HasNoSearchResult(source)) { resp.Message = "无记录!"; } else { resp.TotalResultCount = _getSecondLevelSafetyAssessmentReportDAL.GetCountByContains(ps); resp.SecondLevelSafetyAssessmentReport = source; resp.Succeed = true; } } catch (Exception ex) { resp.Message = "搜索二级安全评估报告发生错误!"; Log(ex); } return(resp); }