Preventing Audit of AuditInfo Entity

Posts   
 
    
stevebez
User
Posts: 4
Joined: 21-Dec-2007
# Posted on: 27-Dec-2007 15:37:28   

Hi

I have a general Auditor class that I use via DI to audit all entities in my application. The problem is when I instantiate an AuditInfo object inside the AuditEntityFieldSet routine and try to set it's properties, it re-fires the AuditEntityFieldSet for the AuditInfo object.


        Dim auditInfo As AuditInfoEntity = New AuditInfoEntity()
        auditInfo.AffectedEntityName = entity.LLBLGenProEntityName
        auditInfo.ActionDateTime = DateTime.Now
        auditInfo.AuditActionTypeId = AuditType.EntityFieldSet
        auditInfo.UserId = 1
        auditInfo.ActionData = actionData

I realise this is because my AuditInfo object is also set to be audited since it has received the AuditorToUse just like all my other entities.

What is the best way to set this entity not to be audited?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 27-Dec-2007 16:38:45   

You have 2 options:

1- Inside the Auditor methods, check on the passed in Entity type or entity name, and exit the method if the passed in entity is an AuditorEntity.

2- Rather than using IEntity or IEntity2 to specify the type of objects to have this Auditor injected in, you may specify multiple DI tags for each entity type you want your Auditor to be injected in it. And exclude the Audiotr Entity of-course.

stevebez
User
Posts: 4
Joined: 21-Dec-2007
# Posted on: 28-Dec-2007 10:38:58   

Thanks, that's done the trick!