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

120 lines
4.5 KiB

11 months ago
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 ZYPersonAccessHandler : IHttpHandler
{
private FangYar.BLL.TBL_PERSONACCESS bll = new FangYar.BLL.TBL_PERSONACCESS();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string action = context.Request.Params["Action"];
string returnstr = "";
switch (action)
{
case "List":
returnstr = perList(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string perList(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 = " 1=1 ";
//if (!string.IsNullOrEmpty(OrgId))
//{
// where += " and (ORG_ID ='" + OrgId + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + OrgId + "') )";
//}
//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.TBL_PERSONACCESS> list = bll.QueryList(pageIndex, pageSize, where, "");
//returnstr += FangYar.Common.JsonHelper.ToJson(list);
string data = "[";
List<FangYar.Model.TBL_PERSONACCESS> list = bll.QueryList(pageIndex, pageSize, where, "");
for (int i = 0; i < list.Count; i++)
{
string pic1 = "";
string pic2 = "";
if (list[i].PICTURE != null && list[i].PICTURE.ToString() != "")
{
pic1 = Convert.ToBase64String((byte[])list[i].PICTURE);
}
if (list[i].CLOSEUP_PIC != null && list[i].CLOSEUP_PIC.ToString() != "")
{
pic2 = Convert.ToBase64String((byte[])list[i].CLOSEUP_PIC);
}
data += "{\"ID\":\"" + list[i].ID + "\",\"NAME\":\"" + list[i].NAME + "\",\"EMPID\":\"" + list[i].EMPID + "\",\"SEX\":\"" + list[i].SEX + "\",\"PROF\":\"" + list[i].PROF + "\",\"START_TIMESTAMP\":\"" + list[i].START_TIMESTAMP + "\",\"START_TIME\":\"" + list[i].START_TIME + "\",";
data += "\"CAMERA_ID\":\"" + list[i].CAMERA_ID + "\",\"ORG_ID\":\"" + list[i].ORG_ID + "\",\"INOROUT\":\"" + list[i].INOROUT + "\",\"ADDR\":\"" + list[i].ADDR + "\",";
data += "\"PICTURE\":\"" + pic1 + "\",\"CLOSEUP_PIC\":\"" + pic2 + "\"}";
if (i != list.Count - 1)
{
data += ",";
}
}
returnstr += data + "]";
}
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
}
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}