I have a requirement where I have to put audit log feature in an existing Asp.net Web Forms application in C# using SQL Server 2008. There are various pages in this application which use from formviews, listviews, gridviews for inserting, updating and deleting data. The requirement is to capture each 3 of these events with data which was modified/deleted, the user details and timestamp.
I want ideas/suggestions as to how I can easily implement this (the code in the application side) and with the use of just one AuditLog table (database side). This is my initial design of the table:
我有一个要求,我必须使用SQL Server 2008将审计日志功能放在C#中的现有Asp.net Web窗体应用程序中。此应用程序中有各种页面,它们使用表单视图,列表视图,网格视图来插入,更新和删除数据。要求是使用修改/删除的数据,用户详细信息和时间戳捕获这些事件中的每个事件。我想知道如何轻松实现这个(应用程序端的代码)和使用一个AuditLog表(数据库端)的想法/建议。这是我最初的表格设计:
- AuditId uniqueidentifier
- TableName varchar(100)
- RecordId varchar(100) (some tables have int as primary and some have guid)
- Action char(1) (I - insert, U - update, D - delete)
- RecordData varchar(MAX) (dump all data for that record, not sure about this field, need help??)
- ActionDate datetime
- ActionedBy varchar(20) (user)
Thanks in advance...
提前致谢...
1 个解决方案
#1
1
What technology are you using for data access? With EF, you can handle the SavingChanges event:
您使用什么技术进行数据访问?使用EF,您可以处理SavingChanges事件:
http://www.codeproject.com/Articles/34491/Implementing-Audit-Trail-using-Entity-Framework-Pa
http://www.codeproject.com/Articles/34491/Implementing-Audit-Trail-using-Entity-Framework-Pa
With NHibernate, implementing IInterceptor:
使用NHibernate,实现IInterceptor:
http://nhforge.org/wikis/howtonh/creating-an-audit-log-using-nhibernate-events.aspx
http://nhforge.org/wikis/howtonh/creating-an-audit-log-using-nhibernate-events.aspx
#1
1
What technology are you using for data access? With EF, you can handle the SavingChanges event:
您使用什么技术进行数据访问?使用EF,您可以处理SavingChanges事件:
http://www.codeproject.com/Articles/34491/Implementing-Audit-Trail-using-Entity-Framework-Pa
http://www.codeproject.com/Articles/34491/Implementing-Audit-Trail-using-Entity-Framework-Pa
With NHibernate, implementing IInterceptor:
使用NHibernate,实现IInterceptor:
http://nhforge.org/wikis/howtonh/creating-an-audit-log-using-nhibernate-events.aspx
http://nhforge.org/wikis/howtonh/creating-an-audit-log-using-nhibernate-events.aspx