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

282 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;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// OaLeaveHandler 的摘要说明
/// </summary>
public class FireExpertHandler : IHttpHandler
{
private FangYar.BLL.FIRE.FIRE_EXPERT bll = new FangYar.BLL.FIRE.FIRE_EXPERT();
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 "ExpertList":
returnstr = GetExpertList(context);
break;
case "Add":
returnstr = AddExpert(context);
break;
case "Edit":
returnstr = EditExpert(context);
break;
case "Del":
returnstr = DelExpert(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string GetExpertList(HttpContext context)
{
string returnstr = "";
try
{
string OrgId = context.Request.Params["OrgId"];
string keyword = context.Request.Params["keywords"];
string FIELD = context.Request.Params["FIELD"];
string treeID = context.Request.Params["treeID"];
string is_content = context.Request.Params["is_content"];
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;
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
{
OrgId = treeID;
}
if (!string.IsNullOrEmpty(OrgId))
{
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(FIELD))
{
if (where != null)
{
where += " and ";
}
where += " FIELD = '" + FIELD + "' ";
}
if (!string.IsNullOrEmpty(keyword))
{
if (where != null)
{
where += " and ";
}
where += "( name like '%" + keyword + "%' or UNIT_NAME like '%" + keyword + "%' or UNIT_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_EXPERT> 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 AddExpert(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 NAME = context.Request.Params["NAME"];
string FIELD = context.Request.Params["FIELD"];
string PROF = context.Request.Params["PROF"];
string UNIT_NAME = context.Request.Params["UNIT_NAME"];
string UNIT_ADDR = context.Request.Params["UNIT_ADDR"];
string M_PHONE = context.Request.Params["M_PHONE"];
string F_PHONE = context.Request.Params["F_PHONE"];
string ORG_ID = context.Request.Params["ORG_ID"];
string PHOTO_PATH = context.Request.Params["PHOTO"];
//专家信息表
FangYar.Model.FIRE.FIRE_EXPERT model = new Model.FIRE.FIRE_EXPERT();
model.ID = ID;
model.NAME = NAME;
model.FIELD = FIELD;
model.PROF = PROF;
model.UNIT_NAME = UNIT_NAME;
model.UNIT_ADDR = UNIT_ADDR;
model.M_PHONE = M_PHONE;
model.F_PHONE = F_PHONE;
model.ORG_ID = ORG_ID;
model.A_PER = USER_ID;
model.PHOTO = PHOTO_PATH;
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 EditExpert(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 NAME = context.Request.Params["NAME"];
string FIELD = context.Request.Params["FIELD"];
string PROF = context.Request.Params["PROF"];
string UNIT_NAME = context.Request.Params["UNIT_NAME"];
string UNIT_ADDR = context.Request.Params["UNIT_ADDR"];
string M_PHONE = context.Request.Params["M_PHONE"];
string F_PHONE = context.Request.Params["F_PHONE"];
string ORG_ID = context.Request.Params["ORG_ID"];
string PHOTO_PATH = context.Request.Params["PHOTO"];
//专家信息表
FangYar.Model.FIRE.FIRE_EXPERT model = new Model.FIRE.FIRE_EXPERT();
model.ID = ID;
model.NAME = NAME;
model.FIELD = FIELD;
model.PROF = PROF;
model.UNIT_NAME = UNIT_NAME;
model.UNIT_ADDR = UNIT_ADDR;
model.M_PHONE = M_PHONE;
model.F_PHONE = F_PHONE;
model.ORG_ID = ORG_ID;
model.U_PER = USER_ID;
model.PHOTO = PHOTO_PATH;
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 DelExpert(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ExpertList = context.Request.Params["ExpertList"];
string[] ExpertArray = ExpertList.Split(',');
string ExpertListString = "";
for (int i = 0; i < ExpertArray.Length; i++)
{
if (i == 0)
{
ExpertListString = "'" + ExpertArray[i] + "'";
}
else
{
ExpertListString += ",'" + ExpertArray[i] + "'";
}
}
if (bll.DeleteList(ExpertListString))
{
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;
}
}
}
}