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.
160 lines
6.9 KiB
160 lines
6.9 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;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class VisitorInHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.OA.TBL_VISITOR_IN bll = new FangYar.BLL.OA.TBL_VISITOR_IN();
|
|
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 = visInList(context);
|
|
break;
|
|
case "getVisInTree":
|
|
returnstr = getVisInTree(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//根据OrgId获取访客信息Tree
|
|
private string getVisInTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getVisInTree(orgId);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "访客信息操作请求", "根据OrgId获取访客信息Tree异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "访客信息操作请求", "根据OrgId获取访客信息Tree");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//查询
|
|
private string visInList(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
|
|
{
|
|
//认证机推送过来的数据
|
|
string data = "[";
|
|
List<FangYar.Model.OA.TBL_VISITOR_IN> list = bll.QueryList(pageIndex, pageSize, where, " REGISTERTIME DESC");
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
|
|
string pic1 = "", pic2 = "";
|
|
if (list[i].ID_PIC != null && list[i].ID_PIC.ToString() != "")
|
|
{
|
|
pic1 = Convert.ToBase64String((byte[])list[i].ID_PIC);
|
|
}
|
|
if (list[i].V_PIC != null && list[i].V_PIC.ToString() != "")
|
|
{
|
|
pic2 = Convert.ToBase64String((byte[])list[i].V_PIC);
|
|
}
|
|
//System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
|
|
//DateTime dt = startTime.AddSeconds(long.Parse(list[i].REGISTERTIME));
|
|
|
|
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
|
long mTime = long.Parse(list[i].REGISTERTIME + "0000");
|
|
TimeSpan toNow = new TimeSpan(mTime);
|
|
string REGTIME = startTime.Add(toNow).ToString("yyyy/MM/dd HH:mm:ss");
|
|
data += "{\"ID\":\"" + list[i].ID + "\",\"NAME\":\"" + list[i].NAME + "\",\"SEX\":\"" + list[i].SEX + "\",\"AGE\":\"" + list[i].AGE + "\",\"UNIT\":\"" + list[i].UNIT + "\",\"NATION\":\"" + list[i].NATION + "\",\"ADDR\":\"" + list[i].ADDR + "\",\"H_REG\":\"" + list[i].H_REG + "\",";
|
|
data += "\"ID_NUM\":\"" + list[i].ID_NUM + "\",\"ORG_ID\":\"" + list[i].ORG_ID + "\",\"M_ID\":\"" + list[i].M_ID + "\",\"M_ADDR\":\"" + list[i].M_ADDR + "\",";
|
|
data += "\"GOODS\":\"" + list[i].GOODS + "\",\"DRICAR\":\"" + list[i].DRICAR + "\",\"REGISTERTIME\":\"" + list[i].REGISTERTIME + "\",\"REGTIME\":\"" + REGTIME + "\",\"STATE\":\"" + list[i].STATE + "\",";
|
|
data += "\"ID_PIC\":\"" + pic1 + "\",\"V_PIC\":\"" + pic2 + "\"}";
|
|
if (i != list.Count - 1)
|
|
{
|
|
data += ",";
|
|
}
|
|
}
|
|
returnstr += data + "]";
|
|
}
|
|
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;
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|