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

144 lines
5.7 KiB

using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// OaLeaveHandler 的摘要说明
/// </summary>
public class SentryHandler : IHttpHandler
{
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 "getPersonAccByOrgId":
returnstr = getPersonAccByOrgId(context);
break;
case "getLeaveModelByLeaveId":
returnstr = getLeaveModelByLeaveId(context);
break;
}
context.Response.Write(returnstr);
}
//人员:根据机构ID获取员工出营区记录
private string getPersonAccByOrgId(HttpContext context)
{
string returnstr = "";
try
{
FangYar.BLL.TBL_PERSONACCESS pbll = new FangYar.BLL.TBL_PERSONACCESS();
FangYar.BLL.OA.TBL_EPUIP_ORG ebll = new FangYar.BLL.OA.TBL_EPUIP_ORG();
string OrgId = context.Request.Params["OrgId"];
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 = "";
if (!string.IsNullOrEmpty(OrgId))
{
where += " org_id ='" + OrgId + "'";
}
DataTable edt = ebll.getEpuIpByOrgId(OrgId, "0", "0");
string epuip_s = "";
for (int i = 0; i < edt.Rows.Count; i++)
{
if (i == 0)
{
epuip_s += edt.Rows[i]["EPUIP_ID"].ToString();
}
else
{
epuip_s += "," + edt.Rows[i]["EPUIP_ID"].ToString();
}
}
if (!string.IsNullOrEmpty(epuip_s))
{
if (where != null)
{
where += " and ";
}
where += "instr('," + epuip_s + ",',',' || extend3 || ',')<>0 ";
}
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = pbll.GetRecordCount(where);
returnstr += "\"count\":" + count + ",\"data\":";
DataTable dt = pbll.getPersonAccListByOrgIdEpuId(pageIndex, pageSize, where, " START_TIMESTAMP DESC ");
string data = "[";
for (int i = 0; i < dt.Rows.Count; i++)
{
data += "{\"ID\":\"" + dt.Rows[i]["ID"].ToString() + "\",";
data += "\"NAME\":\"" + dt.Rows[i]["NAME"].ToString() + "\",";
data += "\"LEAVE_ID\":\"" + dt.Rows[i]["LEAVE_ID"].ToString() + "\",";
data += "\"ISOUT\":\"" + dt.Rows[i]["ISOUT"].ToString() + "\",";
data += "\"PICTURE_URL\":\"" + dt.Rows[i]["PICTURE_URL"].ToString() + "\",";
data += "\"START_TIME\":\"" + dt.Rows[i]["START_TIME"].ToString() + "\"}";
if (i != dt.Rows.Count - 1)
{
data += ",";
}
}
returnstr += data + "]}";
}
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 getLeaveModelByLeaveId(HttpContext context)
{
string returnstr = "";
try
{
FangYar.BLL.OA_LEAVE lbll = new FangYar.BLL.OA_LEAVE();
string leaveId = context.Request.Params["leaveId"];
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
FangYar.Model.OA_LEAVE data = lbll.GetModel(leaveId);
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, "哨兵信息操作请求", "获取请假信息异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "哨兵信息操作请求", "获取请假信息");
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}