Hi,
I am trying to setup the Auditing for my entities. I have successfully been able to get the auditing of updates working but not inserts. It seems as though the AuditInsertOfNewEntity never gets called. Here are my solution details.
I am using .net Remoting.
SD.LLBLGen.Pro.ORMSupportClasses.NET20 Version: v2.0.50727 (V2.5)
Web Config Settings
<configSections>
<section name="dependencyInjectionInformation"
type="SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionSectionHandler,
SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=2.5.0.0, Culture=neutral,
PublicKeyToken=ca73b74ba4e3ff27"/>
</configSections>
<dependencyInjectionInformation>
<additionalAssemblies>
<assembly filename="MBL.CAG.FOD.RACS.Helper.dll"/>
<assembly fullName="MBL.CAG.FOD.RACS.Helper, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null"/>
</additionalAssemblies>
<instanceTypeFilters>
<instanceTypeFilter namespace="MBL.CAG.FOD.RACS.Helper"/>
</instanceTypeFilters>
</dependencyInjectionInformation>
Save Method Details
public ReturnObject<bool> SaveRuleCriteria(LeadScheduleAutomationEntity entity)
{
ReturnObject<bool> returnObject = new ReturnObject<bool>();
adapter.StartTransaction(IsolationLevel.ReadCommitted, "SaveAutomationRule");
try
{
entity.CreatedBy = UserShortName;
entity.CreatedDate = DateTime.Now;
adapter.SaveEntity(entity, false);
adapter.Commit();
returnObject.ReturnValue = true;
returnObject.UIMessages.Add("Rule Successfully Save");
}
catch (Exception ex)
{
adapter.Rollback();
returnObject.ReturnValue = false;
returnObject.UIMessages.Add("Rule Save Failed");
returnObject.ErrorMessage.Add(ex.Message);
}
finally
{
adapter.Dispose();
}
}
Audit Class Details.
namespace MBL.CAG.FOD.RACS.Helper
{
[DependencyInjectionInfo(typeof(IEntity2), "AuditorToUse")]
[Serializable]
public class EntityAuditor : AuditorBase
{
private enum AuditType
{
DeleteOfEntity = 1,
DirectDeleteOfEntities,
DirectUpdateOfEntities,
DereferenceOfRelatedEntity,
ReferenceOfRelatedEntity,
EntityFieldSet,
InsertOfNewEntity,
UpdateOfExistingEntity
}
private List<AuditLogEntity> _auditLogEntities;
//private BaseClass.BLLRemoteBase _remoteBase;
/// <summary>CTor </summary>
public EntityAuditor()
{
_auditLogEntities = new List<AuditLogEntity>();
//_remoteBase = new BLLRemoteBase();
}
public override void AuditInsertOfNewEntity(IEntityCore entity)
{
if (entity.LLBLGenProEntityName != "AuditLogEntity")
{
AuditLogEntity auditLog = new AuditLogEntity();
auditLog.TableName = entity.LLBLGenProEntityName;
auditLog.CreateDate = DateTime.Now;
auditLog.CreatedBy = UserShortName();
auditLog.AuditRecordTypeId = (int)AuditType.InsertOfNewEntity;
_auditLogEntities.Add(auditLog);
}
}
public override System.Collections.IList GetAuditEntitiesToSave()
{
return _auditLogEntities;
}
public override void TransactionCommitted()
{
_auditLogEntities.Clear();
}
}
}
If anybody can see where I have gone wrong, that would be great.
Thanks,
Matt.