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
{
///
/// 监控报表
///
public class MonitorController : QController
{
#region 数据处理任务监控
///
/// 数据处理任务监控
///
///
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();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
//调用服务
QMAPP.ServicesAgent.TaskService.TaskServiceClient agent = new ServiceAgent().GetTaskService();
List monitors = agent.GetPlanMonitorInfos().ToList();
QMAPP.ServicesAgent.TaskService.PlanInfo[] list = agent.GetPlanList();
DataGridResult result = new DataGridResult();
result.Total = monitors.Count; ;
result.Rows = new List();
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 数据处理任务日志
///
/// 数据处理任务日志
///
///
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();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
//获取数据
condition = CopyToModel(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("DataTaskPlanBLL_GetLogList", condition, page);
DataGridResult result = new DataGridResult();
result.Total = page.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize>(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
///
/// 导出excel
///
/// 结果
[HttpPost]
[HandleException]
public ActionResult ExportLogList()
{
DataTaskLogModel seachModel = null;
DataTaskLog condition = null;
DataTable exportDt = new DataTable();
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
try
{
//获取查询对象
seachModel = GetModel();
condition = CopyToModel(seachModel);
//获取数据
exportDt = agent.InvokeServiceFunction("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
}
}