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 { /// /// OaLeaveHandler 的摘要说明 /// public class ZYVisitorHandler : IHttpHandler { private FangYar.BLL.TBL_VISITOR bll = new FangYar.BLL.TBL_VISITOR(); public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string action = context.Request.Params["Action"]; string returnstr = ""; switch (action) { case "List": returnstr = visList(context); break; case "editWait": returnstr = editWait(context); break; case "GetVisitorWeek": returnstr = GetVisitorWeek(context); break; } context.Response.Write(returnstr); } //查询 private string visList(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 list = bll.QueryList(pageIndex, pageSize, where, ""); for (int i = 0; i < list.Count; i++) { string pic1 = "", pic2 = "", pic3 = "", pic4 = ""; 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); } if (list[i].OUTPIC != null && list[i].OUTPIC.ToString() != "") { pic1 = Convert.ToBase64String((byte[])list[i].OUTPIC); } if (list[i].INPIC != null && list[i].INPIC.ToString() != "") { pic2 = Convert.ToBase64String((byte[])list[i].INPIC); } 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 + "\",\"VED_MAN\":\"" + list[i].VED_MAN + "\","; data += "\"VED_MAN\":\"" + list[i].VED_MAN + "\",\"VED_ID\":\"" + list[i].VED_ID + "\",\"REASON\":\"" + list[i].REASON + "\",\"GOODS\":\"" + list[i].GOODS + "\","; data += "\"DRICAR\":\"" + list[i].DRICAR + "\",\"TRAVELNUM\":\"" + list[i].TRAVELNUM + "\",\"ABOUTTIME\":\"" + list[i].ABOUTTIME + "\",\"REGISTERTIME\":\"" + list[i].REGISTERTIME + "\","; data += "\"INTIME\":\"" + list[i].INTIME + "\",\"OUTTIME\":\"" + list[i].OUTTIME + "\",\"ACTUALTIME\":\"" + list[i].ACTUALTIME + "\",\"STATE\":\"" + list[i].STATE + "\","; data += "\"APPROVALTIME\":\"" + list[i].APPROVALTIME + "\",\"QRINFO\":\"" + list[i].QRINFO + "\",\"INMACHINEID\":\"" + list[i].INMACHINEID + "\",\"INADDR\":\"" + list[i].INADDR + "\","; data += "\"OUTMACHINEID\":\"" + list[i].OUTMACHINEID + "\",\"OUTADDR\":\"" + list[i].OUTADDR + "\",\"EXTEND1\":\"" + list[i].EXTEND1 + "\",\"EXTEND2\":\"" + list[i].EXTEND2 + "\","; data += "\"EXTEND3\":\"" + list[i].EXTEND3 + "\",\"EXTEND4\":\"" + list[i].EXTEND4 + "\","; data += "\"ID_PIC\":\"" + pic1 + "\",\"V_PIC\":\"" + pic2 + "\","; data += "\"OUTPIC\":\"" + pic3 + "\",\"INPIC\":\"" + pic4 + "\"}"; if (i != list.Count - 1) { data += ","; } } returnstr += data + "]"; } returnstr += "}"; } catch { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]"; } return returnstr; } //访客审批 private string editWait(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string taskId = context.Request.Params["taskId"]; string waitId = context.Request.Params["waitId"]; string state = context.Request.Params["state"]; string sort = context.Request.Params["sort"]; string aOpinion = context.Request.Params["a_opinion"]; string isOver = context.Request.Params["isOver"]; FangYar.Model.OA_WAITPROCESSED model = new Model.OA_WAITPROCESSED(); model.ID = waitId; model.TASK_ID = taskId; model.STATE = state; model.SORT = Convert.ToInt32(sort); model.A_OPINION = aOpinion; if (bll.editWait(model, isOver)) { msg = "审批成功!"; code = 1; } else { msg = "审批失败!"; } } catch { msg = "审批失败!"; } returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; return returnstr; } //获取访客数量趋势 private string GetVisitorWeek(HttpContext context) { string returnstr = ""; try { returnstr = "{\"code\":1,\"msg\":\"\","; returnstr += "\"data\":"; string ORG_ID = context.Request.Params["ORG_ID"]; string where = "1=1"; where += " and (ORG_ID ='" + ORG_ID + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + ORG_ID + "') )"; returnstr += JsonConvert.SerializeObject(bll.TotalDaysAlarm(7, where)); returnstr += "}"; } catch { returnstr = "{\"code\":-1,\"msg\":\"\","; returnstr += "}"; } return returnstr; } public bool IsReusable { get { return false; } } } }