using System; using System.Collections.Generic; using System.Web.Mvc; using QMAPP.Common.Web.Controllers; using QMAPP.FJC.Web.Models.CompleteStatistics; using QMAPP.ServicesAgent; using QMFrameWork.Common.Serialization; using QMFrameWork.Data; using QMFrameWork.WebUI.Attribute; using QMFrameWork.WebUI.DataSource; using QMAPP.Entity; using QMAPP.FJC.Entity.CompleteStatistics; using QMFrameWork.Log; using QMFrameWork.Common.ExcelOperation; using System.Data; namespace QMAPP.FJC.Web.Controllers { public class CompleteStatisticsController : QController { // // GET: /CompleteStatistics/ [HandleException] public ActionResult CompleteStatisticsList(bool? callBack) { CompleteStatisticsModel searchModel = new CompleteStatisticsModel(); if (callBack == true) this.TryGetSelectBuffer(out searchModel); searchModel.rownumbers = false; searchModel.url = "/CompleteStatistics/GetList"; return this.View("CompleteStatisticsList", searchModel); } /// /// 获取列表 /// /// 是否回调 /// 用户列表 [HandleException] public ActionResult GetList(bool? callBack) { ServiceAgent wcfAgent = this.GetServiceAgent(); CompleteStatisticsModel searchModel = this.GetModel(); if (callBack == true) { this.TryGetSelectBuffer(out searchModel); } else { this.SetSelectBuffer(searchModel); } //获取前台分页设置信息 DataPage page = this.GetDataPage(searchModel); CompleteStatisticsEntity condition = this.CopyToModel(searchModel); condition.DELFLAG = searchModel.DOESEXPORT; DataResult pageResult = wcfAgent.InvokeServiceFunction>("CompleteStatisticsBLL_GetList", condition, page); if (pageResult.IsSuccess == false) { this.SetMessage(pageResult.Msg); return this.CompleteStatisticsList(true); } DataGridResult result = new DataGridResult { Total = pageResult.Result.RecordCount, Rows = JsonConvertHelper.GetDeserialize>(pageResult.Result.Result.ToString()) }; return this.Content(result.GetJsonSource()); } [HttpPost] [HandleException] public ActionResult ExportCompleteStatistics() { CompleteStatisticsModel searchModel = this.GetModel(); CompleteStatisticsEntity condition = this.CopyToModel(searchModel); DataResult result = this.GetServiceAgent().InvokeServiceFunction("CompleteStatisticsBLL_ExportCompleteStatistics", condition); this.SetMessage(result.Msg); return this.CompleteStatisticsList(true); } [HttpPost] [HandleException] public ActionResult Delete() { string selectKey = this.Request.Form["selectKey"]; ServiceAgent wcfAgent = this.GetServiceAgent(); //删除 DataResult serviceResult = wcfAgent.InvokeServiceFunction>("", selectKey); this.SetMessage(string.IsNullOrEmpty(serviceResult.Msg) ? AppResource.DeleteMessage : serviceResult.Msg); return this.CompleteStatisticsList(true); } [HttpPost] [HandleException] public ActionResult Save(CompleteStatisticsModel saveModel) { CompleteStatisticsEntity model = this.CopyToModel(saveModel); ServiceAgent wcfAgent = this.GetServiceAgent(); DataResult serviceResult = wcfAgent.InvokeServiceFunction>(string.IsNullOrEmpty(model.PID) ? "CompleteStatisticsBLL_Insert" : "CompleteStatisticsBLL_Update", model); this.SetMessage(string.IsNullOrEmpty(serviceResult.Msg) ? AppResource.SaveMessge : serviceResult.Msg); return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge)); } /// /// 编辑载入 /// /// 处理结果 [HandleException] public ActionResult CompleteStatisticsEdit() { CompleteStatisticsModel model = new CompleteStatisticsModel(); string pid = this.Request.Params["PID"]; if (!string.IsNullOrEmpty(pid)) { ServiceAgent serviceAgent = this.GetServiceAgent(); CompleteStatisticsEntity entity = serviceAgent.InvokeServiceFunction("CompleteStatisticsBLL_GetById", pid); model = this.CopyToModel(entity); } return this.View(model); } /// /// 导出excel /// /// 结果 [HandleException] public ActionResult ExportExcel() { try { CompleteStatisticsModel searchModel = this.GetModel(); CompleteStatisticsEntity condition = this.CopyToModel(searchModel); DataResult result = this.GetServiceAgent().InvokeServiceFunction>("CompleteStatisticsBLL_ExportExcelData", condition); //导出 QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool(); return efTool.GetExcelFileResult("CompleteStatisticsExp", "完工数量统计.xlsx", result.Result); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Info = "导出excel", Tag = "完工数量统计" }); this.SetMessage("导出excel失败"); return this.CompleteStatisticsList(true); } } } }