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

233 lines
8.8 KiB

using FangYar.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// HumanFaceHandler 人脸识别服务器一般处理程序
/// </summary>
public class HumanFaceHandler : IHttpHandler
{
private FangYar.BLL.TBL_HUMANFACESERVER bll = new FangYar.BLL.TBL_HUMANFACESERVER();
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<FangYar.Model.TBL_HUMANFACESERVER_MO>> retMo = new JsonRetMo<List<FangYar.Model.TBL_HUMANFACESERVER_MO>>() { code = "0", data = new List<FangYar.Model.TBL_HUMANFACESERVER_MO>(), 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 += "( SERVER_NAME like '%" + keyword + "%' or REMARK 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 SERVER_IP = context.Request.Params["SERVER_IP"] + "";//服务器IP
string SERVER_NAME = context.Request.Params["s_Name"] + "";//服务器名称
string REMARK = context.Request.Params["REMARK"] + ""; //备注
//
FangYar.Model.TBL_HUMANFACESERVER_MO model = new Model.TBL_HUMANFACESERVER_MO();
model.ORG_ID = ORG_ID;
model.ORG_NAME = ORG_NAME;
model.SERVER_IP = SERVER_IP;
model.SERVER_NAME = SERVER_NAME;
model.REMARK = REMARK;
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 SERVER_IP = context.Request.Params["SERVER_IP"] + "";//服务器IP
string SERVER_NAME = context.Request.Params["s_Name"] + "";//服务器名称
string REMARK = context.Request.Params["REMARK"] + ""; //备注
//
FangYar.Model.TBL_HUMANFACESERVER_MO model = new Model.TBL_HUMANFACESERVER_MO();
model.ID = id;
model.ORG_ID = ORG_ID;
model.ORG_NAME = ORG_NAME;
model.SERVER_IP = SERVER_IP;
model.SERVER_NAME = SERVER_NAME;
model.REMARK = REMARK;
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;
}
}
}
}