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.
179 lines
5.8 KiB
179 lines
5.8 KiB
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 获取列表
|
|
/// <summary>
|
|
/// 加载列表
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="callBack">是否回调</param>
|
|
/// <returns>列表</returns>
|
|
[HandleException]
|
|
public ActionResult GetList(bool? callBack)
|
|
{
|
|
ServiceAgent wcfAgent = GetServiceAgent();
|
|
try
|
|
{
|
|
//获取查询对象
|
|
var seachModel = GetModel<WorkCellStateModel>();
|
|
|
|
#region 获取缓存值
|
|
if (callBack != null)
|
|
{
|
|
TryGetSelectBuffer(out seachModel);
|
|
}
|
|
else
|
|
{
|
|
//保存搜索条件
|
|
SetSelectBuffer(seachModel);
|
|
}
|
|
#endregion
|
|
|
|
//获取前台分页设置信息
|
|
var page = GetDataPage(seachModel);
|
|
var condition = CopyToModel<WorkCellState, WorkCellStateModel>(seachModel);
|
|
|
|
page = wcfAgent.InvokeServiceFunction<DataPage>("WorkCellStateBLL_GetList", condition, page);
|
|
|
|
DataGridResult<WorkCellState> result = new DataGridResult<WorkCellState>
|
|
{
|
|
Total = page.RecordCount,
|
|
Rows = JsonConvertHelper.GetDeserialize<List<WorkCellState>>(page.Result.ToString())
|
|
};
|
|
|
|
return Content(result.GetJsonSource());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 编辑载入
|
|
/// </summary>
|
|
/// <returns>处理结果</returns>
|
|
[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<WorkCellState>("WorkCellStateBLL_Get", Entity);
|
|
if (item==null)
|
|
{
|
|
SetMessage("修改失败。");
|
|
return View("Edit", model);
|
|
}
|
|
model = CopyToModel<WorkCellStateModel, WorkCellState>(item);
|
|
}
|
|
return View("Edit", model);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
/// <returns>处理结果</returns>
|
|
[HttpPost]
|
|
[HandleException]
|
|
public ActionResult Save(WorkCellStateModel saveModel)
|
|
{
|
|
ServiceAgent wcfAgent = GetServiceAgent();
|
|
try
|
|
{
|
|
var info = CopyToModel<WorkCellState, WorkCellStateModel>(saveModel);
|
|
|
|
//info.Details = JsonConvertHelper.DeserializeObject<List<WorkCellStateData>>(saveModel.DetailValue);
|
|
var serviceResult = wcfAgent.InvokeServiceFunction<DataResult<int>>(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 删除
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <returns>结果</returns>
|
|
[HttpPost]
|
|
[HandleException]
|
|
public ActionResult Delete()
|
|
{
|
|
string selectKey = Request.Form["selectKey"];
|
|
ServiceAgent wcfAgent = GetServiceAgent();
|
|
try
|
|
{
|
|
var serviceResult = wcfAgent.InvokeServiceFunction<DataResult<int>>("WorkCellStateBLL_DeleteArray", selectKey);
|
|
SetMessage(string.IsNullOrEmpty(serviceResult.Msg) ? AppResource.DeleteMessage : serviceResult.Msg);
|
|
return List(true);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|
|
|