C# C/S框架功能-保存修改日志(Modify Log)
作者:C/S原创  发布日期:2011-03-31 15:37:37
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结构框架学习网








点击下载附件 点击下载附件 (如下载失败,请邮件通知我们寄回给您,或QQ:23404761留言.)
上一篇 下一篇