-
Notifications
You must be signed in to change notification settings - Fork 0
Audit generator
PackDB allows for auditing of data that is marked to be audited. To help with this process this project provides a default audit generator however you might want to change how this is done for example you might want to change it so that specific bits of data are not audited or extra bits of meta data are added to an audit event when a audit is generated.
To implment your own audit generator you can create a class that implments IAuditGenerator.
The IAuditGenerator interface enforces the following methods
This should produce an AuditLog object that contains a AuditEntry. The AuditEntry is expected to be of the type Create and it should discribe the properties that are set and with what values. This method is normally used when data is created for the first time.
AuditLog NewLog<TDataType>(TDataType data) where TDataType : DataEntity;
The method takes in the data object of the type of data to audit.
This should produce an AuditLog object that contains a AuditEntry. The AuditEntry is expected to be of the type Update and it should discribe the properties that have been updated with there old and new values. This method is normally used when data is change.
AuditLog UpdateLog<TDataType, TOldDataType>(TDataType newData, TOldDataType oldData, AuditLog currentLog) where TDataType : DataEntity;
The mehod takes in two data object one for how the object is after the change and one for the way the object was before the chane. The method also is passed the existing AuditLog which should be expanded on to produce the returned AuditLog.
This should produce an AuditLog object that contains a AuditEntry. The AuditEntry is expected to be of the type Delete and it should discribe the way the object was before it was deleted. This method is normally used when data is deleted.
AuditLog DeleteLog<TDataType>(TDataType data, AuditLog currentLog) where TDataType : DataEntity;
The mehod takes in a data object which is the way the data was before it was deleted. The method also is passed the existing AuditLog which should be expanded on to produce the returned AuditLog.
This should produce an AuditLog object that contains a AuditEntry. The AuditEntry is expected to be of the type Undelete and it should discribe the way the object is now it is restored. This method is normally used when data is restored.
AuditLog UndeleteLog<TDataType>(TDataType data, AuditLog currentLog) where TDataType : DataEntity;
The mehod takes in a data object which is the data that was restored. The method also is passed the existing AuditLog which should be expanded on to produce the returned AuditLog.
This should produce an AuditLog object that contains a AuditEntry. The AuditEntry is expected to be of the type Rollback and it should discribe the way the object is now it is restored. This method is normally used when data has failed to be written or be indexed and will allow auditers to determine when data had to be rolledback.
AuditLog RollbackLog<TDataType>(TDataType data, AuditLog currentLog) where TDataType : DataEntity;
The mehod takes in a data object which is the data that was restored. The method also is passed the existing AuditLog which should be expanded on to produce the returned AuditLog.
You can inject you AuditGenerator into the audit worker or any audit worker that allows the audit genertor to be set from this point on it will then be used.
The default generator is available to be used by any extention and could be inherited to kick start your expantion if you only need to add extra detail to the audit log. This would provide a clean and quick way to easily expand the audit without needing to write the code over again.