Example #1
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);
         }
     }
 }
Example #2
0
 /// <summary>
 /// Commits the transaction information and all the actions.
 /// </summary>
 /// <param name="userContext">The user context.</param>
 /// <param name="transac">The transac.</param>
 protected virtual void CommitFullTransac(IUserContext userContext, TransacInfo transac)
 {
     this.CommitTransac(userContext, transac);
     for (int i = 0; i < transac.Actions.Count; i++)
     {
         this.CommitAction(userContext, transac, i, transac.Actions[i]);
     }
 }
Example #3
0
 /// <summary>
 /// Commits the transaction information and all the actions.
 /// </summary>
 /// <param name="userContext">The user context.</param>
 /// <param name="transac">The transac.</param>
 protected virtual void CommitFullTransac(IUserContext userContext, TransacInfo transac)
 {
     this.CommitTransac(userContext, transac);
     for (int i = 0; i < transac.Actions.Count; i++)
     {
         this.CommitAction(userContext, transac, i, transac.Actions[i]);
     }
 }
Example #4
0
 /// <summary>
 /// Starts a new transaction.
 /// </summary>
 /// <param name="userContext">The user context.</param>
 /// <returns></returns>
 public TransacInfo StartTransaction(IUserContext userContext)
 {
     TransacInfo result = new TransacInfo();
     result.TransacId = null;
     result.UserId = userContext.User.UserId.Value;
     result.StartDateTime = DateTime.UtcNow;
     result.EndDateTime = null;
     return result;
 }
Example #5
0
        /// <summary>
        /// Starts a new transaction.
        /// </summary>
        /// <param name="userContext">The user context.</param>
        /// <returns></returns>
        public TransacInfo StartTransaction(IUserContext userContext)
        {
            TransacInfo result = new TransacInfo();

            result.TransacId     = null;
            result.UserId        = userContext.User.UserId.Value;
            result.StartDateTime = DateTime.UtcNow;
            result.EndDateTime   = null;
            return(result);
        }
Example #6
0
 /// <summary>
 /// Ends the transaction.
 /// </summary>
 /// <param name="userContext">The user context.</param>
 /// <param name="transac">The transac.</param>
 public void EndTransaction(IUserContext userContext, TransacInfo transac)
 {
     transac.EndDateTime = DateTime.UtcNow;
     this.CommitFullTransac(userContext, transac);
 }
Example #7
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 abstract void CommitAction(IUserContext userContext, TransacInfo transac, int index, TransacActionInfo action);
Example #8
0
 /// <summary>
 /// Commits the transaction information.
 /// </summary>
 /// <param name="userContext">The user context.</param>
 /// <param name="transac">The transaction information.</param>
 protected abstract void CommitTransac(IUserContext userContext, TransacInfo transac);
Example #9
0
 /// <summary>
 /// Commits the transaction information.
 /// </summary>
 /// <param name="userContext">The user context.</param>
 /// <param name="transac">The transaction information.</param>
 protected override void CommitTransac(IUserContext userContext, TransacInfo transac)
 {
     if (transac.Actions.Count > 0)
     {
         AuditTransac transacEntity = new AuditTransac();
         transacEntity.UserId = Convert.ToInt32(transac.UserId);
         transacEntity.StartDttm = transac.StartDateTime;
         transacEntity.EndDttm = transac.EndDateTime;
         userContext.Context.Add(transacEntity);
         userContext.Context.FlushChanges();
         transac.TransacId = transacEntity.AuditTransacId;
     }
 }
Example #10
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)
 {
 }
Example #11
0
 /// <summary>
 /// Commits the transaction information.
 /// </summary>
 /// <param name="userContext">The user context.</param>
 /// <param name="transac">The transaction information.</param>
 protected override void CommitTransac(IUserContext userContext, TransacInfo transac)
 {
 }
Example #12
0
 /// <summary>
 /// Commits the transaction information.
 /// </summary>
 /// <param name="userContext">The user context.</param>
 /// <param name="transac">The transaction information.</param>
 protected abstract void CommitTransac(IUserContext userContext, TransacInfo transac);
Example #13
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 abstract void CommitAction(IUserContext userContext, TransacInfo transac, int index, TransacActionInfo action);
Example #14
0
 /// <summary>
 /// Ends the transaction.
 /// </summary>
 /// <param name="userContext">The user context.</param>
 /// <param name="transac">The transac.</param>
 public void EndTransaction(IUserContext userContext, TransacInfo transac)
 {
     transac.EndDateTime = DateTime.UtcNow;
     this.CommitFullTransac(userContext, transac);
 }
Example #15
0
 /// <summary>
 /// Commits the transaction information.
 /// </summary>
 /// <param name="userContext">The user context.</param>
 /// <param name="transac">The transaction information.</param>
 protected override void CommitTransac(IUserContext userContext, TransacInfo transac)
 {
 }
Example #16
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)
 {
 }