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 { /// /// OaLeaveHandler 的摘要说明 /// public class FireUnitHandler : IHttpHandler { private FangYar.BLL.FIRE.FIRE_E_L_UNIT bll = new FangYar.BLL.FIRE.FIRE_E_L_UNIT(); 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 "UnitList": returnstr = GetUnitList(context); break; case "Add": returnstr = AddUnit(context); break; case "Edit": returnstr = EditUnit(context); break; case "Del": returnstr = DelUnit(context); break; } context.Response.Write(returnstr); } //查询 private string GetUnitList(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["OrgId"]; string Type = context.Request.Params["Type"]; string keyword = context.Request.Params["keywords"]; string treeID = context.Request.Params["treeID"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; 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, mod_code = null; if (!string.IsNullOrEmpty(treeID) && treeID != OrgId) { OrgId = treeID; } if (Type == "0") { mod_code = "EUNITTYPE"; } else if (Type == "1") { mod_code = "LUNITTYPE"; } if (!string.IsNullOrEmpty(Type)) { if (where != null) { where += " and "; } where += "TYPE = '" + Type + "'"; } if (!string.IsNullOrEmpty(OrgId)) { if (where != null) { where += " and "; } if (is_content == "1") { where += " org_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 + "' "; } } 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 list = bll.QueryList(pageIndex, pageSize, where, " NAME ", mod_code); returnstr += FangYar.Common.JsonHelper.ToJson(list); } 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; } //添加应急联动联勤保障单位 private string AddUnit(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string USER_ID = context.Request.Params["USER_ID"]; string ID = Guid.NewGuid().ToString("N"); string TYPE = context.Request.Params["TYPE"]; string NAME = context.Request.Params["NAME"]; string UNIT_TYPE = context.Request.Params["UNIT_TYPE"]; string ADDR = context.Request.Params["ADDR"]; string PHONE = context.Request.Params["PHONE"]; string UNIT_PER = context.Request.Params["UNIT_PER"]; string ORG_ID = context.Request.Params["ORG_ID"]; //应急联动联勤保障单位表 FangYar.Model.FIRE.FIRE_E_L_UNIT model = new Model.FIRE.FIRE_E_L_UNIT(); model.ID = ID; model.TYPE = TYPE; model.NAME = NAME; model.UNIT_TYPE = UNIT_TYPE; model.ADDR = ADDR; model.PHONE = PHONE; model.UNIT_PER = UNIT_PER; model.ORG_ID = ORG_ID; model.A_PER = USER_ID; if (bll.Add(model)) { 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.Add, "应急联动联勤保障单位操作请求", "添加应急联动联勤保障单位"); return returnstr; } //修改应急联动联勤保障单位 private string EditUnit(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string USER_ID = context.Request.Params["USER_ID"]; string ID = context.Request.Params["ID"]; string TYPE = context.Request.Params["TYPE"]; string NAME = context.Request.Params["NAME"]; string UNIT_TYPE = context.Request.Params["UNIT_TYPE"]; string ADDR = context.Request.Params["ADDR"]; string PHONE = context.Request.Params["PHONE"]; string UNIT_PER = context.Request.Params["UNIT_PER"]; string ORG_ID = context.Request.Params["ORG_ID"]; //应急联动联勤保障单位表 FangYar.Model.FIRE.FIRE_E_L_UNIT model = new Model.FIRE.FIRE_E_L_UNIT(); model.ID = ID; model.TYPE = TYPE; model.NAME = NAME; model.UNIT_TYPE = UNIT_TYPE; model.ADDR = ADDR; model.PHONE = PHONE; model.UNIT_PER = UNIT_PER; model.ORG_ID = ORG_ID; model.U_PER = USER_ID; if (bll.Update(model)) { 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; } //删除应急联动联勤保障单位 private string DelUnit(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string UnitList = context.Request.Params["UnitList"]; string[] UnitArray = UnitList.Split(','); string UnitListString = ""; for (int i = 0; i < UnitArray.Length; i++) { if (i == 0) { UnitListString = "'" + UnitArray[i] + "'"; } else { UnitListString += ",'" + UnitArray[i] + "'"; } } if (bll.DeleteList(UnitListString)) { msg = "删除成功!"; code = 1; } else { msg = "删除失败!"; } } catch (Exception e) { msg = "删除失败!"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "应急联动联勤保障单位操作请求", "删除应急联动联勤保障单位异常:" + e); } returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "应急联动联勤保障单位操作请求", "删除应急联动联勤保障单位"); return returnstr; } public bool IsReusable { get { return false; } } } }