This commit is contained in:
104
Epost.DAL/Sys_operate_logDAL.cs
Normal file
104
Epost.DAL/Sys_operate_logDAL.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using Epost.Common;
|
||||
using Epost.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Epost.DAL
|
||||
{
|
||||
public class Sys_operate_logDAL
|
||||
{
|
||||
|
||||
|
||||
DataBaseOpration.OprationSqlDAL db = DB_DLL.GetInstance();
|
||||
#region 分页获取日志列表
|
||||
|
||||
public List<Sys_operate_logModel> GetLogListByPage(string strWhere, string orderby, int startIndex, int endIndex, out int recordCount)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("SELECT * FROM ( ");
|
||||
strSql.Append(" SELECT ROW_NUMBER() OVER (");
|
||||
if (!string.IsNullOrEmpty(orderby.Trim()))
|
||||
{
|
||||
strSql.Append("order by T." + orderby);
|
||||
}
|
||||
else
|
||||
{
|
||||
strSql.Append("order by id desc");
|
||||
}
|
||||
strSql.Append(")AS Row, T.* from Sys_operate_log T WITH(NOLOCK) ");
|
||||
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
||||
{
|
||||
strSql.Append(" WHERE 1=1 " + strWhere);
|
||||
}
|
||||
strSql.Append(" ) TT");
|
||||
strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
|
||||
List<Sys_operate_logModel> list = ModelConvertHelper<Sys_operate_logModel>.ConvertToList(db.GetsqlForDT(strSql.ToString()));
|
||||
|
||||
strSql.Remove(0, strSql.Length);
|
||||
strSql.Append("SELECT COUNT(*) FROM Sys_operate_log AS T ");
|
||||
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
||||
{
|
||||
strSql.AppendFormat(" WHERE 1=1 {0}", strWhere);
|
||||
}
|
||||
|
||||
object obj = db.GetsqlForDT(strSql.ToString()).Rows[0][0];
|
||||
if (obj != null)
|
||||
recordCount = Convert.ToInt32(obj);
|
||||
else
|
||||
recordCount = 0;
|
||||
|
||||
return list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog(GetType(), ex.Message);
|
||||
recordCount = 0;
|
||||
return new List<Sys_operate_logModel>();
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取日志明细
|
||||
|
||||
public List<Sys_operate_logModel> GetLogDetail(int mid)
|
||||
{
|
||||
string sql = string.Format("select * from Sys_operate_log where ID='" + mid + "'");
|
||||
DataTable dt = db.GetsqlForDT(sql);
|
||||
return ModelConvertHelper<Sys_operate_logModel>.ConvertToList(dt);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 添加日志
|
||||
public bool InsertLogDetail(Sys_operate_logModel model)
|
||||
{
|
||||
string sql = string.Format("insert into Sys_operate_log([title],[method],[operate_url],[operate_param],[json_result],[status],[error_msg],[addtime]) " +
|
||||
"values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}' )",
|
||||
model.title, model.method, model.operate_url, model.operate_param, model.json_result, model.status, model.error_msg, model.addtime);
|
||||
long x = db.UpdateSql(sql);
|
||||
|
||||
if (x > 0)
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogInfo("添加日志失败" + sql);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user