Imports DevExpress.Xpo
Imports DevExpress.Persistent.AuditTrail
Imports DevExpress.Persistent.BaseImpl

Public Module AuditTrailHandler
    Public Sub InitAuditTrail(_uow As UnitOfWork)
        AuditTrailService.Instance.SetXPDictionary(_uow.Dictionary)
        AuditTrailService.Instance.AuditDataStore = New AuditDataStore(Of AuditDataItemPersistent, AuditedObjectWeakReference)()
        AuditTrailService.Instance.BeginSessionAudit(_uow, AuditTrailStrategy.OnObjectChanged, ObjectAuditingMode.Full)
        AddHandler AuditTrailService.Instance.QueryCurrentUserName, AddressOf AuditTrailService_Instance_QueryCurrentUserName
    End Sub
    Public Sub SaveAuditTrail(_uow As UnitOfWork)
        AuditTrailService.Instance.SaveAuditData(_uow)
    End Sub
    Private Sub AuditTrailService_Instance_QueryCurrentUserName(sender As Object, e As QueryCurrentUserNameEventArgs)
        e.CurrentUserName = "SysAdmin"
    End Sub

End Module
