using System;
using System.Collections.Generic;
using System.Web.Mvc;
using QMAPP.Common.Web.Controllers;
using QMAPP.Entity;
using QMAPP.FJC.Entity;
using QMAPP.FJC.Entity.WarnManage;
using QMAPP.FJC.Web.Models.ProduceManage;
using QMAPP.FJC.Web.Models.WarnManage;
using QMAPP.ServicesAgent;
using QMFrameWork.Common.Serialization;
using QMFrameWork.Data;
using QMFrameWork.WebUI.Attribute;
using QMFrameWork.WebUI.DataSource;
namespace QMAPP.FJC.Web.Controllers
{
///
/// 模块编号:M6-3自动报警维护
/// 作 用:自动报警维护
/// 作 者:张敬贺
/// 编写日期:2015年06月19日
///
public class WarnManageController : QController
{
#region 报警信息维护
#region 报警信息获取列表
///
/// 加载列表
///
/// 结果
[HandleException]
public ActionResult WarnInfoList(bool? callBack)
{
WarnInfoModel seachModel = new WarnInfoModel();
seachModel.STARTCREATEDATE = DateTime.Now.Date.AddDays(-10).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.ENDCREATEDATE = DateTime.Now.Date.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.ImmediateSearch = false;
if (callBack == true)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/WarnManage/GetWarnInfoList";
return View("WarnInfoList", seachModel);
}
///
/// 获取列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetWarnInfoList(bool? callBack)
{
WarnInfoModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
WarnInfo condition = null;
try
{
//获取查询对象
seachModel = GetModel();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel(seachModel);
#region wcf服务统一接口
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_GetWarnInfoList.ToString(), condition, page);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (dataResult.IsSuccess)
{
page = dataResult.Result;
}
DateGridResult result = new DateGridResult();
result.Total = page.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize>(page.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 报警信息编辑
///
/// 编辑载入
///
/// 处理结果
[HandleException]
public ActionResult WarnInfoEdit()
{
WarnInfoModel model = new WarnInfoModel();
string ID = Request.Params["PID"];
WarnInfo Entity = new WarnInfo();
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
if (string.IsNullOrEmpty(ID) == false)
{
//修改获取原数据
Entity.PID = ID;
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnInfoGet.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (dataResult.IsSuccess)
{
Entity = dataResult.Result;
}
else
{
SetMessage(dataResult.Msg);
return View("WarnInfoEdit", Entity);
}
model = CopyToModel(Entity);
}
return View("WarnInfoEdit", model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 报警信息保存
///
/// 保存
///
///
/// 处理结果
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult WarnInfoSave(WarnInfoModel saveModel)
{
WarnInfo Entity = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
Entity = CopyToModel(saveModel);
//web段调用为手动创建
Entity.CREATETYPE = QMAPP.FJC.Entity.EnumGeter.CREATETYPE.people.GetHashCode().ToString();
if (string.IsNullOrEmpty(Entity.PID) == true)
{
//新增
var dataResult = wcfAgent.InvokeServiceFunction(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnInfoInsert.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
return View("WarnInfoEdit", saveModel);
}
}
else
{
//修改
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnInfoUpdate.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
return View("WarnInfoEdit", saveModel);
}
}
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 报警信息删除
///
/// 删除
///
/// 结果
[HttpPost]
[HandleException]
public ActionResult WarnInfoDelete(ProducePlanModel saveMode)
{
string selectKey = Request.Form["selectKey"];
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
var dataResult = wcfAgent.InvokeServiceFunction(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnInfoDelete.ToString(), selectKey);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
}
else
{
SetMessage(AppResource.DeleteMessage);
}
return WarnInfoList(true);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#endregion
#region 报警类别维护
#region 报警类别获取列表
///
/// 加载列表
///
/// 结果
[HandleException]
public ActionResult WarnTypeList(bool? callBack)
{
WarnTypeModel seachModel = new WarnTypeModel();
if (callBack == true)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/WarnManage/GetWarnTypeList";
return View("WarnTypeList", seachModel);
}
///
/// 获取列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetWarnTypeList(bool? callBack)
{
WarnTypeModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
WarnType condition = null;
try
{
//获取查询对象
seachModel = GetModel();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel(seachModel);
#region 用于报警通知人关联报警信息查询使用
string WarnInformerId = Request["WarnInformerId"];
if (!string.IsNullOrEmpty(WarnInformerId))
{
condition.WarnInformerId = WarnInformerId;
}
#endregion
#region wcf服务统一接口
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_GetWarnTypeList.ToString(), condition, page);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (dataResult.IsSuccess)
{
page = dataResult.Result;
}
DateGridResult result = new DateGridResult();
result.Total = page.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize>(page.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 报警类别编辑
///
/// 编辑载入
///
/// 处理结果
[HandleException]
public ActionResult WarnTypeEdit()
{
WarnTypeModel model = new WarnTypeModel();
string ID = Request.Params["PID"];
WarnType Entity = new WarnType();
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
if (string.IsNullOrEmpty(ID) == false)
{
//修改获取原数据
Entity.PID = ID;
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnTypeGet.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (dataResult.IsSuccess)
{
Entity = dataResult.Result;
}
else
{
SetMessage(dataResult.Msg);
return View("WarnTypeEdit", Entity);
}
model = CopyToModel(Entity);
}
return View("WarnTypeEdit", model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 报警类别保存
///
/// 保存
///
///
/// 处理结果
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult WarnTypeSave(WarnTypeModel saveModel)
{
WarnType Entity = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
Entity = CopyToModel(saveModel);
if (string.IsNullOrEmpty(Entity.PID) == true)
{
//新增
var dataResult = wcfAgent.InvokeServiceFunction(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnTypeInsert.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
return View("WarnTypeEdit", saveModel);
}
}
else
{
//修改
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnTypeUpdate.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
return View("WarnTypeEdit", saveModel);
}
}
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 报警类别删除
///
/// 删除
///
/// 结果
[HttpPost]
[HandleException]
public ActionResult WarnTypeDelete(WarnTypeModel saveMode)
{
string selectKey = Request.Form["selectKey"];
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
var dataResult = wcfAgent.InvokeServiceFunction(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnTypeDelete.ToString(), selectKey);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
}
else
{
SetMessage(AppResource.DeleteMessage);
}
return WarnTypeList(true);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#endregion
#region 通知人员维护
#region 通知人员获取列表
///
/// 加载列表
///
/// 结果
[HandleException]
public ActionResult WarnInformerList(bool? callBack)
{
WarnInformerModel seachModel = new WarnInformerModel();
if (callBack == true)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/WarnManage/GetWarnInformerList";
return View("WarnInformerList", seachModel);
}
///
/// 获取列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetWarnInformerList(bool? callBack)
{
WarnInformerModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
WarnInformer condition = null;
try
{
//获取查询对象
seachModel = GetModel();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel(seachModel);
#region wcf服务统一接口
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_GetWarnInformerList.ToString(), condition, page);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (dataResult.IsSuccess)
{
page = dataResult.Result;
}
DateGridResult result = new DateGridResult();
result.Total = page.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize>(page.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 通知人员编辑
///
/// 编辑载入
///
/// 处理结果
[HandleException]
public ActionResult WarnInformerEdit()
{
WarnInformerModel model = new WarnInformerModel();
string ID = Request.Params["PID"];
WarnInformer Entity = new WarnInformer();
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
if (string.IsNullOrEmpty(ID) == false)
{
//修改获取原数据
Entity.PID = ID;
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnInformerGet.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (dataResult.IsSuccess)
{
Entity = dataResult.Result;
}
else
{
SetMessage(dataResult.Msg);
return View("WarnInformerEdit", Entity);
}
model = CopyToModel(Entity);
}
return View("WarnInformerEdit", model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 通知人员保存
///
/// 保存
///
///
/// 处理结果
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult WarnInformerSave(WarnInformerModel saveModel)
{
WarnInformer Entity = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
Entity = CopyToModel(saveModel);
//报警类别ID
Entity.WarnTypeIds = Request.Params["WarnTypeIds"];
if (string.IsNullOrEmpty(Entity.PID) == true)
{
//新增
var dataResult = wcfAgent.InvokeServiceFunction(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnInformerInsert.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
return View("WarnInformerEdit", saveModel);
}
}
else
{
//修改
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnInformerUpdate.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
return View("WarnInformerEdit", saveModel);
}
}
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 通知人员删除
///
/// 删除
///
/// 结果
[HttpPost]
[HandleException]
public ActionResult WarnInformerDelete(WarnInformerModel saveMode)
{
string selectKey = Request.Form["selectKey"];
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
var dataResult = wcfAgent.InvokeServiceFunction(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_WarnInformerDelete.ToString(), selectKey);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
}
else
{
SetMessage(AppResource.DeleteMessage);
}
return WarnInformerList(true);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 校验运单号并进行绑定
///
/// 校验运单号并进行绑定
///
[HttpGet]
//public JsonResult CheckTransno(string transno)
//{
// DataResult DataResult = new DataResult();
// #region wcf服务统一接口
//ServiceAgent wcfAgent = this.GetServiceAgent();
//DataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.WarnManage.WarnManageBLL_GetAllWarnTypeList.ToString(), transno);
// List