C# C/S框架功能-保存修改日志(Modify Log)
C# C/S框架功能-保存修改日志(Modify Log)
模拟C/S框架修改日志,frmLogConfig窗体用到DevExpress 9.24控件。
/// <summary>
/// 支持写入日志的接口
/// </summary>
public interface LogSupportable
{
/// <summary>
/// 写入单表日志
/// </summary>
/// <param name="changes"></param>
/// <param name="tableName"></param>
/// <param name="keyFieldName"></param>
void WriteLog(DataTable changes, string tableName, string keyFieldName);
/// <summary>
/// 写入多个表的日志,一般为主表,明细1..n
/// </summary>
/// <param name="changes"></param>
void WriteLog(DataSet changes);
}
// 来源:www.CSFramework.com, C/S结构框架学习网
/// <summary>
/// 记录单表日志
/// </summary>
/// <param name="changes">修改后的数据</param>
/// <param name="tableName">表名</param>
/// <param name="keyFieldName">记录的主键,比较新旧数据时用于定位</param>
public void WriteLog(DataTable changes, string tableName, string keyFieldName)
{
SystemLog bllLog = new SystemLog();
string[] tracedFields = bllLog.GetTracedFields(tableName);
IList logs = bllLog.Compare(changes, tracedFields, keyFieldName, tableName);
foreach (LogDef log in logs) bllLog.WriteLog(log);
}
/// <summary>
/// 写入多表日志
/// </summary>
/// <param name="changes"></param>
public void WriteLog(DataSet changes)
{
WriteLog(changes.Tables[0], "tb_Customers", "CustomerCode");
//WriteLog(changes.Tables[1], "tb_Detail1", "Key"); //如有明细表
}
// 来源:www.CSFramework.com, C/S结构框架学习网
扫一扫加作者微信
模拟C/S框架修改日志,frmLogConfig窗体用到DevExpress 9.24控件。
/// <summary>
/// 支持写入日志的接口
/// </summary>
public interface LogSupportable
{
/// <summary>
/// 写入单表日志
/// </summary>
/// <param name="changes"></param>
/// <param name="tableName"></param>
/// <param name="keyFieldName"></param>
void WriteLog(DataTable changes, string tableName, string keyFieldName);
/// <summary>
/// 写入多个表的日志,一般为主表,明细1..n
/// </summary>
/// <param name="changes"></param>
void WriteLog(DataSet changes);
}
// 来源:www.CSFramework.com, C/S结构框架学习网
/// <summary>
/// 记录单表日志
/// </summary>
/// <param name="changes">修改后的数据</param>
/// <param name="tableName">表名</param>
/// <param name="keyFieldName">记录的主键,比较新旧数据时用于定位</param>
public void WriteLog(DataTable changes, string tableName, string keyFieldName)
{
SystemLog bllLog = new SystemLog();
string[] tracedFields = bllLog.GetTracedFields(tableName);
IList logs = bllLog.Compare(changes, tracedFields, keyFieldName, tableName);
foreach (LogDef log in logs) bllLog.WriteLog(log);
}
/// <summary>
/// 写入多表日志
/// </summary>
/// <param name="changes"></param>
public void WriteLog(DataSet changes)
{
WriteLog(changes.Tables[0], "tb_Customers", "CustomerCode");
//WriteLog(changes.Tables[1], "tb_Detail1", "Key"); //如有明细表
}
// 来源:www.CSFramework.com, C/S结构框架学习网
扫一扫加作者微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网