亚音速 3.0.0.3 | 数据访问层 - 审计跟踪
大家好,你们如何在数据访问层下的 SubSonic 上的所有对象/类上实现审计跟踪?
如果我想要的是,所有对象的所有更改都将记录在单个表/对象上。
public class AuditTrail
{
public int Id { get; set; }
public string SourceObjectName { get; set; }
public int RowPK { get; set; } // Id of the SourceObject
public string ChangeType {get; set;} // value such as "Add", "Update", "Delete"
public string RowCapture { get; set; } // Id="6" UserId="xxx3" SurName="NoBodyx" FirstName="no3" MiddleName="B." Email="[email protected]" CreatedDate="8/6/2009 1:57:58 PM" CreatedBy="ca3" UpdatedDate="8/7/2009 5:58:37 AM" UpdatedBy="qqq" Name="no3 B. NoBodyx"
public CreatedDate {get; set;}
}
Hi guys how do you implementing an Audit Trails on all objects/class on SubSonic under Data Access Layer?
If what I want is, all changes on all objects will be recorded on a single table/object.
public class AuditTrail
{
public int Id { get; set; }
public string SourceObjectName { get; set; }
public int RowPK { get; set; } // Id of the SourceObject
public string ChangeType {get; set;} // value such as "Add", "Update", "Delete"
public string RowCapture { get; set; } // Id="6" UserId="xxx3" SurName="NoBodyx" FirstName="no3" MiddleName="B." Email="[email protected]" CreatedDate="8/6/2009 1:57:58 PM" CreatedBy="ca3" UpdatedDate="8/7/2009 5:58:37 AM" UpdatedBy="qqq" Name="no3 B. NoBodyx"
public CreatedDate {get; set;}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用触发器直接在数据库中处理所有审计跟踪。 当审核仅发生在来自代码的更改时,如果有人通过直接 SQL 查询或通过 Management Studio 修改数据,您将无法获得任何线索。 我还发现基于触发器的设置比基于代码的设置性能更好,并且更少陷入困境。
我使用一个存储过程为每个表创建一个审计表并设置所有触发器。 但是,如果需要,类似的设置可以指向单个审核表。
一旦审计表存在,您就可以通过 Subsonic 从中提取数据。
I handle all of my audit trails directly in the database using triggers. When the audit only happens to changes that come from code, if someone tinkers with the data via direct SQL query or via Management Studio, you get no trail. I've also found that the trigger-based setups perform better than the code-based ones, bogging things down less.
I use a stored procedure that creates an audit table per table and sets up all of the triggers. However, a similar setup could point to a single audit table if you want.
Once the audit table exists, you can pull data from it via Subsonic.