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 FireIntWharfHandler : IHttpHandler { private FangYar.BLL.FIRE.FIRE_INTAKE_WHARF bll = new FangYar.BLL.FIRE.FIRE_INTAKE_WHARF(); 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 "IntWharfList": returnstr = GetIntWharfList(context); break; case "Add": returnstr = AddIntWharf(context); break; case "Edit": returnstr = EditIntWharf(context); break; case "Del": returnstr = DelIntWharf(context); break; } context.Response.Write(returnstr); } //查询取水码头 private string GetIntWharfList(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["OrgId"]; string is_content = context.Request.Params["is_content"]; string keyword = context.Request.Params["keywords"]; string A_STATE = context.Request.Params["A_STATE"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; string treeID = context.Request.Params["treeID"]; 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(treeID)) { OrgId = treeID; } if (!string.IsNullOrEmpty(OrgId)) { if (is_content == "1") { where += " and org_id in (select org_id from fire_org, (SELECT get_Org_child_list('" + OrgId + "') cids) t where find_in_set(ORG_ID, cids))"; } else { where += " and org_id = '" + OrgId + "'"; } } if (!string.IsNullOrEmpty(A_STATE)) { if (where != null) { where += " and "; } where += " A_STATE = '" + A_STATE + "' "; } 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"); 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 AddIntWharf(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 INT_NO = context.Request.Params["INT_NO"]; string NAME = context.Request.Params["NAME"]; string ADDR = context.Request.Params["ADDR"]; string LON = context.Request.Params["LON"]; string LAT = context.Request.Params["LAT"]; string A_STATE = context.Request.Params["A_STATE"]; string SOURCE = context.Request.Params["SOURCE"]; string SUB_ROAD = context.Request.Params["SUB_ROAD"]; string I_FORM = context.Request.Params["I_FORM"]; string I_HEIGHT = context.Request.Params["I_HEIGHT"]; string P_SPACE = context.Request.Params["P_SPACE"]; string P_NUM = context.Request.Params["P_NUM"]; string R_PHOTO = context.Request.Params["R_PHOTO"]; string P_PHOTO = context.Request.Params["P_PHOTO"]; string FOUND_DATE = context.Request.Params["FOUND_DATE"]; string I_RECORD = context.Request.Params["I_RECORD"]; string ORG_ID = context.Request.Params["ORG_ID"]; string CITY = context.Request.Params["CITY"]; string STATE = context.Request.Params["STATE"]; //取水码头表 FangYar.Model.FIRE.FIRE_INTAKE_WHARF model = new Model.FIRE.FIRE_INTAKE_WHARF(); model.ID = ID; model.INT_NO = INT_NO; model.NAME = NAME; model.ADDR = ADDR; model.LON = LON; model.LAT = LAT; model.A_STATE = A_STATE; model.SOURCE = SOURCE; model.SUB_ROAD = SUB_ROAD; model.I_FORM = I_FORM; if (!string.IsNullOrEmpty(I_HEIGHT)) { model.I_HEIGHT = Convert.ToDecimal(I_HEIGHT); } model.P_SPACE = P_SPACE; if (!string.IsNullOrEmpty(P_NUM)) { model.P_NUM = Convert.ToDecimal(P_NUM); } model.R_PHOTO = R_PHOTO; model.P_PHOTO = P_PHOTO; model.FOUND_DATE = FOUND_DATE; model.I_RECORD = I_RECORD; model.ORG_ID = ORG_ID; model.CITY = CITY; model.STATE = STATE; 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 EditIntWharf(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 INT_NO = context.Request.Params["INT_NO"]; string NAME = context.Request.Params["NAME"]; string ADDR = context.Request.Params["ADDR"]; string LON = context.Request.Params["LON"]; string LAT = context.Request.Params["LAT"]; string A_STATE = context.Request.Params["A_STATE"]; string SOURCE = context.Request.Params["SOURCE"]; string SUB_ROAD = context.Request.Params["SUB_ROAD"]; string I_FORM = context.Request.Params["I_FORM"]; string I_HEIGHT = context.Request.Params["I_HEIGHT"]; string P_SPACE = context.Request.Params["P_SPACE"]; string P_NUM = context.Request.Params["P_NUM"]; string R_PHOTO = context.Request.Params["R_PHOTO"]; string P_PHOTO = context.Request.Params["P_PHOTO"]; string FOUND_DATE = context.Request.Params["FOUND_DATE"]; string I_RECORD = context.Request.Params["I_RECORD"]; string ORG_ID = context.Request.Params["ORG_ID"]; string CITY = context.Request.Params["CITY"]; string STATE = context.Request.Params["STATE"]; //取水码头表 FangYar.Model.FIRE.FIRE_INTAKE_WHARF model = new Model.FIRE.FIRE_INTAKE_WHARF(); model.ID = ID; model.INT_NO = INT_NO; model.NAME = NAME; model.ADDR = ADDR; model.LON = LON; model.LAT = LAT; model.A_STATE = A_STATE; model.SOURCE = SOURCE; model.SUB_ROAD = SUB_ROAD; model.I_FORM = I_FORM; if (!string.IsNullOrEmpty(I_HEIGHT)) { model.I_HEIGHT = Convert.ToDecimal(I_HEIGHT); } model.P_SPACE = P_SPACE; if (!string.IsNullOrEmpty(P_NUM)) { model.P_NUM = Convert.ToDecimal(P_NUM); } model.R_PHOTO = R_PHOTO; model.P_PHOTO = P_PHOTO; model.FOUND_DATE = FOUND_DATE; model.I_RECORD = I_RECORD; model.ORG_ID = ORG_ID; model.CITY = CITY; model.STATE = STATE; 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 DelIntWharf(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string IntWharfList = context.Request.Params["IntWharfList"]; string[] IntWharfArray = IntWharfList.Split(','); string IntWharfListString = ""; for (int i = 0; i < IntWharfArray.Length; i++) { if (i == 0) { IntWharfListString = "'" + IntWharfArray[i] + "'"; } else { IntWharfListString += ",'" + IntWharfArray[i] + "'"; } } if (bll.DeleteList(IntWharfListString)) { 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; } } } }