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

527 lines
19 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// ToTreeHandler 的摘要说明
/// </summary>
public class ToTreeHandler : IHttpHandler
{
private FangYar.BLL.ZHSQ.FolderBLL bll = new BLL.ZHSQ.FolderBLL();
private FangYar.BLL.ToTree_BLL blltree = new BLL.ToTree_BLL();
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 "FolderTree":
returnstr = GetFolderTree(context);
break;
case "OrgTree":
returnstr = GetOrgTree(context);
break;
case "OrgNodeTree":
returnstr = GetOrgNodeTree(context);
break;
case "UserOrgNodeTree":
returnstr = GetUserOrgNodeTree(context);
break;
case "AreaTree":
returnstr = GetAreaTree(context);
break;
case "AreaNodeTree":
returnstr = GetAreaNodeTree(context);
break;
case "UserLowerAreaNodeTree":
returnstr = GetUserLowerAreaNodeTree(context);
break;
case "FolderNodeTree":
returnstr = GetFolderNodeTree(context);
break;
case "UserFolderNodeTree":
returnstr = GetUserFolderNodeTree(context);
break;
case "HYNodeTree":
returnstr = GetHYNodeTree(context);
break;
}
context.Response.Write(returnstr);
}
//自定义设备目录树
private string GetFolderTree(HttpContext context)
{
string returnstr = "";
try
{
string treeid = context.Request.Params["treeid"];
string where = null;
if (!string.IsNullOrEmpty(treeid))
{
where = " F_CODE = " + treeid;
}
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
list = blltree.GetTree("F_CODE", "F_FID", "F_NAME", "ZHSQ_FOLDER_INFO", where, list);
returnstr = "{\"data\":";
if (list.Count == 0)
{
returnstr += "[]";
}
else
{
returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "树结构查询操作请求", "自定义设备目录树异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "树结构查询操作请求", "自定义设备目录树");
return returnstr;
}
//组织机构树
private string GetOrgTree(HttpContext context)
{
string returnstr = "";
try
{
string treeid = context.Request.Params["treeid"];
string where = null;
//if (!string.IsNullOrEmpty(treeid))
//{
// where = " ORG_CODE = " + treeid;
//}
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
list = blltree.GetTree("ORG_CODE", "PID", "ORG_NAME", "TBL_SYS_ORG", where, list);
returnstr = "{\"data\":";
if (list.Count == 0)
{
returnstr += "[]";
}
else
{
returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "树结构查询操作请求", "组织机构树异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "树结构查询操作请求", "组织机构树");
return returnstr;
}
//行政区划树
private string GetAreaTree(HttpContext context)
{
string returnstr = "";
try
{
string treeid = context.Request.Params["treeid"];
string where = null;
if (!string.IsNullOrEmpty(treeid))
{
where = " PID = '" + treeid + "'";
}
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
list = blltree.GetTree("AREA_CODE", "PID", "AREA_NAME", "TBL_SYS_AREA", where, list);
returnstr = "{\"data\":";
if (list.Count == 0)
{
returnstr += "[]";
}
else
{
returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "树结构查询操作请求", "行政区划树异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "树结构查询操作请求", "行政区划树");
return returnstr;
}
//行政区划树
private string GetAreaNodeTree(HttpContext context)
{
string returnstr = "";
try
{
string treeid = context.Request.Params["id"];
string where = null;
if (!string.IsNullOrEmpty(treeid))
{
where = " PID = '" + treeid + "'";
}
else
{
where = " PID = '" + -1 + "'";
}
where += " order by AREA_NAME ";
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
list = blltree.GetNodeTree("AREA_CODE", "PID", "AREA_NAME", "TBL_SYS_AREA", where);
if (list.Count == 0)
{
returnstr = "[]";
}
else
{
returnstr = FangYar.Common.JsonHelper.ToJson(list);
}
}
catch (Exception e)
{
returnstr = "[]";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "树结构查询操作请求", "行政区划树异常;" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "树结构查询操作请求", "行政区划树");
return returnstr;
}
//行政区划树
private string GetUserLowerAreaNodeTree(HttpContext context)
{
string returnstr = "";
try
{
string treeid = context.Request.Params["id"];
Model.LoginUserModel loginuser = FangYar.WebUI.WebCommon.HttpUtil.GetUser(context);
if (loginuser != null)
{
Model.TBL.TBL_SYS_ORG_Model orgmodel = new BLL.TBL.SysOrgBLL().GetModelByID(loginuser.OrgID);
string where = " AREA_CODE = '" + orgmodel.AREA_ID + "' "; ;
//if (!string.IsNullOrEmpty(treeid))
//{
// where += " and PID = '" + treeid + "'";
//}
//else
//{
// where += " and PID = '" + -1 + "'";
//}
where += " order by AREA_NAME ";
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
list = blltree.GetNodeTree("AREA_CODE", "PID", "AREA_NAME", "TBL_SYS_AREA", where);
if (list.Count == 0)
{
returnstr = "[]";
}
else
{
returnstr = FangYar.Common.JsonHelper.ToJson(list);
}
}
else { returnstr = "[]"; }
}
catch (Exception e)
{
returnstr = "[]";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "树结构查询操作请求", "行政区划树异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "树结构查询操作请求", "行政区划树");
return returnstr;
}
//机构树
private string GetOrgNodeTree(HttpContext context)
{
string returnstr = "";
try
{
string treeid = context.Request.Params["id"];
string where = null;
if (!string.IsNullOrEmpty(treeid))
{
where = " PID = '" + treeid + "'";
}
else
{
where = " PID = '" + -1 + "'";
}
where += " order by ORG_NAME ";
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
list = blltree.GetNodeTree("ORG_CODE", "PID", "ORG_NAME", "TBL_SYS_ORG", where);
if (list.Count == 0)
{
returnstr = "[]";
}
else
{
returnstr = FangYar.Common.JsonHelper.ToJson(list);
}
}
catch (Exception e)
{
returnstr = "[]";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "树结构查询操作请求", "机构树异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "树结构查询操作请求", "机构树");
return returnstr;
}
//机构树
private string GetUserOrgNodeTree(HttpContext context)
{
string returnstr = "";
try
{
string treeid = context.Request.Params["id"];
Model.LoginUserModel loginuser = FangYar.WebUI.WebCommon.HttpUtil.GetUser(context);
if (loginuser != null)
{
string where = " ID = '" + loginuser.OrgID + "'";
//if (!string.IsNullOrEmpty(treeid))
//{
// where = " PID = '" + treeid + "'";
//}
//else
//{
// where = " PID = '" + -1 + "'";
//}
where += " order by ORG_NAME ";
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
list = blltree.GetNodeTree("ORG_CODE", "PID", "ORG_NAME", "TBL_SYS_ORG", where);
if (list.Count == 0)
{
returnstr = "[]";
}
else
{
returnstr = FangYar.Common.JsonHelper.ToJson(list);
}
}
else { returnstr = "[]"; }
}
catch (Exception e)
{
returnstr = "[]";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "树结构查询操作请求", "机构树异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "树结构查询操作请求", "机构树");
return returnstr;
}
//行业树
private string GetHYNodeTree(HttpContext context)
{
string returnstr = "";
try
{
string treeid = context.Request.Params["id"];
string where = " MOD_CODE='HYTYPE'";
if (!string.IsNullOrEmpty(treeid))
{
where += " and DIC_FID = '" + treeid + "'";
}
else
{
where += " and DIC_FID = '" + -1 + "'";
}
where += " order by DIC_ORDER ";
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
list = blltree.GetNodeTree("DIC_VALUE", "DIC_FID", "DIC_TEXT", "TBL_SYS_DICDETAIL", where);
if (list.Count == 0)
{
returnstr = "[]";
}
else
{
returnstr = FangYar.Common.JsonHelper.ToJson(list);
}
}
catch (Exception e)
{
returnstr = "[]";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "树结构查询操作请求", "行业树异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "树结构查询操作请求", "行业树");
return returnstr;
}
//目录树
private string GetFolderNodeTree(HttpContext context)
{
string returnstr = "";
try
{
string treeid = context.Request.Params["id"];
Model.LoginUserModel loginuser = FangYar.WebUI.WebCommon.HttpUtil.GetUser(context);
if (loginuser == null) { }
string where = null;
if (!string.IsNullOrEmpty(treeid))
{
where = " F_FID = '" + treeid + "'";
}
else
{
where = " F_FID = '" + -1 + "'";
}
where += " order by F_ORDER ";
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
list = blltree.GetNodeTree("F_CODE", "F_FID", "F_NAME", "ZHSQ_FOLDER_INFO", where);
if (list.Count == 0)
{
returnstr = "[]";
}
else
{
returnstr = FangYar.Common.JsonHelper.ToJson(list);
}
}
catch (Exception e)
{
returnstr = "[]";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "树结构查询操作请求", "目录树异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "树结构查询操作请求", "目录树");
return returnstr;
}
//目录树
private string GetUserFolderNodeTree(HttpContext context)
{
string returnstr = "";
try
{
string id = context.Request.Params["id"];
string treeid = context.Request.Params["treeid"];
Model.LoginUserModel loginuser = FangYar.WebUI.WebCommon.HttpUtil.GetUser(context);
if (loginuser != null)
{
string where = " ORG_ID = '" + loginuser.OrgID + "' ";
if (string.IsNullOrEmpty(treeid))
{
where += " and F_FID = '" + -1 + "'";
}
else if (!string.IsNullOrEmpty(id))
{
where += " and F_FID = '" + id + "'";
}
where += " order by F_ORDER ";
if (string.IsNullOrEmpty(treeid) || (!string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(treeid)))
{
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
list = blltree.GetNodeTree("F_CODE", "F_FID", "F_NAME", "ZHSQ_FOLDER_INFO", where);
if (list.Count == 0)
{
returnstr = "[]";
}
else
{
returnstr = FangYar.Common.JsonHelper.ToJson(list);
}
}
else { returnstr = "[]"; }
}
else { returnstr = "[]"; }
}
catch (Exception e)
{
returnstr = "[]";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "树结构查询操作请求", "目录树异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "树结构查询操作请求", "目录树");
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}