Beispiel #1
0
 public void Trail(TransacActionType actionType, object sourceObject, object targetObject)
 {
     if (IoC.Get <IAuditManager>().MustTrail(actionType, sourceObject, targetObject))
     {
         TransacActionInfo action = new TransacActionInfo();
         action.Type           = actionType;
         action.SourceInstance = sourceObject;
         action.TargetInstance = targetObject;
         this.Transaction.Actions.Add(action);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Commits one action of the transaction.
        /// </summary>
        /// <param name="userContext">The user context.</param>
        /// <param name="transac">The transac.</param>
        /// <param name="index">The index.</param>
        /// <param name="action">The action.</param>
        protected override void CommitAction(IUserContext userContext, TransacInfo transac, int index, TransacActionInfo action)
        {
            object referenceObject = null;

            if (action.Type == TransacActionType.Insert)
            {
                referenceObject = action.TargetInstance;
            }
            else
            {
                referenceObject = action.SourceInstance;
            }
            IMetamodelEntity metamodelEntity = IoC.Get <ISecurityManager>().MetamodelManager.GetEntity(referenceObject.GetType());

            if (metamodelEntity != null)
            {
                if (metamodelEntity.AuditType == AuditType.Simple)
                {
                    AuditTransacAction actionEntity = new AuditTransacAction();
                    actionEntity.AuditTransacId       = Convert.ToInt32(transac.TransacId);
                    actionEntity.AuditTransacActionIx = index + 1;
                    actionEntity.EntityId             = metamodelEntity.EntId;
                    actionEntity.PrimaryKey           = metamodelEntity.GetStringKey(referenceObject);
                    userContext.Context.Add(actionEntity);
                }
            }
        }