Пример #1
0
        protected void ExecuteByTransection(Action transactionAction)
        {
            TransactionSwitch.TurnOn();

            BaseTransactionManager transactionManager = null;

            try
            {
                transactionAction();

                transactionManager = TransactionManagerFactory.GetCurrentThreadTransactionManager();
                transactionManager.Commit();
            }
            catch (Exception)
            {
                transactionManager.Rollback();
            }
            finally
            {
                TransactionSwitch.TurnOff();
                transactionManager.Dispose();
                TransactionManagerFactory.ClearCurrentThreadTransactionManager();
            }
        }
Пример #2
0
 private static void SetCurrentThreadTransactionManager(BaseTransactionManager transactionManager)
 {
     ThreadStaticStorage.SetData(TRANSACTION_MANAGER, transactionManager);
 }