-
Notifications
You must be signed in to change notification settings - Fork 0
Audit worker
The audit worker is responsible for managing the operations of writing events to the audit and returning them when requested.
Several methods are needed from a audit worker; these are defined on the audit worker interface (IAuditWorker). We will now take a look at each method and discuss what the intent of the method is.
There is a group of methods divoted to creating different types of audit events. An audit event is a record of what happened for a specific interaction. The method in this section stage the audit ready to be commited to the data store. These event methods are called between the data being staged and it being commited when using the default data manager.
The audit generator class might be of use for these methods to allow the audit records to be simply created.
The CreationEvent method is called when data is created by the data manager.
Task<bool> CreationEvent<TDataType>(TDataType data) where TDataType : DataEntity;
The method takes in the data object so that each property can be audited. If the event is stage successfully then true is returned.
The UpdateEvent method is called when data is updated by the data manager.
Task<bool> UpdateEvent<TDataType>(TDataType newData, TDataType oldData) where TDataType : DataEntity;
The method takes in the data object as it is after the changes and the data object before the changes so that each property can be audited with the before and after values. If the event is stage successfully then true is returned.
The DeleteEvent method is called when data is deleted by the data manager.
Task<bool> DeleteEvent<TDataType>(TDataType data) where TDataType : DataEntity;
The method takes in the data object that was deleted so that each property can be audited with the values that where last saved. If the event is stage successfully then true is returned.
The UndeleteEvent method is called when data is restored after being deleted by the data manager.
Task<bool> UndeleteEvent<TDataType>(TDataType data) where TDataType : DataEntity;
The method takes in the data object that was restored so that each property can be audited with the values that have been restored. If the event is stage successfully then true is returned.
The RollbackEvent method is called when data is rolledback after being committed by the data manager.
Task<bool> RollbackEvent<TDataType>(TDataType data) where TDataType : DataEntity;
The method takes in the data object that was restored so that each property can be audited with the values that have been restored. If the event is stage successfully then true is returned.
The CommitEvents method is called when the data manager has commited the data and want the audit to be commited to the data store.
Task<bool> CommitEvents<TDataType>(TDataType data) where TDataType : DataEntity;
The method takes in the data object that is to be audited this can be used to identify the audit events that are staged. If the events are committed successfully then true is returned.
The DiscardEvents method is called when the data manager has failed commited the data and want the audit events that are staged to be discarded.
Task<bool> DiscardEvents<TDataType>(TDataType data) where TDataType : DataEntity;
The method takes in the data object that is to be audited this can be used to identify the audit events that are staged. If the events are discarded successfully then true is returned.
The ReadAllEvents method can be called by the data manager to get all the audit logs for a specific data object.
Task<AuditLog> ReadAllEvents<TDataType>(int id) where TDataType : DataEntity;
The method takes in the id of a data object. The method returns an audit log which is a collection of AuditEntry which is an object that represents a single event.
A data object can be marked a auditable by adding an AuditAttribute to the class or a parent class.