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

339 lines
13 KiB

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
{
/// <summary>
/// OaLeaveHandler 的摘要说明
/// </summary>
public class ZYFireHydrantHandler : IHttpHandler
{
private FangYar.BLL.FIRE.FIRE_HYDRANT bll = new FangYar.BLL.FIRE.FIRE_HYDRANT();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string action = context.Request.Params["Action"];
string returnstr = "";
switch (action)
{
case "HydrantList":
returnstr = GetHydrantList(context);
break;
case "Add":
returnstr = AddHydrant(context);
break;
case "Edit":
returnstr = EditHydrant(context);
break;
case "Del":
returnstr = DelHydrant(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string GetHydrantList(HttpContext context)
{
string returnstr = "";
try
{
string OrgId = context.Request.Params["OrgId"];
string keyword = context.Request.Params["keywords"];
string STATE = context.Request.Params["STATE"];
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(STATE))
{
if (where != null)
{
where += " and ";
}
where += " STATE = '" + 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<FangYar.Model.FIRE.FIRE_HYDRANT> list = bll.QueryList(pageIndex, pageSize, where, "");
List<FangYar.Model.FIRE.FIRE_HYDRANT> list2 = bll.QueryList(pageIndex, pageSize, where, "");
returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
}
return returnstr;
}
//添加消火栓
private string AddHydrant(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 HYD_NO = context.Request.Params["HYD_NO"];
string NAME = context.Request.Params["NAME"];
string ADDR = context.Request.Params["ADDR"];
string CRA_HEIGHT = context.Request.Params["CRA_HEIGHT"];
string LON = context.Request.Params["LON"];
string LAT = context.Request.Params["LAT"];
string A_STATE = context.Request.Params["A_STATE"];
string SUB_ROAD = context.Request.Params["SUB_ROAD"];
string PLA_FORM = context.Request.Params["PLA_FORM"];
string INT_FORM = context.Request.Params["INT_FORM"];
string I_FORM = context.Request.Params["I_FORM"];
string SUB_M = context.Request.Params["SUB_M"];
string M_FORM = context.Request.Params["M_FORM"];
string M_PRE = context.Request.Params["M_PRE"];
string M_DIA = context.Request.Params["M_DIA"];
string FLOW_SIZE = context.Request.Params["FLOW_SIZE"];
string SUP_UNIT = context.Request.Params["SUP_UNIT"];
string IS_COM = context.Request.Params["IS_COM"];
string IS_ANT = context.Request.Params["IS_ANT"];
string IS_LEAK = context.Request.Params["IS_LEAK"];
string IS_IMP = context.Request.Params["IS_IMP"];
string IS_DAM = context.Request.Params["IS_DAM"];
string IS_ID = context.Request.Params["IS_ID"];
string IS_PAINT = context.Request.Params["IS_PAINT"];
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_HYDRANT model = new Model.FIRE.FIRE_HYDRANT();
model.ID = ID;
model.HYD_NO = HYD_NO;
model.NAME = NAME;
model.ADDR = ADDR;
model.LON = LON;
model.LAT = LAT;
model.A_STATE = A_STATE;
model.SUB_ROAD = SUB_ROAD;
model.PLA_FORM = PLA_FORM;
model.INT_FORM = INT_FORM;
model.I_FORM = I_FORM;
model.SUB_M = SUB_M;
model.M_FORM = M_FORM;
model.M_PRE = M_PRE;
model.M_DIA = M_DIA;
model.FLOW_SIZE = FLOW_SIZE;
model.SUP_UNIT = SUP_UNIT;
model.IS_COM = IS_COM;
model.IS_ANT = IS_ANT;
model.IS_LEAK = IS_LEAK;
model.IS_IMP = IS_IMP;
model.IS_DAM = IS_DAM;
model.IS_ID = IS_ID;
model.IS_PAINT = IS_PAINT;
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
{
msg = "添加失败:装备编码有重复数据";
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
return returnstr;
}
//修改消火栓
private string EditHydrant(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 HYD_NO = context.Request.Params["HYD_NO"];
string NAME = context.Request.Params["NAME"];
string ADDR = context.Request.Params["ADDR"];
string CRA_HEIGHT = context.Request.Params["CRA_HEIGHT"];
string LON = context.Request.Params["LON"];
string LAT = context.Request.Params["LAT"];
string A_STATE = context.Request.Params["A_STATE"];
string SUB_ROAD = context.Request.Params["SUB_ROAD"];
string PLA_FORM = context.Request.Params["PLA_FORM"];
string INT_FORM = context.Request.Params["INT_FORM"];
string I_FORM = context.Request.Params["I_FORM"];
string SUB_M = context.Request.Params["SUB_M"];
string M_FORM = context.Request.Params["M_FORM"];
string M_PRE = context.Request.Params["M_PRE"];
string M_DIA = context.Request.Params["M_DIA"];
string FLOW_SIZE = context.Request.Params["FLOW_SIZE"];
string SUP_UNIT = context.Request.Params["SUP_UNIT"];
string IS_COM = context.Request.Params["IS_COM"];
string IS_ANT = context.Request.Params["IS_ANT"];
string IS_LEAK = context.Request.Params["IS_LEAK"];
string IS_IMP = context.Request.Params["IS_IMP"];
string IS_DAM = context.Request.Params["IS_DAM"];
string IS_ID = context.Request.Params["IS_ID"];
string IS_PAINT = context.Request.Params["IS_PAINT"];
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_HYDRANT model = new Model.FIRE.FIRE_HYDRANT();
model.ID = ID;
model.HYD_NO = HYD_NO;
model.NAME = NAME;
model.ADDR = ADDR;
model.LON = LON;
model.LAT = LAT;
model.A_STATE = A_STATE;
model.SUB_ROAD = SUB_ROAD;
model.PLA_FORM = PLA_FORM;
model.INT_FORM = INT_FORM;
model.I_FORM = I_FORM;
model.SUB_M = SUB_M;
model.M_FORM = M_FORM;
model.M_PRE = M_PRE;
model.M_DIA = M_DIA;
model.FLOW_SIZE = FLOW_SIZE;
model.SUP_UNIT = SUP_UNIT;
model.IS_COM = IS_COM;
model.IS_ANT = IS_ANT;
model.IS_LEAK = IS_LEAK;
model.IS_IMP = IS_IMP;
model.IS_DAM = IS_DAM;
model.IS_ID = IS_ID;
model.IS_PAINT = IS_PAINT;
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
{
msg = "修改失败!";
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
return returnstr;
}
//删除消火栓
private string DelHydrant(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string HydrantList = context.Request.Params["HydrantList"];
string[] HydrantArray = HydrantList.Split(',');
string HydrantListString = "";
for (int i = 0; i < HydrantArray.Length; i++)
{
if (i == 0)
{
HydrantListString = "'" + HydrantArray[i] + "'";
}
else
{
HydrantListString += ",'" + HydrantArray[i] + "'";
}
}
if (bll.DeleteList(HydrantListString))
{
msg = "删除成功!";
code = 1;
}
else
{
msg = "删除失败!";
}
}
catch
{
msg = "删除失败!";
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}