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

272 lines
11 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;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// FireLeaveHandler 的摘要说明
/// </summary>
public class FirePatrolPlanHandler : IHttpHandler
{
private FangYar.BLL.FIRE_PATROL_PLAN bll = new FangYar.BLL.FIRE_PATROL_PLAN();
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 = getPlanlist(context);
break;
case "Add":
returnstr = AddPlan(context);
break;
case "Edit":
returnstr = EditPlan(context);
break;
case "Del":
returnstr = DelPlan(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string getPlanlist(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 = null;
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) )";
if (!string.IsNullOrEmpty(keyword))
{
where += " and NAME like '%" + keyword + "%' or USERS_NAME like '%" + keyword + "%' ";
}
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = bll.GetRecordCount(where);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
List<FangYar.Model.FIRE_PATROL_PLAN> list = bll.QueryList(pageIndex, pageSize, where, null);
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 AddPlan(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string planId = Guid.NewGuid().ToString("N");
string USER_ID = context.Request.Params["UserId"];
string orgId = context.Request.Params["orgId"];
string CITY = context.Request.Params["CITY"];
string NAME = context.Request.Params["NAME"];
string CYCLE = context.Request.Params["CYCLE"];
string WORK_DAY = context.Request.Params["WORK_DAY"];
string S_TIME = context.Request.Params["S_TIME"];
string E_TIME = context.Request.Params["E_TIME"];
string USERS_UID = context.Request.Params["USERS_UID"];
string USERS_NAME = context.Request.Params["USERS_NAME"];
string SPOTS = context.Request.Params["SPOTS"];
string SPOT_IDS = context.Request.Params["SPOT_IDS"];
string SPOT_NAMES = context.Request.Params["SPOT_NAMES"];
string STATE = context.Request.Params["STATE"];
//巡查计划表
FangYar.Model.FIRE_PATROL_PLAN model = new Model.FIRE_PATROL_PLAN();
model.ID = planId;
model.NAME = NAME;
model.CYCLE = CYCLE;
model.WORK_DAY = WORK_DAY;
model.S_TIME = S_TIME;
model.E_TIME = E_TIME;
model.USERS_UID = USERS_UID;
model.USERS_NAME = USERS_NAME;
model.SPOTS = SPOTS;
model.SPOT_IDS = SPOT_IDS;
model.SPOT_NAMES = SPOT_NAMES;
model.A_PER = USER_ID;
model.ORG_ID = orgId;
model.CITY = CITY;
model.STATE = STATE;
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 EditPlan(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ID = context.Request.Params["ID"];
string USER_ID = context.Request.Params["UserId"];
string orgId = context.Request.Params["orgId"];
string CITY = context.Request.Params["CITY"];
string NAME = context.Request.Params["NAME"];
string CYCLE = context.Request.Params["CYCLE"];
string WORK_DAY = context.Request.Params["WORK_DAY"];
string S_TIME = context.Request.Params["S_TIME"];
string E_TIME = context.Request.Params["E_TIME"];
string USERS_UID = context.Request.Params["USERS_UID"];
string USERS_NAME = context.Request.Params["USERS_NAME"];
string SPOTS = context.Request.Params["SPOTS"];
string SPOT_IDS = context.Request.Params["SPOT_IDS"];
string SPOT_NAMES = context.Request.Params["SPOT_NAMES"];
string STATE = context.Request.Params["STATE"];
//巡查计划表
FangYar.Model.FIRE_PATROL_PLAN model = new Model.FIRE_PATROL_PLAN();
model.ID = ID;
model.NAME = NAME;
model.CYCLE = CYCLE;
model.WORK_DAY = WORK_DAY;
model.S_TIME = S_TIME;
model.E_TIME = E_TIME;
model.USERS_UID = USERS_UID;
model.USERS_NAME = USERS_NAME;
model.SPOTS = SPOTS;
model.SPOT_IDS = SPOT_IDS;
model.SPOT_NAMES = SPOT_NAMES;
model.ORG_ID = orgId;
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 DelPlan(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string PlanList = context.Request.Params["PlanList"];
string[] PlanArray = PlanList.Split(',');
string PlanListString = "";
for (int i = 0; i < PlanArray.Length; i++)
{
if (i == 0)
{
PlanListString = "'" + PlanArray[i] + "'";
}
else
{
PlanListString += ",'" + PlanArray[i] + "'";
}
}
if (bll.DeleteList(PlanListString))
{
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;
}
}
}
}