상속: ITransaction
예제 #1
0
파일: SessionFactory.cs 프로젝트: vlko/vlko
        internal static void UnregisterTransaction(Transaction transaction)
        {
            var stack = CurrentStack;
            if (stack.TopTransaction == transaction)
            {
                bool transactionStillActive = stack.TransactionState == StackInfo.TransactionStateEnum.Active;

                // if we have still open transaction then call rollback
                if (transactionStillActive)
                {
                    RollbackTransaction(transaction);
                }

                // throw exception if transaction was still active and no exception raised, then throw my own exception
                if (transactionStillActive && Marshal.GetExceptionCode() == 0)
                {
                    throw new SessionException("Transaction is open! Try commit or rollback before ");
                }

                stack.Transaction.Dispose();
                stack.TransactionState = StackInfo.TransactionStateEnum.NoActiveTransaction;
                stack.TopTransaction = null;

                // if transaction is also top session then free session
                if (stack.TopUnitOfWork == null)
                {
                    ClearStackInfo(stack);
                }
            }
        }
예제 #2
0
파일: SessionFactory.cs 프로젝트: vlko/vlko
 /// <summary>
 /// Registers the transaction.
 /// </summary>
 /// <param name="transaction">The transaction.</param>
 internal static void RegisterTransaction(Transaction transaction)
 {
     var stack = CurrentStack;
     // if no session yet, start new
     if (stack.Session == null)
     {
         stack.Session = (DocumentSession)DocumentStoreInstance.OpenSession();
     }
     // and if no transaction yet, then start new one
     if (stack.TopTransaction == null)
     {
         stack.TopTransaction = transaction;
         stack.Transaction = RavenTransactionAccessor.StartTransaction();
         stack.TransactionState = StackInfo.TransactionStateEnum.Active;
     }
 }
예제 #3
0
파일: SessionFactory.cs 프로젝트: vlko/vlko
 /// <summary>
 /// Rollbacks the transaction.
 /// </summary>
 /// <param name="transaction">The transaction.</param>
 internal static void RollbackTransaction(Transaction transaction)
 {
     var stack = CurrentStack;
     stack.TransactionState = StackInfo.TransactionStateEnum.Rollback;
     stack.Session.Rollback(RavenTransactionAccessor.GetTransactionInformation().Id);
 }
예제 #4
0
파일: SessionFactory.cs 프로젝트: vlko/vlko
 /// <summary>
 /// Commits the transaction.
 /// </summary>
 /// <param name="transaction">The transaction.</param>
 internal static void CommitTransaction(Transaction transaction)
 {
     var stack = CurrentStack;
     if (stack.TopTransaction == transaction)
     {
         if (stack.TransactionState == StackInfo.TransactionStateEnum.Rollback)
         {
             throw new SessionException("Nested transaction called Rollback and thus we are not able to commit!");
         }
         stack.Session.SaveChanges();
         stack.TransactionState = StackInfo.TransactionStateEnum.Commit;
         stack.Session.Commit(RavenTransactionAccessor.GetTransactionInformation().Id);
     }
     else
     {
         stack.Session.SaveChanges();
     }
 }