private void OnTransactionCompleted(object sender, DeltaTransactionEventArgs e)
        {
            var transaction = e.Transaction;
            var transId     = transaction.Identifier;

            try
            {
                logger.LogDebug("TransId:{0} OnTransactionCompleted Status:{1}", transId, transaction.Status);
                var items = GetAll(transId, true);
                if (transaction.Status == DeltaTransactionStatus.Committed)
                {
                    TransactionCommitted?.Invoke(this, items);
                }
                else
                {
                    TransactionAborted?.Invoke(this, items);
                }
            }
            finally
            {
                transaction.TransactionCompleted -= OnTransactionCompleted;
                subscribedTransaction             = null;
                transactionItems.TryRemove(transId, out _);
            }
        }
 private void SubscribeTransactionCompleted()
 {
     if (subscribedTransaction == null || subscribedTransaction != DeltaTransaction.Current)
     {
         DeltaTransaction.Current.TransactionCompleted -= OnTransactionCompleted;
         DeltaTransaction.Current.TransactionCompleted += OnTransactionCompleted;
         subscribedTransaction = DeltaTransaction.Current;
     }
 }
Exemple #3
0
 private void SubscribeTransactionCompleted()
 {
     if (subscribedTransaction == null || subscribedTransaction != transactionFactory.Current)
     {
         transactionFactory.Current.TransactionCompleted -= OnTransactionCompleted;
         transactionFactory.Current.TransactionCompleted += OnTransactionCompleted;
         subscribedTransaction = transactionFactory.Current;
     }
 }
Exemple #4
0
        public static DeltaTransaction InitializeDeltaTransaction()
        {
            try
            {
                Current?.Dispose();
            }
            finally
            {
                Current = null;
            }

            Current = new DeltaTransaction();
            return(Current);
        }
Exemple #5
0
        private void DoDispose()
        {
            if (disposed)
            {
                return;
            }

            disposed = true;
            try
            {
                if (Status == DeltaTransactionStatus.Active)
                {
                    Rollback();
                }
            }
            finally
            {
                if (this == Current)
                {
                    Current = null;
                }
            }
        }
Exemple #6
0
 public DeltaTransactionEventArgs(DeltaTransaction transaction)
 {
     Transaction = transaction;
     Status      = transaction.Status;
 }
 public bool IsTransactionActive(DeltaTransaction transaction = null)
 {
     transaction ??= DeltaTransaction.Current;
     return(transaction?.IsActive() == true);
 }
Exemple #8
0
 public bool IsActive(DeltaTransaction transaction = null)
 {
     transaction ??= transactionFactory.Current;
     return(transaction.IsActive());
 }