📄 dblog.cs
字号:
namespace PowerEasy.Logging
{
using PowerEasy.Common;
using System;
using System.Collections.Generic;
public sealed class DBLog : LogEntry
{
private readonly ILogManager dal = DataAccess.CreateLogManager();
public override void Add(LogInfo info)
{
if (info != null)
{
EncodeInfo(info);
this.dal.Add(info);
}
}
private static void DecodeInfo(LogInfo logInfo)
{
logInfo.Message = DataSecurity.HtmlDecode(logInfo.Message);
logInfo.PostString = DataSecurity.HtmlDecode(logInfo.PostString);
logInfo.ScriptName = DataSecurity.HtmlDecode(logInfo.ScriptName);
logInfo.Source = DataSecurity.HtmlDecode(logInfo.Source);
logInfo.Title = DataSecurity.HtmlDecode(logInfo.Title);
logInfo.UserIP = DataSecurity.HtmlDecode(logInfo.UserIP);
logInfo.UserName = DataSecurity.HtmlDecode(logInfo.UserName);
}
public override bool Delete(DateTime time)
{
return this.dal.Delete(time);
}
public override bool Delete(int id)
{
if (id <= 0)
{
return false;
}
return this.Delete(Convert.ToString(id, (IFormatProvider) null));
}
public bool Delete(string id)
{
return (DataValidator.IsValidId(id) && this.dal.Delete(id));
}
private static void EncodeInfo(LogInfo logInfo)
{
logInfo.Message = DataSecurity.HtmlEncode(logInfo.Message);
logInfo.PostString = DataSecurity.HtmlEncode(logInfo.PostString);
logInfo.ScriptName = DataSecurity.HtmlEncode(logInfo.ScriptName);
logInfo.Source = DataSecurity.HtmlEncode(logInfo.Source);
logInfo.Title = DataSecurity.HtmlEncode(logInfo.Title);
logInfo.UserIP = DataSecurity.HtmlEncode(logInfo.UserIP);
logInfo.UserName = DataSecurity.HtmlEncode(logInfo.UserName);
}
public IList<LogInfo> GetList(int startRowIndexId, int maxNumberRows, int category, string searchType, string keyword)
{
if (category > 0)
{
return this.dal.GetList(startRowIndexId, maxNumberRows, (LogCategory) category);
}
if (!string.IsNullOrEmpty(searchType) && !string.IsNullOrEmpty(keyword))
{
searchType = DataSecurity.FilterBadChar(searchType);
keyword = DataSecurity.FilterBadChar(keyword);
return this.dal.GetList(startRowIndexId, maxNumberRows, searchType, keyword);
}
return this.dal.GetList(startRowIndexId, maxNumberRows);
}
public LogInfo GetLogById(int id)
{
LogInfo logById = this.dal.GetLogById(id);
DecodeInfo(logById);
return logById;
}
public int GetTotalOfLog(int startRowIndexId, int maxNumberRows, int category, string searchType, string keyword)
{
return this.dal.GetTotalOfLog();
}
public bool Update(LogInfo logInfo)
{
if (logInfo == null)
{
return false;
}
EncodeInfo(logInfo);
return this.dal.Update(logInfo);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -