Exemple #1
0
        // NOTE: This is just a private helper because OracleClient V1.1 shipped
        // with a different argument name and it's a breaking change to not use
        // the same argument names in V2.0 (VB Named Parameter Binding--Ick)
        private void EnlistDistributedTransactionHelper(System.EnterpriseServices.ITransaction transaction)
        {
            System.Security.PermissionSet permissionSet = new System.Security.PermissionSet(System.Security.Permissions.PermissionState.None);
            permissionSet.AddPermission(SqlConnection.ExecutePermission); // MDAC 81476
            permissionSet.AddPermission(new System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode));
            permissionSet.Demand();

            SqlClientEventSource.Log.TryTraceEvent("<prov.DbConnectionHelper.EnlistDistributedTransactionHelper|RES|TRAN> {0}, Connection enlisting in a transaction.", ObjectID);
            SysTx.Transaction indigoTransaction = null;

            if (null != transaction)
            {
                indigoTransaction = SysTx.TransactionInterop.GetTransactionFromDtcTransaction((SysTx.IDtcTransaction)transaction);
            }

            RepairInnerConnection();
            // NOTE: since transaction enlistment involves round trips to the
            // server, we don't want to lock here, we'll handle the race conditions
            // elsewhere.
            InnerConnection.EnlistTransaction(indigoTransaction);

            // NOTE: If this outer connection were to be GC'd while we're
            // enlisting, the pooler would attempt to reclaim the inner connection
            // while we're attempting to enlist; not sure how likely that is but
            // we should consider a GC.KeepAlive(this) here.
            GC.KeepAlive(this);
        }
Exemple #2
0
        //// NOTE: This is just a private helper because OracleClient V1.1 shipped
        //// with a different argument name and it's a breaking change to not use
        //// the same argument names in V2.0 (VB Named Parameter Binding--Ick)
        //private void EnlistDistributedTransactionHelper(System.EnterpriseServices.ITransaction transaction) {
        //    SysTx.Transaction indigoTransaction = null;

        //    if (null != transaction) {
        //        indigoTransaction = SysTx.TransactionInterop.GetTransactionFromDtcTransaction((SysTx.IDtcTransaction)transaction);
        //    }

        //    RepairInnerConnection();
        //    // NOTE: since transaction enlistment involves round trips to the
        //    // server, we don't want to lock here, we'll handle the race conditions
        //    // elsewhere.
        //    InnerConnection.EnlistTransaction(indigoTransaction);

        //    // NOTE: If this outer connection were to be GC'd while we're
        //    // enlisting, the pooler would attempt to reclaim the inner connection
        //    // while we're attempting to enlist; not sure how likely that is but
        //    // we should consider a GC.KeepAlive(this) here.
        //    GC.KeepAlive(this);
        //}

        public override void EnlistTransaction(SysTx.Transaction?transaction)
        {
            // If we're currently enlisted in a transaction and we were called
            // on the EnlistTransaction method (Whidbey) we're not allowed to
            // enlist in a different transaction.

            DbConnectionInternal innerConnection = InnerConnection;

            // NOTE: since transaction enlistment involves round trips to the
            // server, we don't want to lock here, we'll handle the race conditions
            // elsewhere.
            SysTx.Transaction?enlistedTransaction = innerConnection.EnlistedTransaction;
            if (enlistedTransaction != null)
            {
                // Allow calling enlist if already enlisted (no-op)
                if (enlistedTransaction.Equals(transaction))
                {
                    return;
                }

                // Allow enlisting in a different transaction if the enlisted transaction has completed.
                if (enlistedTransaction.TransactionInformation.Status == SysTx.TransactionStatus.Active)
                {
                    throw ADP.TransactionPresent();
                }
            }
            RepairInnerConnection();
            InnerConnection.EnlistTransaction(transaction);

            // NOTE: If this outer connection were to be GC'd while we're
            // enlisting, the pooler would attempt to reclaim the inner connection
            // while we're attempting to enlist; not sure how likely that is but
            // we should consider a GC.KeepAlive(this) here.
            GC.KeepAlive(this);
        }
Exemple #3
0
 /// <summary>
 /// Enlists in the specified transaction.
 /// </summary>
 /// <param name="transaction">A reference to an existing <see cref="T:System.Transactions.Transaction" /> in which to enlist.</param>
 public override void EnlistTransaction(Transaction transaction)
 {
     if (InnerConnection == null)
     {
         throw new InvalidOperationException(Messages.PropertyNotInitialized("Connection"));
     }
     InnerConnection.EnlistTransaction(transaction);
 }
Exemple #4
0
 public override void EnlistTransaction(Transaction transaction)
 {
     InnerConnection.EnlistTransaction(transaction);
     if (transaction != null)
     {
         transaction.TransactionCompleted += OnDtcTransactionCompleted;
         Stats.DtcTransactionEnlisted(ConnectionId, transaction.IsolationLevel);
     }
 }
        public override void EnlistTransaction(Transaction transaction)
        {
            InnerConnection.EnlistTransaction(transaction);
            if (transaction != null)
            {
                transaction.TransactionCompleted += OnDtcTransactionCompleted;

                if (MessageBroker != null)
                {
                    MessageBroker.Publish(new DtcTransactionEnlistedMessage(ConnectionId, transaction.IsolationLevel));
                }
            }
        }
 public override void EnlistTransaction(Transaction transaction)
 {
     InnerConnection.EnlistTransaction(transaction);
 }