forked from postsharp/PostSharp.Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
30 lines (26 loc) · 765 Bytes
/
Copy pathProgram.cs
File metadata and controls
30 lines (26 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using PostSharp.Patterns.Diagnostics.Audit;
using System.Security.Principal;
namespace PostSharp.Samples.Audit
{
internal class Program
{
private static void Main(string[] args)
{
// Configure the auditing services.
AuditServices.RecordPublished += OnAuditRecordPublished;
// Simulate some audited business operation.
var po = new PurchaseOrder();
po.Approve();
}
private static void OnAuditRecordPublished(object sender, AuditRecordEventArgs e)
{
var record = new DbAuditRecord(
WindowsIdentity.GetCurrent().Name,
(BusinessObject) e.Record.Target,
e.Record.MemberName,
e.Record.Text
);
record.AppendToDatabase();
}
}
}