软测单独项目
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.
 
 
 
 
 
 

237 lines
9.0 KiB

using System;
using System.Collections.Generic;
using System.Web;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// OaLeaveHandler 的摘要说明
/// </summary>
public class OaPatrolRulesHandler : IHttpHandler
{
private FangYar.BLL.OA.OA_PATROL_RULES bll = new FangYar.BLL.OA.OA_PATROL_RULES();
public void ProcessRequest(HttpContext context)
{
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "岗哨巡查操作请求", "");
context.Response.ContentType = "text/plain";
string action = context.Request.Params["Action"];
string returnstr = "";
switch (action)
{
case "List":
returnstr = getRuleslist(context);
break;
case "Add":
returnstr = AddRules(context);
break;
case "Edit":
returnstr = EditRules(context);
break;
case "Del":
returnstr = DelRules(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string getRuleslist(HttpContext context)
{
string returnstr = "";
try
{
string orgId = context.Request.Params["orgId"];
string keyword = context.Request.Params["keywords"];
string page = context.Request.Params["page"];
string limit = context.Request.Params["limit"];
int pageIndex = 1;
int pageSize = 10;//
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
string where = null;
where = "ORG_ID = '" + orgId + "' ";
if (!string.IsNullOrEmpty(keyword))
{
where += " and NAME like '%" + keyword + "%' ";
}
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = bll.GetRecordCount(where);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
List<FangYar.Model.OA.OA_PATROL_RULES> list = bll.QueryList(pageIndex, pageSize, where, null);
returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "岗哨巡查操作请求", "查询异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "岗哨巡查操作请求", "查询");
return returnstr;
}
//添加巡查规则
private string AddRules(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string rulesId = Guid.NewGuid().ToString("N");
string NAME = context.Request.Params["NAME"];
string STARTTIME = context.Request.Params["STARTTIME"];
string ENDTIME = context.Request.Params["ENDTIME"];
string DES = context.Request.Params["DES"];
string STATE = context.Request.Params["STATE"];
string REMARKS = context.Request.Params["REMARKS"];
string ORG_ID = context.Request.Params["ORG_ID"];
string ORG_NAME = context.Request.Params["ORG_NAME"];
//巡查规则表
FangYar.Model.OA.OA_PATROL_RULES model = new Model.OA.OA_PATROL_RULES();
model.ID = rulesId;
model.NAME = NAME;
model.STARTTIME = STARTTIME;
model.ENDTIME = ENDTIME;
model.DES = DES;
model.STATE = STATE;
model.REMARKS = REMARKS;
model.ORG_ID = ORG_ID;
model.ORG_NAME = ORG_NAME;
if (bll.Add(model))
{
msg = "添加成功!";
code = 1;
}
else { msg = "添加失败!"; }
}
catch (Exception e)
{
msg = "添加失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "岗哨巡查操作请求", "添加巡查规则异常:" + e);
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "岗哨巡查操作请求", "添加巡查规则");
return returnstr;
}
//修改巡查规则
private string EditRules(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ID = context.Request.Params["ID"];
string NAME = context.Request.Params["NAME"];
string STARTTIME = context.Request.Params["STARTTIME"];
string ENDTIME = context.Request.Params["ENDTIME"];
string DES = context.Request.Params["DES"];
string STATE = context.Request.Params["STATE"];
string REMARKS = context.Request.Params["REMARKS"];
string ORG_ID = context.Request.Params["ORG_ID"];
string ORG_NAME = context.Request.Params["ORG_NAME"];
//巡查规则表
FangYar.Model.OA.OA_PATROL_RULES model = new Model.OA.OA_PATROL_RULES();
model.ID = ID;
model.NAME = NAME;
model.STARTTIME = STARTTIME;
model.ENDTIME = ENDTIME;
model.DES = DES;
model.STATE = STATE;
model.REMARKS = REMARKS;
model.ORG_ID = ORG_ID;
model.ORG_NAME = ORG_NAME;
if (bll.Update(model))
{
msg = "修改成功!";
code = 1;
}
else { msg = "修改失败!"; }
}
catch (Exception e)
{
msg = "修改失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "岗哨巡查操作请求", "修改巡查规则异常:" + e);
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "岗哨巡查操作请求", "修改巡查规则");
return returnstr;
}
//删除巡查规则
private string DelRules(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string RulesList = context.Request.Params["RulesList"];
string[] RulesArray = RulesList.Split(',');
string RulesListString = "";
for (int i = 0; i < RulesArray.Length; i++)
{
if (i == 0)
{
RulesListString = "'" + RulesArray[i] + "'";
}
else
{
RulesListString += ",'" + RulesArray[i] + "'";
}
}
if (bll.DeleteList(RulesListString))
{
msg = "删除成功!";
code = 1;
}
else
{
msg = "删除失败!";
}
}
catch (Exception e)
{
msg = "删除失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "岗哨巡查操作请求", "删除巡查规则异常:" + e);
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "岗哨巡查操作请求", "删除巡查规则");
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}