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

352 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 FirePatrolInspectorHandler : IHttpHandler
{
private FangYar.BLL.FIRE_PATROL_INSPECTOR bll = new FangYar.BLL.FIRE_PATROL_INSPECTOR();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string action = context.Request.Params["Action"];
string returnstr = "";
switch (action)
{
case "List":
returnstr = GetInspectorList(context);
break;
case "Add":
returnstr = AddInspector(context);
break;
case "Edit":
returnstr = EditInspector(context);
break;
case "Del":
returnstr = DelInspector(context);
break;
case "getOrgInspectorTree":
returnstr = getOrgInspectorTree(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string GetInspectorList(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 = " 1=1 ";
if (!string.IsNullOrEmpty(OrgId))
{
where = " org_id in (select o.org_id from fire_org o,(select get_Org_child_list('" + OrgId + "') cids ) s where o.type = '0' and find_in_set(org_id,cids) )";
}
else
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
return returnstr;
}
if (!string.IsNullOrEmpty(keyword))
{
where += " and ( NAME like '%" + keyword + "%' or PHONE like '%" + keyword + "%' or UNIT_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_INSPECTOR> list = 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 AddInspector(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ID = Guid.NewGuid().ToString("N");
string NAME = context.Request.Params["NAME"];
string TYPE = context.Request.Params["TYPE"];
string USERS_UID = context.Request.Params["USERS_UID"];
string USERS_PWD = context.Request.Params["USERS_PWD"];
string RulesId = context.Request.Params["RulesId"];
string EMP_ID = context.Request.Params["EMP_ID"];
string ORG_ID = context.Request.Params["ORG_ID"];
string ORG_NAME = context.Request.Params["ORG_NAME"];
string CITY = context.Request.Params["CITY"];
string CITY_NAME = context.Request.Params["CITY_NAME"];
string PHONE = context.Request.Params["PHONE"];
string UNIT_NAME = context.Request.Params["UNIT_NAME"];
string REMARKS = context.Request.Params["REMARKS"];
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"];
string EXTENDCODE3 = context.Request.Params["EXTENDCODE3"];
string EXTENDCODE4 = context.Request.Params["EXTENDCODE4"];
//巡查员表
FangYar.Model.FIRE_PATROL_INSPECTOR model = new Model.FIRE_PATROL_INSPECTOR();
model.ID = ID;
model.NAME = NAME;
model.TYPE = TYPE;
model.USERS_UID = USERS_UID;
model.EMP_ID = EMP_ID;
model.ORG_ID = ORG_ID;
model.ORG_NAME = ORG_NAME;
model.CITY = CITY;
model.CITY_NAME = CITY_NAME;
model.PHONE = PHONE;
model.UNIT_NAME = UNIT_NAME;
model.REMARKS = REMARKS;
model.EXTENDCODE1 = EXTENDCODE1;
model.EXTENDCODE2 = EXTENDCODE2;
model.EXTENDCODE3 = EXTENDCODE3;
model.EXTENDCODE4 = EXTENDCODE4;
FangYar.BLL.TBL.SysUsersBLL ubll = new BLL.TBL.SysUsersBLL();
//user表
FangYar.Model.TBL.TBL_SYS_USERS_Model umodel = new Model.TBL.TBL_SYS_USERS_Model();
umodel.USERS_UID = USERS_UID;
umodel.USERS_PWD = FangYar.Common.Md5.GetMD5String(USERS_PWD);
umodel.USERS_NAME = NAME;
umodel.USERS_WEEK = "1,2,3,4,5,6,0";
umodel.USERS_TIME = "00:00:00 - 23:59:59";
umodel.USERS_STATE = "0";
umodel.USERS_EMAIL = "";
umodel.USERS_MOBILE = "";
umodel.ORG_ID = ORG_ID;
umodel.IS_THIS = "0";
umodel.IS_SUPER = "5,";
FangYar.BLL.TBL.SysEmpBLL empbll = new BLL.TBL.SysEmpBLL();
//emp表
FangYar.Model.TBL.TBL_SYS_EMP_Model empmodel = new Model.TBL.TBL_SYS_EMP_Model();
empmodel.ID = Guid.NewGuid().ToString("N");
empmodel.USERS_UID = USERS_UID;
empmodel.EMP_NAME = NAME;
empmodel.ORG_ID = ORG_ID;
empmodel.IS_DEL = "1";
empmodel.EMP_MOBILE = PHONE;
FangYar.BLL.TBL.SysUSerRulesBLL urbll = new BLL.TBL.SysUSerRulesBLL();
//userrole表
FangYar.Model.TBL.TBL_SYS_USERSRULES_Model urmodel = new Model.TBL.TBL_SYS_USERSRULES_Model();
urmodel.ID = Guid.NewGuid().ToString("N");
urmodel.USERS_UID = USERS_UID;
urmodel.APP_ID = "0001";
urmodel.RULES_TYPE = "2";
urmodel.RULES_ID = RulesId;
//1、巡查员表
//2、人员表
//3、账号表
//4、账号角色表
if (ubll.Add(umodel))
{
if (bll.Add(model) && empbll.Add(empmodel) && urbll.Add(urmodel))
{
msg = "添加成功!";
code = 1;
}
else { msg = "添加失败!"; }
}
else
{
msg = "添加失败,登录账号已存在!";
}
}
catch (Exception e)
{
msg = "添加失败!";
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
return returnstr;
}
//修改巡查员
private string EditInspector(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ID = context.Request.Params["ID"];
string NAME = context.Request.Params["NAME"];
string TYPE = context.Request.Params["TYPE"];
string USERS_UID = context.Request.Params["USERS_UID"];
string EMP_ID = context.Request.Params["EMP_ID"];
string ORG_ID = context.Request.Params["ORG_ID"];
string ORG_NAME = context.Request.Params["ORG_NAME"];
string CITY = context.Request.Params["CITY"];
string CITY_NAME = context.Request.Params["CITY_NAME"];
string PHONE = context.Request.Params["PHONE"];
string UNIT_NAME = context.Request.Params["UNIT_NAME"];
string REMARKS = context.Request.Params["REMARKS"];
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"];
string EXTENDCODE3 = context.Request.Params["EXTENDCODE3"];
string EXTENDCODE4 = context.Request.Params["EXTENDCODE4"];
//消防水资源巡查员表
FangYar.Model.FIRE_PATROL_INSPECTOR model = new Model.FIRE_PATROL_INSPECTOR();
model.ID = ID;
model.NAME = NAME;
model.TYPE = TYPE;
model.USERS_UID = USERS_UID;
model.EMP_ID = EMP_ID;
model.ORG_ID = ORG_ID;
model.ORG_NAME = ORG_NAME;
model.CITY = CITY;
model.CITY_NAME = CITY_NAME;
model.PHONE = PHONE;
model.UNIT_NAME = UNIT_NAME;
model.REMARKS = REMARKS;
model.EXTENDCODE1 = EXTENDCODE1;
model.EXTENDCODE2 = EXTENDCODE2;
model.EXTENDCODE3 = EXTENDCODE3;
model.EXTENDCODE4 = EXTENDCODE4;
if (bll.Update(model))
{
msg = "修改成功!";
code = 1;
}
else { msg = "修改失败!"; }
}
catch
{
msg = "修改失败!";
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
return returnstr;
}
//删除巡查员
private string DelInspector(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
//删除
//1、巡查员表
//2、人员表
//3、账号表
//4、账号角色表
string ID = context.Request.Params["ID"];
string USERS_UID = context.Request.Params["USERS_UID"];
if (bll.Delete(ID))
{
FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL();
FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL();
FangYar.BLL.TBL.SysUSerRulesBLL urBll = new FangYar.BLL.TBL.SysUSerRulesBLL();
if (userBll.Delete(USERS_UID) && empBll.DeleteByUid(USERS_UID) && urBll.DeleteByUid(USERS_UID))
{
msg = "删除成功!";
code = 1;
}
else
{
msg = "删除失败!";
}
}
else
{
msg = "删除失败!";
}
}
catch
{
msg = "删除失败!";
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
return returnstr;
}
//机构巡查员Tree
private string getOrgInspectorTree(HttpContext context)
{
string returnstr = "";
try
{
string orgId = context.Request.Params["OrgId"];
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
DataTable data = bll.getOrgInspectorTree(orgId);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
}
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}