示例#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();
            }
        }
示例#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;
        }
示例#3
0
        public DependentTransactionV(TransactionV innerTx)
        {
            InnerTransaction = innerTx;

            DbTransactionWrapper = innerTx.DbTransactionWrapper;
        }