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.
346 lines
14 KiB
346 lines
14 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// FolderHandler 的摘要说明
|
|
/// </summary>
|
|
public class FolderHandler : IHttpHandler
|
|
{
|
|
|
|
private FangYar.BLL.ZHSQ.FolderBLL bll = new BLL.ZHSQ.FolderBLL();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "设备目录操作请求", "");
|
|
|
|
context.Response.ContentType = "text/json";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
switch (action)
|
|
{
|
|
case "List":
|
|
returnstr = GetModelList(context);
|
|
break;
|
|
case "TreeList":
|
|
returnstr = GetTreeList(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddModel(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditModel(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = DelModel(context);
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
//查询
|
|
private string GetModelList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
FangYar.Model.LoginUserModel user = FangYar.WebUI.WebCommon.HttpUtil.GetUser(context);
|
|
if (user != null)
|
|
{
|
|
string keywords = context.Request.Params["keywords"];
|
|
string limit = context.Request.Params["limit"];
|
|
string page = context.Request.Params["page"];
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(limit)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = " ORG_ID = '" + user.OrgID + "' ";
|
|
if (!string.IsNullOrEmpty(keywords))
|
|
{
|
|
where = " and F_CODE like '" + keywords + "' or F_NAME like '" + keywords + "' ";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.Count(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.ZHSQ.ZHSQ_FOLDER_INFO_Model> list = bll.QueryList(pageIndex, pageSize, where, null);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
else { returnstr = "{\"code\":-2,\"msg\":\"登录超时\",\"count\":0,\"data\":[]}"; }
|
|
}
|
|
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 GetTreeList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
FangYar.Model.LoginUserModel user = FangYar.WebUI.WebCommon.HttpUtil.GetUser(context);
|
|
|
|
|
|
if (user != null)
|
|
{
|
|
string keywords = context.Request.Params["keywords"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
string limit = context.Request.Params["limit"];
|
|
string page = context.Request.Params["page"];
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(limit)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = " ORG_CODE = '" + user.OrgID + "' ";
|
|
if (!string.IsNullOrEmpty(keywords))
|
|
{
|
|
where = " and ORG_ID = '" + keywords + "' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(treeID))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( F_FID ='" + treeID + "' or F_CODE ='" + treeID + "' ) ";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.Count(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.ZHSQ.ZHSQ_FOLDER_INFO_Model> list = bll.QueryList(pageIndex, pageSize, where, null);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
else { returnstr = "{\"code\":-2,\"msg\":\"登录超时\",\"count\":0,\"data\":[]}"; }
|
|
}
|
|
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 AddModel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
FangYar.Model.LoginUserModel user = FangYar.WebUI.WebCommon.HttpUtil.GetUser(context);
|
|
if (user != null)
|
|
{
|
|
string fCode = context.Request.Params["fCode"];
|
|
string fName = context.Request.Params["fName"];
|
|
string orgID = context.Request.Params["orgID"];
|
|
string fDes = context.Request.Params["fDes"];
|
|
string FID = context.Request.Params["FID"];
|
|
string User = context.Request.Params["User"];
|
|
string fOrder = context.Request.Params["fOrder"];
|
|
int fcode = 0;
|
|
int order = 1;
|
|
if (!string.IsNullOrEmpty(fCode))
|
|
{
|
|
fcode = int.Parse(fCode);
|
|
}
|
|
if (!string.IsNullOrEmpty(fOrder))
|
|
{
|
|
order = int.Parse(fOrder);
|
|
}
|
|
if (string.IsNullOrEmpty(fCode))
|
|
{
|
|
msg = "编号不能为空!";
|
|
}
|
|
|
|
else if (string.IsNullOrEmpty(fName))
|
|
{
|
|
msg = "名称不能为空!";
|
|
}
|
|
else
|
|
{
|
|
|
|
FangYar.Model.ZHSQ.ZHSQ_FOLDER_INFO_Model model = new Model.ZHSQ.ZHSQ_FOLDER_INFO_Model();
|
|
model.ID = Guid.NewGuid().ToString("N");
|
|
model.F_CODE = fcode;
|
|
model.F_NAME = fName;
|
|
model.F_FID = FID;
|
|
model.ORG_ID = user.OrgID;
|
|
model.F_DES = fDes;
|
|
model.USER_CODE = user.UserCode;
|
|
model.F_ORDER = order;
|
|
model.F_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
if (bll.Add(model))
|
|
{
|
|
msg = "添加成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "添加失败!";
|
|
}
|
|
}
|
|
}
|
|
else { returnstr = "{\"code\":-2,\"msg\":\"登录超时\",\"count\":0,\"data\":[]}"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "添加失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "设备目录操作请求", "添加异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "设备目录操作请求", "添加");
|
|
return returnstr;
|
|
}
|
|
//修改
|
|
private string EditModel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
FangYar.Model.LoginUserModel user = FangYar.WebUI.WebCommon.HttpUtil.GetUser(context);
|
|
if (user != null)
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
string fCode = context.Request.Params["fCode"];
|
|
string fName = context.Request.Params["fName"];
|
|
string orgID = context.Request.Params["orgID"];
|
|
string fDes = context.Request.Params["fDes"];
|
|
string FID = context.Request.Params["FID"];
|
|
string fOrder = context.Request.Params["fOrder"];
|
|
string User = context.Request.Params["User"];
|
|
int fcode = 0;
|
|
int order = 1;
|
|
if (!string.IsNullOrEmpty(fCode))
|
|
{
|
|
fcode = int.Parse(fCode);
|
|
}
|
|
if (!string.IsNullOrEmpty(fOrder))
|
|
{
|
|
order = int.Parse(fOrder);
|
|
}
|
|
if (string.IsNullOrEmpty(fCode))
|
|
{
|
|
msg = "编号不能为空!";
|
|
}
|
|
|
|
else if (string.IsNullOrEmpty(fName))
|
|
{
|
|
msg = "名称不能为空!";
|
|
}
|
|
else
|
|
{
|
|
|
|
FangYar.Model.ZHSQ.ZHSQ_FOLDER_INFO_Model model = bll.GetModelByID(ID);
|
|
if (model == null)
|
|
{
|
|
msg = "记录不存在!";
|
|
}
|
|
else
|
|
{
|
|
model.F_CODE = fcode;
|
|
model.F_NAME = fName;
|
|
model.F_FID = FID;
|
|
model.F_DES = fDes;
|
|
model.USER_CODE = User;
|
|
model.F_ORDER = order;
|
|
|
|
if (bll.Edit(model))
|
|
{
|
|
msg = "修改成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败!";
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else { returnstr = "{\"code\":-2,\"msg\":\"登录超时\",\"count\":0,\"data\":[]}"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "修改失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "设备目录操作请求", "修改异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "设备目录操作请求", "修改");
|
|
return returnstr;
|
|
}
|
|
//删除
|
|
private string DelModel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string UIDList = context.Request.Params["UIDList"];
|
|
UIDList = UIDList.Replace(",", "','");
|
|
if (bll.Delete(UIDList))
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|