using System;
using System.Collections.Generic;
using System.Web.Mvc;
using QMFrameWork.Common.Serialization;
using QMFrameWork.Data;
using QMFrameWork.WebUI.Attribute;
using QMAPP.ServicesAgent;
using QMAPP.Common.Web.Controllers;
using QMAPP.Entity;
using QMFrameWork.WebUI.DataSource;
using QMAPP.MD.Web.Models;
using QMAPP.MD.Entity;
namespace QMAPP.MD.Web.Controllers
{
/// 模块名称:采集数据借口-状态码配置
/// 作 者:周晓东
/// 编写日期:2010514
public class WorkCellStateController : QController
{
#region 获取列表
///
/// 加载列表
///
/// 结果
[HandleException]
public ActionResult List(bool? callBack)
{
WorkCellStateModel seachModel = new WorkCellStateModel();
if (callBack == false)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/WorkCellState/GetList";
return View("List", seachModel);
}
///
/// 获取列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetList(bool? callBack)
{
ServiceAgent wcfAgent = GetServiceAgent();
try
{
//获取查询对象
var seachModel = GetModel();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
//获取前台分页设置信息
var page = GetDataPage(seachModel);
var condition = CopyToModel(seachModel);
page = wcfAgent.InvokeServiceFunction("WorkCellStateBLL_GetList", condition, page);
DataGridResult result = new DataGridResult
{
Total = page.RecordCount,
Rows = JsonConvertHelper.GetDeserialize>(page.Result.ToString())
};
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 编辑
///
/// 编辑载入
///
/// 处理结果
[HandleException]
public ActionResult Edit()
{
WorkCellStateModel model = new WorkCellStateModel();
string PID = Request.Params["PID"];
WorkCellState Entity = new WorkCellState();
ServiceAgent wcfAgent = GetServiceAgent();
try
{
if (string.IsNullOrEmpty(PID) == false)
{
//修改获取原数据
Entity.PID = PID;
var item = wcfAgent.InvokeServiceFunction("WorkCellStateBLL_Get", Entity);
if (item==null)
{
SetMessage("修改失败。");
return View("Edit", model);
}
model = CopyToModel(item);
}
return View("Edit", model);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 保存
///
/// 处理结果
[HttpPost]
[HandleException]
public ActionResult Save(WorkCellStateModel saveModel)
{
ServiceAgent wcfAgent = GetServiceAgent();
try
{
var info = CopyToModel(saveModel);
//info.Details = JsonConvertHelper.DeserializeObject>(saveModel.DetailValue);
var serviceResult = wcfAgent.InvokeServiceFunction>(string.IsNullOrEmpty(info.PID) ? "WorkCellStateBLL_Insert" : "WorkCellStateBLL_Update", info);
if (serviceResult.Ex != null)
throw serviceResult.Ex;
if (serviceResult.IsSuccess)
return
GetJsViewResult(
string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();",
AppResource.SaveMessge));
//保存失败
SetMessage(serviceResult.Msg);
return View("Edit", saveModel);
}
catch(Exception ex)
{
throw ex;
}
}
#endregion
#region 删除
///
/// 删除
///
/// 结果
[HttpPost]
[HandleException]
public ActionResult Delete()
{
string selectKey = Request.Form["selectKey"];
ServiceAgent wcfAgent = GetServiceAgent();
try
{
var serviceResult = wcfAgent.InvokeServiceFunction>("WorkCellStateBLL_DeleteArray", selectKey);
SetMessage(string.IsNullOrEmpty(serviceResult.Msg) ? AppResource.DeleteMessage : serviceResult.Msg);
return List(true);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}