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.
72 lines
3.1 KiB
72 lines
3.1 KiB
4 years ago
|
using System.Text;
|
||
|
using System.Data;
|
||
|
using System;
|
||
|
|
||
|
namespace Common.LogUtil
|
||
|
{
|
||
|
public static class Log
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 记录异常信息
|
||
|
/// </summary>
|
||
|
/// <param name="ex"></param>
|
||
|
public static void Record(LogInformation log)
|
||
|
{
|
||
|
StringBuilder query = new StringBuilder("INSERT INTO T_SYS_DEBUG_LOG(HELPLINK,EXMESSAGE,EXSOURCE,STACKTRACE,TARGETSITE,CREATETIME,OPERATEUSER,EXTENDMESSAGE,SOURCEDEVICE,CLIENTIP) VALUES('{HELPLINK}','{EXMESSAGE}','{EXSOURCE}','{STACKTRACE}','{TARGETSITE}',getdate(),'{OPERATEUSER}','{EXTENDMESSAGE}','{SOURCEDEVICE}','{CLIENTIP}')");
|
||
|
query.Replace("{HELPLINK}", log.HELPLINK);
|
||
|
query.Replace("{EXMESSAGE}", log.EXMESSAGE);
|
||
|
query.Replace("{EXSOURCE}", log.EXSOURCE);
|
||
|
query.Replace("{STACKTRACE}", log.STACKTRACE);
|
||
|
query.Replace("{TARGETSITE}", log.TARGETSITE);
|
||
|
query.Replace("{OPERATEUSER}", log.OPERATEUSER);
|
||
|
query.Replace("{EXTENDMESSAGE}", log.EXTENDMESSAGE);
|
||
|
query.Replace("{SOURCEDEVICE}", log.SOURCEDEVICE);
|
||
|
query.Replace("{CLIENTIP}", log.CLIENTIP);
|
||
|
Data.SqlLite.SqlLiteHelper dal = new Data.SqlLite.SqlLiteHelper();
|
||
|
try
|
||
|
{
|
||
|
using (System.Data.IDbConnection conn = dal.OpenConnection(Common.Config.ConfigSetting.GetDBConnString(1)))
|
||
|
{
|
||
|
dal.ExecuteSql(conn, query.ToString());
|
||
|
}
|
||
|
}
|
||
|
catch { }
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取所有消息记录
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
public static DataTable Read()
|
||
|
{
|
||
|
Data.SqlLite.SqlLiteHelper dal = new Data.SqlLite.SqlLiteHelper();
|
||
|
using (System.Data.IDbConnection conn = dal.OpenConnection(Common.Config.ConfigSetting.GetDBConnString(1)))
|
||
|
{
|
||
|
return dal.QueryReturnDataTable(conn, "SELECT * FROM T_SYS_DEBUG_LOG");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 以分页方式获取消息记录
|
||
|
/// </summary>
|
||
|
/// <param name="pageSize">每页数据条数</param>
|
||
|
/// <param name="pageIndex">要获取数据的页码</param>
|
||
|
/// <param name="pageCount">总页数</param>
|
||
|
/// <param name="rowCount">总行数</param>
|
||
|
/// <returns></returns>
|
||
|
//public static DataTable Read(int pageSize, int pageIndex, out int pageCount, out int rowCount)
|
||
|
//{
|
||
|
// string start = (pageSize * pageIndex).ToString();
|
||
|
|
||
|
// Data.SqlLite.SqlLiteHelper dal = new Data.SqlLite.SqlLiteHelper();
|
||
|
// using (System.Data.IDbConnection conn = dal.OpenConnection(Common.Config.ConfigSetting.GetConnectionString()))
|
||
|
// using (Data.SqlLite.SqlLiteRoutine routine = new Data.SqlLite.SqlLiteRoutine(conn))
|
||
|
// {
|
||
|
// rowCount = (int)routine.GetSingle("SELECT COUNT(1) FROM T_LOG");
|
||
|
// pageCount = (int)Math.Ceiling((decimal)(rowCount / pageSize));
|
||
|
// return routine.QueryReturnDataTable("SELECT * FROM T_LOG LIMIT " + start + "," + pageSize.ToString());
|
||
|
// }
|
||
|
//}
|
||
|
}
|
||
|
}
|