I combined the two examples from your website. Basically I'm doing this:
public abstract class RAMAuditorBase : AuditorBase
{
private List<EntityBase2> _auditInfoEntities;
private DataAccessAdapter _dataAdapter;
...
code from example on website changed slightly to fit. The method you asked about is duplicated here. It pretty much follows the example.
protected virtual internal void AddAuditEntryToList(string affectedEntityName, AuditType actionType, string actionData)
{
AuditInfoEntity auditInfo = new AuditInfoEntity();
auditInfo.AffectedEntityName = affectedEntityName;
auditInfo.ActionDateTime = DateTime.Now;
auditInfo.AuditActionTypeId = (int)actionType;
auditInfo.UserId = GetCurrentUserID();
auditInfo.ActionData = actionData;
_auditInfoEntities.Add(auditInfo);
}
...
}
The above pretty much covers anything I want saved to just to the AuditInfo table.
In order to do anything I little more custom I did this:
public class RIAAuditor : RAMAuditorBase
{
public RIAAuditor(DataAccessAdapter dataAdapter):base(dataAdapter)
{
}
protected internal override void AddAuditEntryToList(string affectedEntityName, AuditType actionType, string actionData)
{
AuditInfoRIAEntity auditInfo = new AuditInfoRIAEntity();
auditInfo.AffectedEntityName = affectedEntityName;
auditInfo.ActionDateTime = DateTime.Now;
auditInfo.AuditActionTypeId = (int)actionType;
auditInfo.UserId = GetCurrentUserID();
auditInfo.RIAId = 1;
auditInfo.ActionData = actionData;
base.AddAuditEntryToList(auditInfo);
}
}
So now I'm thinking I should just pass in the ENTITY into this method and not "string affectedEntityName".
-Luke
Walaa wrote:
If I understand you well, implementing the IAuditor -> most of the methods that you should implement receives the host entity as a parameter as follows:
public override void AuditUpdateOfExistingEntity(IEntityCore entity)
{
AuditInfoEntity auditInfo = new AuditInfoEntity();
auditInfo.AffectedEntityName = entity.LLBLGenProEntityName;
auditInfo.ActionDateTime = DateTime.Now;
auditInfo.ActionType = (int)AuditType.UpdateOfExistingEntity;
_auditInfoEntities.Add(auditInfo);
}
From where did you get the AddAuditEntryToList() method?