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.
401 lines
15 KiB
401 lines
15 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaKnowledgeHandler 的摘要说明
|
|
/// </summary>
|
|
public class OaKnowledgeHandler : IHttpHandler
|
|
{
|
|
|
|
|
|
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 "ListType":
|
|
returnstr = ListType(context);
|
|
break;
|
|
case "ListInfo":
|
|
returnstr = ListInfo(context);
|
|
break;
|
|
case "SaveTypeInfo":
|
|
returnstr = SaveTypeInfo(context);
|
|
break;
|
|
case "SaveInfo":
|
|
returnstr = SaveInfo(context);
|
|
break;
|
|
case "DelType":
|
|
returnstr = DelType(context);
|
|
break;
|
|
case "DelInfo":
|
|
returnstr = DelInfo(context);
|
|
break;
|
|
case "GetTypeById":
|
|
returnstr = GetTypeById(context);
|
|
break;
|
|
case "GetInfoById":
|
|
returnstr = GetInfoById(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 查询类型集合
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string ListType(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string sqlStr = " SELECT * from oa_knowledge_type where Type_State='0' ";
|
|
|
|
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sqlStr);
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = dt.Rows.Count;
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 查询信息集合
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string ListInfo(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
|
|
string keyword = context.Request.Params["keyword"];
|
|
string TYPE_ID = context.Request.Params["TYPE_ID"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
string orgId = context.Request.Params["orgId"];
|
|
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); }
|
|
|
|
int startIndex = 0;
|
|
int endIndex = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
startIndex = (pageIndex - 1) * pageSize;
|
|
endIndex = pageSize;
|
|
|
|
string where = " where INFO_STATE = '0' ";
|
|
|
|
|
|
string sqlCount = " SELECT count(1) from oa_knowledge_info ";
|
|
string sqlStr = " SELECT *,(SELECT TYPE_NAME from oa_knowledge_type WHERE id = TYPE_ID LIMIT 1) TYPE_NAME from oa_knowledge_info ";
|
|
|
|
//是否包含下级
|
|
if (is_content == "1")
|
|
{
|
|
where += " and find_in_set(org_id,cids) ";
|
|
|
|
sqlCount += ",(select get_Org_child_list('" + orgId + "') cids ) s ";
|
|
sqlStr += ",(select get_Org_child_list('" + orgId + "') cids ) s ";
|
|
}
|
|
else
|
|
{
|
|
where += " and org_id='" + orgId + "' ";
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(keyword))
|
|
{
|
|
where += " and ( INFO_TITLE like '%" + keyword + "%'or INFO_REMARK like '%" + keyword + "%' or FIRE_NAME like '%" + keyword + "%' ) ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(TYPE_ID))
|
|
{
|
|
where += " and TYPE_ID='" + TYPE_ID + "' ";
|
|
}
|
|
|
|
sqlCount = sqlCount + where;
|
|
sqlStr = sqlStr + where + " LIMIT " + startIndex + " , " + endIndex;
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = Convert.ToInt32(FangYar.Common.MySqlHelper.QueryTable(sqlCount).Rows[0][0] + "");
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sqlStr);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除类型
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string DelType(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
|
|
string id = context.Request.Params["id"];
|
|
|
|
string sqlStr = " update oa_knowledge_type set Type_State='-1' where id = '" + id + "' ";
|
|
|
|
FangYar.Common.MySqlHelper.Execute(sqlStr);
|
|
|
|
returnstr = "{\"code\":1,\"msg\":\"OK\",\"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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除信息
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string DelInfo(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
|
|
string id = context.Request.Params["id"];
|
|
|
|
string sqlStr = " update oa_knowledge_info set INFO_STATE='-1' where id = '" + id + "' ";
|
|
|
|
FangYar.Common.MySqlHelper.Execute(sqlStr);
|
|
|
|
returnstr = "{\"code\":1,\"msg\":\"OK\",\"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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 类型信息保存
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string SaveTypeInfo(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
|
|
string id = context.Request.Params["id"];
|
|
|
|
string Type_Name = context.Request.Params["Type_Name"];
|
|
string Type_Sort = context.Request.Params["Type_Sort"];
|
|
|
|
|
|
string sqlStr = " update oa_knowledge_type set Type_Name='" + Type_Name + "',Type_Sort='" + Type_Sort + "' where id = '" + id + "' ";
|
|
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
sqlStr = " insert into oa_knowledge_type (ID,Type_Name,Type_Sort) values(uuid(),'" + Type_Name + "','" + Type_Sort + "') ";
|
|
}
|
|
|
|
|
|
FangYar.Common.MySqlHelper.Execute(sqlStr);
|
|
|
|
returnstr = "{\"code\":1,\"msg\":\"OK\",\"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;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 信息保存
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string SaveInfo(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
|
|
string id = context.Request.Params["id"];
|
|
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string TYPE_ID = context.Request.Params["TYPE_ID"];
|
|
string INFO_TITLE = context.Request.Params["INFO_TITLE"];
|
|
string INFO_REMARK = context.Request.Params["INFO_REMARK"];
|
|
string FIRE_URL = context.Request.Params["FIRE_URL"];
|
|
string FIRE_NAME = context.Request.Params["FIRE_NAME"];
|
|
|
|
|
|
string sqlStr = " update oa_knowledge_info set INFO_TITLE='" + INFO_TITLE + "',INFO_REMARK='" + INFO_REMARK +
|
|
"',FIRE_URL='" + FIRE_URL + "',FIRE_NAME='" + FIRE_NAME + "' where id = '" + id + "' ";
|
|
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
sqlStr = " insert into oa_knowledge_info (ID,ORG_ID,TYPE_ID,INFO_TITLE,INFO_REMARK,FIRE_URL,FIRE_NAME) values(uuid(),'" + ORG_ID + "','" +
|
|
TYPE_ID + "','" + INFO_TITLE + "','" + INFO_REMARK + "','" + FIRE_URL + "','" + FIRE_NAME + "') ";
|
|
}
|
|
|
|
|
|
FangYar.Common.MySqlHelper.Execute(sqlStr);
|
|
|
|
returnstr = "{\"code\":1,\"msg\":\"OK\",\"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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据ID查询
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string GetTypeById(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
|
|
string id = context.Request.Params["id"];
|
|
string sqlStr = " SELECT * from oa_knowledge_type where id = '" + id + "' ";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
returnstr += "\"count\":" + 0 + ",\"data\":";
|
|
|
|
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sqlStr);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "印章管理操作请求", "根据ID查询类型异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "印章管理操作请求", "根据ID查询类型");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据ID查询
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string GetInfoById(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
|
|
string id = context.Request.Params["id"];
|
|
string sqlStr = " SELECT * from oa_knowledge_info where id = '" + id + "' ";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
returnstr += "\"count\":" + 0 + ",\"data\":";
|
|
|
|
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sqlStr);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "印章管理操作请求", "根据ID查询信息异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "印章管理操作请求", "根据ID查询信息");
|
|
return returnstr;
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|