Exemplo n.º 1
0
 protected override AuditType GetActionAuditType(AuditTransacInfo transac, AuditOperationType operation, object entity)
 {
     if (entity == null)
     {
         return AuditType.None;
     }
     if (this.metaEntities.ContainsKey(entity.GetType()))
     {
         return this.metaEntities[entity.GetType()].AuditType;
     }
     return AuditType.None;
 }
Exemplo n.º 2
0
 protected override void CommitAudit(IUserContext userContext, AuditTransacInfo transac)
 {
     EntitiesModel context = (EntitiesModel)userContext.Context;
     AppTiempos.Model.AuditTransac ntransac = new AppTiempos.Model.AuditTransac();
     ntransac.UserId = Convert.ToInt32(transac.UserId);
     ntransac.StartDttm = transac.StartDateTime;
     ntransac.EndDttm = transac.EndDateTime;
     context.Add(ntransac);
     context.FlushChanges();
     int ix = 1;
     foreach (AuditTransacActionInfo action in transac.Actions)
     {
         EntityHelper helper = this.Parent.EntityHelperManager.GetEntityHelper(action.instance.GetType());
         MetaEntity metaEntity = null;
         if (this.metaEntities.ContainsKey(action.instance.GetType())) {
             metaEntity = this.metaEntities[action.instance.GetType()];
         }
         if ((helper != null) && (metaEntity != null))
         {
             AuditTransacAction naction = new AuditTransacAction();
             naction.TransacId = ntransac.TransacId;
             naction.TransacActionIx = ix;
             naction.PrimaryKey = helper.GetStringKey(action.instance);
             naction.EntId = metaEntity.EntId;
             if (action.ActionType == AuditOperationType.Insert)
             {
                 naction.ActionType = 'I';
             }
             else if (action.ActionType == AuditOperationType.Update)
             {
                 naction.ActionType = 'U';
             }
             else if (action.ActionType == AuditOperationType.Delete)
             {
                 naction.ActionType = 'D';
             }
             context.Add(naction);
             ix++;
         }
     }
 }