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.
236 lines
8.9 KiB
236 lines
8.9 KiB
using FangYar.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// TblDrillDeviceHandler 的摘要说明
|
|
/// </summary>
|
|
public class TblDrillDeviceHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.TBL_DRILL_DEVICE bll = new FangYar.BLL.TBL_DRILL_DEVICE();
|
|
|
|
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 = List(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = Add(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = Edit(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = Del(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
//查询
|
|
private string List(HttpContext context)
|
|
{
|
|
JsonRetMo<List<TBL_DRILL_DEVICE>> retMo = new JsonRetMo<List<TBL_DRILL_DEVICE>>() { code = "0", data = new List<TBL_DRILL_DEVICE>(), msg = "" };
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
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(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += " DEVICE_NAME like '%" + keyword + "%' ";
|
|
}
|
|
|
|
retMo.count = bll.GetRecordCount(where);
|
|
retMo.data = (bll.QueryList(pageIndex, pageSize, where, ""));
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
retMo.code = "1";
|
|
retMo.msg = "Error:" + ex;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "训练采集设备操作请求", "查询异常:" + ex);
|
|
}
|
|
string returnstr = FangYar.Common.JsonHelper.ToJSON1(retMo);
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "训练采集设备操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
//添加
|
|
private string Add(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
|
|
string ORG_ID = context.Request.Params["org_id"] + "";//机构id
|
|
string ORG_NAME = context.Request.Params["org_name"] + "";//机构名称
|
|
string EMP_ID = context.Request.Params["EMP_ID"] + "";//负责人
|
|
string DEVICE_NUM = context.Request.Params["DEVICE_NUM"] + "";//设备数量
|
|
string DEVICE_TYPE = context.Request.Params["DEVICE_TYPE"] + ""; //设备类型
|
|
string DEVICE_NAME = context.Request.Params["DEVICE_NAME"] + ""; //设备名称
|
|
|
|
//
|
|
TBL_DRILL_DEVICE model = new TBL_DRILL_DEVICE();
|
|
|
|
model.ORG_ID = ORG_ID;
|
|
model.ORG_NAME = ORG_NAME;
|
|
model.EMP_ID = EMP_ID;
|
|
model.DEVICE_NUM = DEVICE_NUM;
|
|
model.DEVICE_TYPE = DEVICE_TYPE;
|
|
model.DEVICE_NAME = DEVICE_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 Edit(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string id = context.Request.Params["id"];//摄像头表id
|
|
|
|
string ORG_ID = context.Request.Params["org_id"] + "";//机构id
|
|
string ORG_NAME = context.Request.Params["org_name"] + "";//机构名称
|
|
string EMP_ID = context.Request.Params["EMP_ID"] + "";//负责人
|
|
string DEVICE_NUM = context.Request.Params["DEVICE_NUM"] + "";//设备数量
|
|
string DEVICE_TYPE = context.Request.Params["DEVICE_TYPE"] + ""; //设备类型
|
|
string DEVICE_NAME = context.Request.Params["DEVICE_NAME"] + ""; //设备名称
|
|
|
|
//
|
|
TBL_DRILL_DEVICE model = new TBL_DRILL_DEVICE();
|
|
model.ID = id;
|
|
model.ORG_ID = ORG_ID;
|
|
model.ORG_NAME = ORG_NAME;
|
|
model.EMP_ID = EMP_ID;
|
|
model.DEVICE_NUM = DEVICE_NUM;
|
|
model.DEVICE_TYPE = DEVICE_TYPE;
|
|
model.DEVICE_NAME = DEVICE_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 Del(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string EmpList = context.Request.Params["cameraList"];
|
|
string[] EmpArray = EmpList.Split(',');
|
|
string EmpListString = "";
|
|
for (int i = 0; i < EmpArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
EmpListString = "'" + EmpArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
EmpListString += ",'" + EmpArray[i] + "'";
|
|
}
|
|
}
|
|
if (bll.DeleteList(EmpListString))
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|