Esempio n. 1
0
        public TransactionScopeV(string providerName, string connStr, IsolationLevel isoLevel)
        {
            if (currentTx == null)
            {
                DbConnection conn = null;
                conn = ConnPool.GetConn(ConnManager.ThreadConnStrKey) as DbConnection;

                if (conn == null)
                {
                    DbProviderFactory dbProFactory = DbProviderFactories.GetFactory(providerName);
                    conn = dbProFactory.CreateConnection();
                    conn.ConnectionString = connStr;

                    ConnPool.Set(ConnManager.ThreadConnStrKey, conn);
                }

                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                DbTransaction dbTx = conn.BeginTransaction();

                TransactionV.Current = new CommittableTransactionV(dbTx);
                currentTx = TransactionV.Current;
            }
            else
            {
                TransactionV.Current = currentTx.DependentClone();
            }
        }
Esempio n. 2
0
        public void Dispose()
        {
            if (!Completed)
            {
                currentTx.Rollback();
            }

            CommittableTransactionV committableTx = currentTx as CommittableTransactionV;
            if (committableTx != null)
            {
                if (Completed)
                {
                    committableTx.Commit();
                }
            }

            if (ConnPool.GetConn(ConnManager.ThreadConnStrKey) != null)
            {
                DbConnection conn = ConnPool.GetConn(ConnManager.ThreadConnStrKey) as DbConnection;
                ConnPool.Remove(ConnManager.ThreadConnStrKey);
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            currentTx = null;
            TransactionV.Current.Dispose();
            TransactionV.Current = null;
        }
Esempio n. 3
0
        public DependentTransactionV(TransactionV innerTx)
        {
            InnerTransaction = innerTx;

            DbTransactionWrapper = innerTx.DbTransactionWrapper;
        }