Hi,
I have a client/server app using remoting and I attach an auditor deriving from AuditorBase using DI. I create new "audit" records for creating new entities and for changing properties. On the client the audited entity is created and passed to the server in a UnitOfWork which is then processed:
using(var tsw = new TransactionScopeWrapper(methodName))
{
uow.Commit(tsw.DataAccessAdapter);
tsw.Complete();
}
(TransactionScopeWrapper is a wrapper around TransactionScope which exposes a DataAccessAdapter). When Commit is called AuditInsertOfNewEntity is called in the auditor, so far so good. I have overrides on AuditEntityFieldSet and AuditInsertOfNewEntity I record the current time using this (for AuditEntityFieldSet):
var change = new WorkflowAuditEntity
{
WorkflowRunKey = state.WorkflowRunKey,
FieldName = state.Fields[fieldIndex].Name,
EventUtcDateTime = DateTime.UtcNow,
EventTypeCode = "UPD",
UserId = CurrentUserId
};
and this for AuditInsertOfNewEntity
var change = new WorkflowAuditEntity
{
WorkflowRunKey = (int)state.Fields[WorkflowEntityStateFields.WorkflowRunKey.FieldIndex].CurrentValue,
EventUtcDateTime = DateTime.UtcNow,
StatusCode = (string)state.Fields[WorkflowEntityStateFields.StatusCode.FieldIndex].CurrentValue,
EventTypeCode = "INS",
UserId = CurrentUserId
};
However this gives the odd looking, but understandable, results where the insert audit record has a datetime after the updates. Can anything be done about that, such as introduce an audit method for the construction of the entity?
Updated: Using version 2.6 with SQL Server and Adapters (not self servicing)