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

301 lines
12 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Text;
using System.Collections;
using System.Reflection;
using System.Web.Script.Serialization;
using FangYar.Model;
using FangYar.BLL;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// OaLeaveHandler 的摘要说明
/// </summary>
public class TblEpuOrgHandler : IHttpHandler
{
private FangYar.BLL.OA.TBL_EPUIP_ORG bll = new FangYar.BLL.OA.TBL_EPUIP_ORG();
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 = GetEpuList(context);
break;
case "Add":
returnstr = AddEpu(context);
break;
case "Edit":
returnstr = EditEpu(context);
break;
case "Del":
returnstr = DelEpu(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string GetEpuList(HttpContext context)
{
string returnstr = "";
try
{
string OrgId = context.Request.Params["OrgId"];
string keyword = context.Request.Params["keywords"];
string EXTEND2 = context.Request.Params["EXTEND2"];
string treeID = context.Request.Params["treeID"];
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 = " 1=1 ";
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
{
OrgId = treeID;
}
if (!string.IsNullOrEmpty(OrgId))
{
where += " and ORG_ID ='" + OrgId + "'";
}
if (!string.IsNullOrEmpty(EXTEND2))
{
if (where != null)
{
where += " and ";
}
where += " EXTEND2 = '" + EXTEND2 + "' ";
}
if (!string.IsNullOrEmpty(keyword))
{
if (where != null)
{
where += " and ";
}
where += "( NAME like '%" + keyword + "%' or ADDR like '%" + keyword + "%')";
}
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = bll.GetRecordCount(where);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
List<FangYar.Model.OA.TBL_EPUIP_ORG> list = bll.QueryList(pageIndex, pageSize, where, "FOUND_DATE");
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 AddEpu(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ID = Guid.NewGuid().ToString("N");
string EPUIP_ID = context.Request.Params["EPUIP_ID"];
string ORG_ID = context.Request.Params["ORG_ID"];
string EXTEND1 = context.Request.Params["EXTEND1"];
string EXTEND2 = context.Request.Params["EXTEND2"];
string EXTEND3 = context.Request.Params["EXTEND3"];
string EXTEND4 = context.Request.Params["EXTEND4"];
string NAME = context.Request.Params["NAME"];
string ADDR = context.Request.Params["ADDR"];
string FOUND_DATE = context.Request.Params["FOUND_DATE"];
string IS_DOORWAY = context.Request.Params["IS_DOORWAY"];
string IS_Attendance = context.Request.Params["IS_Attendance"];
string DVCADDRESS = context.Request.Params["DVCADDRESS"];
string DVCPORT = context.Request.Params["DVCPORT"];
string USERNAME = context.Request.Params["USERNAME"];
string PASSWORD = context.Request.Params["PASSWORD"];
string SERVICEADDR = context.Request.Params["SERVICEADDR"];
//现场设备与机构绑定表
FangYar.Model.OA.TBL_EPUIP_ORG model = new FangYar.Model.OA.TBL_EPUIP_ORG();
model.ID = ID;
model.EPUIP_ID = EPUIP_ID;
model.ORG_ID = ORG_ID;
model.EXTEND1 = EXTEND1;
model.EXTEND2 = EXTEND2;
model.EXTEND3 = EXTEND3;
model.EXTEND4 = EXTEND4;
model.NAME = NAME;
model.ADDR = ADDR;
model.FOUND_DATE = FOUND_DATE;
model.IS_DOORWAY = IS_DOORWAY;
model.IS_Attendance = IS_Attendance;
model.DVCADDRESS = DVCADDRESS;
model.DVCPORT = DVCPORT;
model.USERNAME = USERNAME;
model.PASSWORD = PASSWORD;
model.SERVICEADDR = SERVICEADDR;
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 EditEpu(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ID = context.Request.Params["ID"];
string EPUIP_ID = context.Request.Params["EPUIP_ID"];
string ORG_ID = context.Request.Params["ORG_ID"];
string EXTEND1 = context.Request.Params["EXTEND1"];
string EXTEND2 = context.Request.Params["EXTEND2"];
string EXTEND3 = context.Request.Params["EXTEND3"];
string EXTEND4 = context.Request.Params["EXTEND4"];
string NAME = context.Request.Params["NAME"];
string ADDR = context.Request.Params["ADDR"];
string FOUND_DATE = context.Request.Params["FOUND_DATE"];
string IS_DOORWAY = context.Request.Params["IS_DOORWAY"];
string IS_Attendance = context.Request.Params["IS_Attendance"];
string DVCADDRESS = context.Request.Params["DVCADDRESS"];
string DVCPORT = context.Request.Params["DVCPORT"];
string USERNAME = context.Request.Params["USERNAME"];
string PASSWORD = context.Request.Params["PASSWORD"];
string SERVICEADDR = context.Request.Params["SERVICEADDR"];
//现场设备与机构绑定表
FangYar.Model.OA.TBL_EPUIP_ORG model = new FangYar.Model.OA.TBL_EPUIP_ORG();
model.ID = ID;
model.EPUIP_ID = EPUIP_ID;
model.ORG_ID = ORG_ID;
model.EXTEND1 = EXTEND1;
model.EXTEND2 = EXTEND2;
model.EXTEND3 = EXTEND3;
model.EXTEND4 = EXTEND4;
model.NAME = NAME;
model.ADDR = ADDR;
model.FOUND_DATE = FOUND_DATE;
model.IS_DOORWAY = IS_DOORWAY;
model.IS_Attendance = IS_Attendance;
model.DVCADDRESS = DVCADDRESS;
model.DVCPORT = DVCPORT;
model.USERNAME = USERNAME;
model.PASSWORD = PASSWORD;
model.SERVICEADDR = SERVICEADDR;
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 DelEpu(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string EpuList = context.Request.Params["EpuList"];
string[] EpuArray = EpuList.Split(',');
string EpuListString = "";
for (int i = 0; i < EpuArray.Length; i++)
{
if (i == 0)
{
EpuListString = "'" + EpuArray[i] + "'";
}
else
{
EpuListString += ",'" + EpuArray[i] + "'";
}
}
if (bll.DeleteList(EpuListString))
{
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;
}
}
}
}