/// <summary> /// 异常事件下载,另存为EXCEL文档 /// </summary> /// <returns></returns> public ActionResult AnomalousEventsDownloadSearchResult(AnomalousEventsQueryConditionView condition) { if (condition.EndTime < condition.StartTime) { return(Content("<span style='color:red'>开始时间不能晚于结束时间</span>")); } var req = new AnomalousEventsQueryRequest() { CurrentPageIndex = condition.CurrentPageIndex, TestTypeId = condition.TestTypeId, PointsPositionId = condition.PointsPositionId, StartTime = condition.StartTime, EndTime = condition.EndTime }; var resp = _anomalousEventManagementService.SaveAs(req); var guid = Guid.NewGuid().ToString(); CacheHelper.SetCache(guid, resp.FilePath); return(Json(guid, JsonRequestBehavior.AllowGet)); }
public ActionResult GetAnomalousEvents(AnomalousEventsQueryConditionView condition) { Response.Cache.SetOmitVaryStar(true); if (condition.EndTime < condition.StartTime) { TempData[WebConstants.MessageColor] = StyleConstants.RedColor; TempData[WebConstants.Message] = "开始时间不能晚于结束时间!"; return(PartialView("NoAnomalousEventManagementContentPartial")); } var req = new AnomalousEventsQueryRequest() { CurrentPageIndex = condition.CurrentPageIndex, TestTypeId = condition.TestTypeId, PointsPositionId = condition.PointsPositionId, StartTime = condition.StartTime, EndTime = condition.EndTime }; var models = new List <AnomalousEventManagementViewModel>(); var sours = new List <AnomalousEventManagementViewModel>(); long resultCount = 0; var result = _anomalousEventManagementService.GetAnomalousEventManagementDatasBy(req); if (result.Succeed) { foreach (var item in result.Datas) { var model = new AnomalousEventManagementViewModel() { Time = item.Time, TestType = item.TestType, PointsPosition = item.PointsPosition, PointsNumber = item.PointsNumber, AnomalousEventReason = item.AnomalousEventReason }; models.Add(model); } resultCount = result.TotalResultCount; } var resp = new AnomalousEventManagementResponseViewModel(); resp.Datas = models; resp.TotalResultCount = resultCount; string partialView = null; if (resp.TotalResultCount > 0) { resp.Succeed = true; ViewData["TotalPages"] = resp.TotalPages; resp.CurrentPage = condition.CurrentPageIndex; partialView = "AnomalousEventManagementContentPartial"; } else { //resp.Message = result.Message; TempData[WebConstants.MessageColor] = StyleConstants.RedColor; TempData[WebConstants.Message] = "无记录!"; partialView = "NoAnomalousEventManagementContentPartial"; } return(PartialView(partialView, resp)); }