using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Web; namespace FangYar.WebUI.ashx { /// /// SysEmpPolHandler 的摘要说明 /// public class SysEmpPolHandler : IHttpHandler { BLL.TBL.TBL_SYS_EMP_POLBLL bLL = new BLL.TBL.TBL_SYS_EMP_POLBLL(); private FangYar.BLL.TBL.SysEmpBLL bll_Emp = new FangYar.BLL.TBL.SysEmpBLL(); 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 "SetPol": returnstr = SetPol(context); break; case "OrgEmpList": returnstr = GetOrgEmpList(context); break; case "PolLevelList": returnstr = PolLevelList(context); break; case "PolLevelFX": returnstr = PolLevelFX(context); break; } context.Response.Write(returnstr); } //查询 private string List(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["OrgId"]; string keyword = context.Request.Params["keywords"]; string type = context.Request.Params["type"]; 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 + "'"; } if (!string.IsNullOrEmpty(keyword)) { if (where != null) { where += " and "; } where += "( mtitle like '%" + keyword + "%' or mADDR like '%" + keyword + "%')"; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = 0; List list = bLL.PageList(pageIndex, pageSize, where, " mdate desc", ref count); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception ex) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员消防救援衔操作请求", "查询异常:" + ex); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员消防救援衔操作请求", "查询"); return returnstr; } //查询 private string GetOrgEmpList(HttpContext context) { //VIEW_SYS_EMP_POL string returnstr = ""; try { string OrgId = context.Request.Params["OrgId"]; string OrgList = context.Request.Params["OrgList"]; string keyword = context.Request.Params["keywords"]; string treeID = context.Request.Params["treeID"]; string type = context.Request.Params["type"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; string searchTime = context.Request.Params["searchTime"]; string searchAccess = context.Request.Params["searchAccess"]; string is_content = context.Request.Params["is_content"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = null; if (!string.IsNullOrEmpty(treeID) && treeID != OrgId) { if (is_content == "1") { where = "( org_id in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids) ) "; where += " or DEPT_ID in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids) )) "; } else { where = "( ORG_ID = '" + treeID + "'"; where += " or DEPT_ID = '" + treeID + "')"; } } else { if (is_content == "1") { where = " (orgid in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids) ) "; where += " or DEPT_ID in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids) )) "; } else { where = "(ORG_ID = '" + OrgId + "'"; where += " or DEPT_ID = '" + OrgId + "')"; } } if (!string.IsNullOrEmpty(keyword)) { if (where != null) { where += " and "; } where += "( emp_name like '%" + keyword + "%' or idnumber like '%" + keyword + "%')"; } if (!string.IsNullOrEmpty(searchTime)) { string startTime = "", endTime = ""; if (searchTime.IndexOf(" - ") != -1) { startTime = Regex.Split(searchTime, " - ", RegexOptions.IgnoreCase)[0]; endTime = Regex.Split(searchTime, " - ", RegexOptions.IgnoreCase)[1]; } if (!string.IsNullOrEmpty(startTime)) { if (where != null) { where += " and "; } where += "ENLISTED_TIME >= '" + startTime + "'"; } if (!string.IsNullOrEmpty(endTime)) { if (where != null) { where += " and "; } where += "ENLISTED_TIME <= '" + endTime + "'"; } } if (!string.IsNullOrEmpty(searchAccess)) { if (where != null) { where += " and "; } where += "IS_ACCESS = '" + searchAccess + "'"; } if (where != null) { where += " and "; } where += " is_del = '0'"; returnstr = "{\"code\":0,\"msg\":\"\","; int count = 0; List list = bLL.PageListVIEW(pageIndex, pageSize, where, " PNEXTTIME desc", ref count); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch (Exception ex) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员消防救援衔操作请求", "查询异常:" + ex); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员消防救援衔操作请求", "查询"); return returnstr; } private string PolLevelList(HttpContext context) { string returnstr = ""; try { string type = context.Request.Params["type"]; returnstr = "{\"code\":0,\"msg\":\"\","; List list = bLL.PageListPOLLEVEL("1=1", "PNOWLLEVEL asc"); returnstr += "\"data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(list); returnstr += "}"; } catch (Exception ex) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员消防救援衔操作请求", "查询异常:" + ex); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员消防救援衔操作请求", "查询"); return returnstr; } private string PolLevelFX(HttpContext context) { string returnstr = ""; try { string type = context.Request.Params["type"]; returnstr = "{\"code\":0,\"msg\":\"\","; List list = bLL.PageListPOLLEVEL("1=1", "PNOWLLEVEL asc"); returnstr += "\"data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(list); returnstr += "}"; } catch (Exception ex) { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员消防救援衔操作请求", "查询异常:" + ex); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员消防救援衔操作请求", "查询"); return returnstr; } //修改 private string SetPol(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string id = context.Request.Params["id"];// string orgid = context.Request.Params["orgid"];// string puid = context.Request.Params["puid"];// string puname = context.Request.Params["puname"];// string pn1 = context.Request.Params["pn1"];// string pn2 = context.Request.Params["pn2"];// string pt1 = context.Request.Params["pt1"]; // string pt2 = context.Request.Params["pt2"]; // string pt3 = context.Request.Params["pt3"]; // string plv1 = context.Request.Params["plv1"];// string plv2 = context.Request.Params["plv2"];// string ptype = context.Request.Params["ptype"];// FangYar.Model.TBL_SYS_EMP_POL model; bool ifadd = true; if (string.IsNullOrEmpty(id)) { model = new Model.TBL_SYS_EMP_POL(); model.ID = Guid.NewGuid().ToString("N");// } else { model = bLL.GetModelByID(id); if (model != null) { ifadd = false; } else { model = new Model.TBL_SYS_EMP_POL(); model.ID = Guid.NewGuid().ToString("N");// } } model.PUID = puid; model.PUNAME = puname; model.ORG_ID = orgid; model.PTYPE = ptype; model.PNOWNAME = pn1; model.PNOWTIME = DateTime.Parse(pt1); model.PNOWLLEVEL = plv1; model.PNEXTNAME = pn2; model.PNEXTLLEVEL = plv2; model.PNEXTTIME = DateTime.Parse(pt2); model.PREMINDTIME = DateTime.Parse(pt3); model.A_TIME = DateTime.Now; var isset = false; if (ifadd) { isset = bLL.Add(model); } else { isset = bLL.Edit(model); } if (isset) { //更改员工表 //var gis = bll_Emp.Update(new { POL = model.PNOWLLEVEL.ToString() }, it => it.ID == puid); var umo = bll_Emp.UPDPOLByID(model.PNOWLLEVEL, puid); 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; } public bool IsReusable { get { return false; } } } }