天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

221 lines
7.4 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.Mvc;
using QMFrameWork.WebUI.Attribute;
using QMFrameWork.WebUI.DataSource;
using QMFrameWork.Data;
using QMAPP.Common.Web.Controllers;
using QMAPP.Web.Models.Report;
using QMFrameWork.Common.Serialization;
using QMAPP.ServicesAgent;
using QMAPP.Entity.Sys;
namespace QMAPP.Web.Controllers
{
/// <summary>
/// 监控报表
/// </summary>
public class MonitorController : QController
{
#region 数据处理任务监控
/// <summary>
/// 数据处理任务监控
/// </summary>
/// <returns></returns>
public ActionResult TaskMonitorList()
{
MonitorInfoModel searchModel = new MonitorInfoModel();
searchModel.rownumbers = false;
searchModel.singleSelect = true;
searchModel.url = "/Monitor/GetTaskMonitorList";
return View("TaskMonitorList", searchModel);
}
public ActionResult GetTaskMonitorList(bool? callBack)
{
MonitorInfoModel seachModel = null;
DataPage page = new DataPage();
try
{
//获取查询对象
seachModel = GetModel<MonitorInfoModel>();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer<MonitorInfoModel>(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer<MonitorInfoModel>(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
//调用服务
QMAPP.ServicesAgent.TaskService.TaskServiceClient agent = new ServiceAgent().GetTaskService();
List<QMAPP.ServicesAgent.TaskService.MonitorInfo> monitors = agent.GetPlanMonitorInfos().ToList();
QMAPP.ServicesAgent.TaskService.PlanInfo[] list = agent.GetPlanList();
DataGridResult<MonitorInfoModel> result = new DataGridResult<MonitorInfoModel>();
result.Total = monitors.Count; ;
result.Rows = new List<MonitorInfoModel>();
foreach (QMAPP.ServicesAgent.TaskService.MonitorInfo m in monitors)
{
result.Rows.Add(
new MonitorInfoModel
{
PLANID=m.PlanID,
TaskName = m.TaskName,
ExecuteInterval = m.ExecuteInterval,
IsUse = m.IsUse==true?"是":"否",
LastExecuteTime = m.LastExecuteTime,
TaskStatus = m.IsNormal==true?"运行正常":"出现异常",
Running = m.Running==true?"执行中":"空闲"
});
}
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 数据处理任务日志
/// <summary>
/// 数据处理任务日志
/// </summary>
/// <returns></returns>
public ActionResult TaskLogList()
{
string planID = Request.QueryString["ID"];
DataTaskLogModel searchModel = new DataTaskLogModel();
searchModel.PLANID = planID;
searchModel.rownumbers = false;
searchModel.checkbox = false;
searchModel.singleSelect = true;
searchModel.StartTime = DateTime.Now.ToString("yyyy-MM-dd");
searchModel.url = "/Monitor/GetTaskLogList?PlanID="+planID;
return View("TaskLogList", searchModel);
}
public ActionResult GetTaskLogList(bool? callBack)
{
DataTaskLogModel seachModel = null;
DataPage page = new DataPage();
DataTaskLog condition = null;
string planID = Request.QueryString["PlanID"];
try
{
//获取查询对象
seachModel = GetModel<DataTaskLogModel>();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer<DataTaskLogModel>(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer<DataTaskLogModel>(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
//获取数据
condition = CopyToModel<DataTaskLog, DataTaskLogModel>(seachModel);
condition.PLANID = planID;
if (string.IsNullOrEmpty(condition.StartTime) == true)
{
condition.StartTime = DateTime.Now.ToString("yyyy-MM-dd");
}
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
page = agent.InvokeServiceFunction<DataPage>("DataTaskPlanBLL_GetLogList", condition, page);
DataGridResult<DataTaskLog> result = new DataGridResult<DataTaskLog>();
result.Total = page.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize<List<DataTaskLog>>(page.Result.ToString());
foreach (DataTaskLog log in result.Rows)
{
log.LASTEXECUTERESULT = log.LASTEXECUTERESULT == "true" ? "执行成功" : "执行失败-" + log.LASTEXECUTERESULT;
}
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 导出excel
/// <summary>
/// 导出excel
/// </summary>
/// <returns>结果</returns>
[HttpPost]
[HandleException]
public ActionResult ExportLogList()
{
DataTaskLogModel seachModel = null;
DataTaskLog condition = null;
DataTable exportDt = new DataTable();
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
try
{
//获取查询对象
seachModel = GetModel<DataTaskLogModel>();
condition = CopyToModel<DataTaskLog, DataTaskLogModel>(seachModel);
//获取数据
exportDt = agent.InvokeServiceFunction<DataTable>("DataTaskPlanBLL_GetExportLogData", condition);
foreach (DataRow row in exportDt.Rows)
{
row["LASTEXECUTERESULT"] = row["LASTEXECUTERESULT"].ToString() == "true" ? "执行成功" : "执行失败-" + row["LASTEXECUTERESULT"].ToString();
}
//导出
QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool();
return efTool.GetExcelFileResult("DataTaskLogList", "数据处理任务日志.xls", exportDt);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}