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.
140 lines
5.2 KiB
140 lines
5.2 KiB
using FangYar.Common;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// SysOperationLogHandler 的摘要说明 用户操作日志信息
|
|
/// </summary>
|
|
public class SysOperationLogHandler : 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 "GetList":
|
|
returnstr = GetList(context);
|
|
break;
|
|
|
|
case "GetInfoName":
|
|
returnstr = GetInfoName(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string GetInfoName(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string sqlStr = " SELECT Info_Name from tbl_sys_operation_log GROUP BY Info_Name ";
|
|
|
|
var dt = ClickHouseHelper.Execute(sqlStr);
|
|
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":" + JsonHelper.ToJson(dt) + "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"" + e.Message + "\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "操作日志请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "操作日志请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
//查询
|
|
private string GetList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string keyword = context.Request.Params["keywords"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string Info_Type = context.Request.Params["Info_Type"];
|
|
string Info_Name = context.Request.Params["Info_Name"];
|
|
string searchTime = context.Request.Params["searchTime"];
|
|
string endTime = context.Request.Params["endTime"];
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
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 whereStr = " where 1=1 ";
|
|
///信息类型:0、查询;1、新增;2、修改;3、删除;4、异常信息;5、其他
|
|
if (!string.IsNullOrWhiteSpace(Info_Type))
|
|
{
|
|
whereStr += " and Info_Type='" + Info_Type + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(Info_Name))
|
|
{
|
|
whereStr += " and Info_Name='" + Info_Name + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(keyword))
|
|
{
|
|
whereStr += " and Url_Form like '%" + keyword + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(searchTime))
|
|
{
|
|
whereStr += " and createtime >= '" + searchTime + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(endTime))
|
|
{
|
|
whereStr += " and createtime <= '" + endTime + "' ";
|
|
}
|
|
|
|
string sqlCount = " SELECT count(1) FROM default.tbl_sys_operation_log " + whereStr;
|
|
|
|
var dtCount = ClickHouseHelper.Execute(sqlCount);
|
|
|
|
|
|
|
|
string sqlData = " SELECT * FROM default.tbl_sys_operation_log " + whereStr + " order by createtime desc limit " + startIndex + "," + endIndex;
|
|
|
|
var dtData = ClickHouseHelper.Execute(sqlData);
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":" + dtCount.Rows[0][0] + ",\"data\":" + JsonHelper.ToJson(dtData) + "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"" + e.Message + "\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "操作日志请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "操作日志请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|