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.
252 lines
7.7 KiB
252 lines
7.7 KiB
4 years ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Web;
|
||
|
using System.Web.Mvc;
|
||
|
using QMFrameWork.WebUI.Attribute;
|
||
|
using QMAPP.Web.Models.Sys;
|
||
|
using QMAPP.Common.Web.Controllers;
|
||
|
using QMFrameWork.Data;
|
||
|
using QMAPP.Entity.Sys;
|
||
|
using QMFrameWork.WebUI.DataSource;
|
||
|
using QMFrameWork.Common.Serialization;
|
||
|
|
||
|
namespace QMAPP.Web.Controllers
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 系统锁定控制器
|
||
|
/// 创建者:韩磊
|
||
|
/// 创建日期:2014.12.17
|
||
|
/// </summary>
|
||
|
public class SystemLockController : QController
|
||
|
{
|
||
|
#region 系统锁定列表
|
||
|
|
||
|
/// <summary>
|
||
|
/// 系统锁定列表加载
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
[HandleException]
|
||
|
public ActionResult SystemLockList(bool? callBack)
|
||
|
{
|
||
|
SystemLockModel seachModel = new SystemLockModel();
|
||
|
if (callBack == true)
|
||
|
{
|
||
|
TryGetSelectBuffer<SystemLockModel>(out seachModel);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
seachModel.ValidFlg = "1";
|
||
|
}
|
||
|
seachModel.rownumbers = false;
|
||
|
seachModel.url = "/SystemLock/GetList";
|
||
|
return View("SystemLockList", seachModel);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取系统锁定列表
|
||
|
/// </summary>
|
||
|
/// <param name="callBack">是否回调</param>
|
||
|
/// <returns></returns>
|
||
|
[HandleException]
|
||
|
public ActionResult GetList(bool? callBack)
|
||
|
{
|
||
|
List<SystemLockModel> lockInfo = new List<SystemLockModel>();
|
||
|
SystemLockModel seachModel = null;
|
||
|
DataPage page = null;
|
||
|
SystemLockInfo condition = null;
|
||
|
try
|
||
|
{
|
||
|
//获取查询对象
|
||
|
seachModel = GetModel<SystemLockModel>();
|
||
|
|
||
|
if (seachModel.ValidFlg == null)
|
||
|
{
|
||
|
seachModel.ValidFlg = "1";
|
||
|
}
|
||
|
#region 获取缓存值
|
||
|
if (callBack != null)
|
||
|
{
|
||
|
TryGetSelectBuffer<SystemLockModel>(out seachModel);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//保存搜索条件
|
||
|
SetSelectBuffer<SystemLockModel>(seachModel);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
//获取前台分页设置信息
|
||
|
page = this.GetDataPage(seachModel);
|
||
|
|
||
|
//获取查询条件
|
||
|
condition = CopyToModel<SystemLockInfo, SystemLockModel>(seachModel);
|
||
|
|
||
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
||
|
|
||
|
page = agent.InvokeServiceFunction<DataPage>("SystemLockBLL_GetList", condition, page);
|
||
|
//转换查询结果
|
||
|
DataGridResult<SystemLockInfo> result = new DataGridResult<SystemLockInfo>();
|
||
|
result.Total = page.RecordCount;
|
||
|
result.Rows = JsonConvertHelper.GetDeserialize<List<SystemLockInfo>>(page.Result.ToString());
|
||
|
|
||
|
return Content(result.GetJsonSource());
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 系统锁定信息添加、修改、删除
|
||
|
|
||
|
/// <summary>
|
||
|
/// 锁定信息编辑
|
||
|
/// </summary>
|
||
|
/// <returns>锁定信息</returns>
|
||
|
[HandleException]
|
||
|
public ActionResult SystemLockEdit()
|
||
|
{
|
||
|
string Pid = Request.Params["PID"];
|
||
|
SystemLockModel model = new SystemLockModel();
|
||
|
SystemLockInfo lockInfo = new SystemLockInfo();
|
||
|
try
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(Pid) == false)
|
||
|
{
|
||
|
//获取原信息
|
||
|
lockInfo.PID = Pid;
|
||
|
|
||
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
||
|
lockInfo=agent.InvokeServiceFunction<SystemLockInfo>("SystemLockBLL_Get", lockInfo);
|
||
|
|
||
|
model = CopyToModel<SystemLockModel, SystemLockInfo>(lockInfo);
|
||
|
}
|
||
|
|
||
|
return View(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 保存系统锁定信息
|
||
|
/// </summary>
|
||
|
/// <param name="saveModel">系统锁定信息</param>
|
||
|
/// <returns>返回动作</returns>
|
||
|
[HttpPost]
|
||
|
[HandleException]
|
||
|
public ActionResult SystemLockSave(SystemLockModel saveModel)
|
||
|
{
|
||
|
SystemLockInfo lockInfo = new SystemLockInfo();
|
||
|
int r = 0;
|
||
|
try
|
||
|
{
|
||
|
lockInfo = CopyToModel<SystemLockInfo, SystemLockModel>(saveModel);
|
||
|
|
||
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
||
|
if (string.IsNullOrEmpty(lockInfo.PID) == true)
|
||
|
{
|
||
|
//基本信息
|
||
|
lockInfo.StartTime = Convert.ToDateTime(saveModel.StartTime);
|
||
|
lockInfo.EndTime = Convert.ToDateTime(saveModel.EndTime);
|
||
|
//新增
|
||
|
r = agent.InvokeServiceFunction<int>("SystemLockBLL_Insert", lockInfo);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//修改
|
||
|
r = agent.InvokeServiceFunction<int>("SystemLockBLL_Update", lockInfo);
|
||
|
}
|
||
|
|
||
|
//刷新数据锁定标志
|
||
|
agent.RefreshDataLock();
|
||
|
|
||
|
//保存成功
|
||
|
SetMessage(AppResource.SaveMessge);
|
||
|
return this.GetJsViewResult(string.Format("parent.List();parent.showTitle('{0}');parent.closeAppWindow1();"
|
||
|
, AppResource.SaveMessge));
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 删除系统锁定信息
|
||
|
/// </summary>
|
||
|
/// <returns>结果</returns>
|
||
|
[HttpPost]
|
||
|
[HandleException]
|
||
|
public ActionResult SystemLockDelete()
|
||
|
{
|
||
|
string selectKey = Request.Form["selectKey"];
|
||
|
string[] list = selectKey.Split(":".ToCharArray());
|
||
|
ArrayList locks = new ArrayList();
|
||
|
try
|
||
|
{
|
||
|
//调用服务
|
||
|
foreach (string id in list)
|
||
|
{
|
||
|
locks.Add(id);
|
||
|
}
|
||
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
||
|
agent.InvokeServiceFunction("SystemLockBLL_DeleteAll", locks);
|
||
|
|
||
|
//刷新数据锁定标志
|
||
|
agent.RefreshDataLock();
|
||
|
|
||
|
SetMessage(AppResource.DeleteMessage);
|
||
|
|
||
|
return SystemLockList(true);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 解除系统锁定信息
|
||
|
/// </summary>
|
||
|
/// <returns>结果</returns>
|
||
|
[HttpPost]
|
||
|
[HandleException]
|
||
|
public ActionResult SystemUnLock()
|
||
|
{
|
||
|
string selectKey = Request.Form["selectKey"];
|
||
|
try
|
||
|
{
|
||
|
//调用服务
|
||
|
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
|
||
|
agent.InvokeServiceFunction("SystemLockBLL_UnLock", new SystemLockInfo {PID=selectKey });
|
||
|
|
||
|
//刷新数据锁定标志
|
||
|
agent.RefreshDataLock();
|
||
|
|
||
|
SetMessage(AppResource.UnLock);
|
||
|
|
||
|
return SystemLockList(true);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
}
|