private void ValidateInteropOption(EnterpriseServicesInteropOption interopOption)
 {
     if ((interopOption < EnterpriseServicesInteropOption.None) || (interopOption > EnterpriseServicesInteropOption.Full))
     {
         throw new ArgumentOutOfRangeException("interopOption");
     }
 }
Пример #2
0
 // ValidateInteropOption
 //
 // Validate a given interop Option
 private void ValidateInteropOption(EnterpriseServicesInteropOption interopOption)
 {
     if (interopOption < EnterpriseServicesInteropOption.None || interopOption > EnterpriseServicesInteropOption.Full)
     {
         throw new ArgumentOutOfRangeException(nameof(interopOption));
     }
 }
Пример #3
0
        public TransactionScope(
            Transaction transactionToUse,
            TimeSpan scopeTimeout,
            EnterpriseServicesInteropOption interopOption
            )
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceBase, this);
            }

            ValidateInteropOption(interopOption);
            _interopOption = interopOption;

            Initialize(
                transactionToUse,
                scopeTimeout,
                true);

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceBase, this);
            }
        }
        public TransactionScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
        {
            if (!TransactionManager._platformValidated)
            {
                TransactionManager.ValidatePlatform();
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), "TransactionScope.ctor( TransactionScopeOption, TransactionOptions, EnterpriseServicesInteropOption )");
            }
            this.ValidateScopeTimeout("transactionOptions.Timeout", transactionOptions.Timeout);
            TimeSpan timeout = transactionOptions.Timeout;

            transactionOptions.Timeout = TransactionManager.ValidateTimeout(transactionOptions.Timeout);
            TransactionManager.ValidateIsolationLevel(transactionOptions.IsolationLevel);
            this.ValidateInteropOption(interopOption);
            this.interopModeSpecified = true;
            this.interopOption        = interopOption;
            if (this.NeedToCreateTransaction(scopeOption))
            {
                this.committableTransaction = new CommittableTransaction(transactionOptions);
                this.expectedCurrent        = this.committableTransaction.Clone();
            }
            else if (((null != this.expectedCurrent) && (IsolationLevel.Unspecified != transactionOptions.IsolationLevel)) && (this.expectedCurrent.IsolationLevel != transactionOptions.IsolationLevel))
            {
                throw new ArgumentException(System.Transactions.SR.GetString("TransactionScopeIsolationLevelDifferentFromTransaction"), "transactionOptions.IsolationLevel");
            }
            if (((null != this.expectedCurrent) && (null == this.committableTransaction)) && (TimeSpan.Zero != timeout))
            {
                this.scopeTimer = new Timer(new System.Threading.TimerCallback(TransactionScope.TimerCallback), this, timeout, TimeSpan.Zero);
            }
            if (DiagnosticTrace.Information)
            {
                if (null == this.expectedCurrent)
                {
                    TransactionScopeCreatedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), TransactionTraceIdentifier.Empty, TransactionScopeResult.NoTransaction);
                }
                else
                {
                    TransactionScopeResult usingExistingCurrent;
                    if (null == this.committableTransaction)
                    {
                        usingExistingCurrent = TransactionScopeResult.UsingExistingCurrent;
                    }
                    else
                    {
                        usingExistingCurrent = TransactionScopeResult.CreatedTransaction;
                    }
                    TransactionScopeCreatedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), this.expectedCurrent.TransactionTraceId, usingExistingCurrent);
                }
            }
            this.PushScope();
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), "TransactionScope.ctor( TransactionScopeOption, TransactionOptions, EnterpriseServicesInteropOption )");
            }
        }
 private void PushScope()
 {
     if (!this.interopModeSpecified)
     {
         this.interopOption = Transaction.InteropMode(this.savedCurrentScope);
     }
     this.SetCurrent(this.expectedCurrent);
     this.threadContextData.CurrentScope = this;
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the TransactionScope class with the specified
 /// timeout value and COM+ interoperability requirements, and sets the specified
 /// transaction as the ambient transaction, so that transactional work done inside
 /// the scope uses this transDoFactory.
 /// </summary>
 /// <param name="transactionToUse">Represents a transaction.</param>
 /// <param name="scopeTimeout">The TimeSpan after which the transaction scope times out and aborts the transaction.</param>
 /// <param name="interopOption">An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.</param>
 public TransactionDecorator(Transaction transactionToUse, TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
 {
     _transactionToUse = transactionToUse;
     _scopeTimeout     = scopeTimeout;
     _interopOption    = interopOption;
     if (_dataProvider != "System.Data.OleDb" && _useTransuctions.Enabled)
     {
         _scope = new TransactionScope(_transactionToUse, _scopeTimeout, _interopOption);
     }
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the TransactionScope class with the
 /// specified scope and COM+ interoperability requirements, and
 /// transaction options.
 /// </summary>
 /// <param name="scopeOption">TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.</param>
 /// <param name="transactionOptions">A TransactionOptions structure that describes the transaction options to use if a new transaction is created. If an existing transaction is used, the timeout value in this parameter applies to the transaction scope. If that time expires before the scope is disposed, the transaction is aborted.</param>
 /// <param name="interopOption">An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.</param>
 public TransactionDecorator(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
     _scopeOption        = scopeOption;
     _transactionOptions = transactionOptions;
     _interopOption      = interopOption;
     if (_dataProvider != "System.Data.OleDb" && _useTransuctions.Enabled)
     {
         _scope = new TransactionScope(_scopeOption, _transactionOptions, _interopOption);
     }
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionScopeCallHandler"/> class.
 /// </summary>
 /// <param name="transactionScopeOption">
 /// An instance of the TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.
 /// </param>
 /// <param name="transactionOptions">
 /// A TransactionOptions structure that describes the transaction options to use if a new transaction is created. If an existing transaction is used, the timeout value in this parameter applies to the transaction scope. If that time expires before the scope is disposed, the transaction is aborted.
 /// </param>
 /// <param name="interopOption">
 /// An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.
 /// </param>
 /// <param name="complete">
 /// Whether the Transaction should be completed when the next handler executed without exceptions.
 /// </param>
 /// <param name="order">
 /// Order in which handler will be executed.
 /// </param>
 public TransactionScopeCallHandler(
     TransactionScopeOption transactionScopeOption,
     TransactionOptions transactionOptions,
     EnterpriseServicesInteropOption interopOption,
     bool complete,
     int order)
     : this(transactionScopeOption, transactionOptions, interopOption, complete)
 {
     this.Order = order;
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionScopeCallHandler"/> class.
 /// Creates a new <see cref="TransactionScopeCallHandler"/>.
 /// </summary>
 /// <param name="transactionScopeOption">
 /// An instance of the TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.
 /// </param>
 /// <param name="transactionOptions">
 /// A TransactionOptions structure that describes the transaction options to use if a new transaction is created. If an existing transaction is used, the timeout value in this parameter applies to the transaction scope. If that time expires before the scope is disposed, the transaction is aborted.
 /// </param>
 /// <param name="interopOption">
 /// An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.
 /// </param>
 /// <param name="complete">
 /// Whether the Transaction should be completed when the next handler executed without exceptions.
 /// </param>
 public TransactionScopeCallHandler(
     TransactionScopeOption transactionScopeOption,
     TransactionOptions transactionOptions,
     EnterpriseServicesInteropOption interopOption,
     bool complete)
 {
     this.transactionScopeOption = transactionScopeOption;
     this.transactionOptions     = transactionOptions;
     this.interopOption          = interopOption;
     this.complete = complete;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionScopeCallHandler"/> class. 
 /// Creates a new <see cref="TransactionScopeCallHandler"/>.
 /// </summary>
 /// <param name="transactionScopeOption">
 /// An instance of the TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.
 /// </param>
 /// <param name="transactionOptions">
 /// A TransactionOptions structure that describes the transaction options to use if a new transaction is created. If an existing transaction is used, the timeout value in this parameter applies to the transaction scope. If that time expires before the scope is disposed, the transaction is aborted.
 /// </param>
 /// <param name="interopOption">
 /// An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.
 /// </param>
 /// <param name="complete">
 /// Whether the Transaction should be completed when the next handler executed without exceptions.
 /// </param>
 public TransactionScopeCallHandler(
     TransactionScopeOption transactionScopeOption, 
     TransactionOptions transactionOptions, 
     EnterpriseServicesInteropOption interopOption, 
     bool complete)
 {
     this.transactionScopeOption = transactionScopeOption;
     this.transactionOptions = transactionOptions;
     this.interopOption = interopOption;
     this.complete = complete;
 }
        /// <summary>
        /// Initializes a new instance of the TransactionScope class with the
        /// specified scope and COM+ interoperability requirements, and
        /// transaction options.
        /// </summary>
        /// <param name="scopeOption">TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.</param>
        /// <param name="transactionOptions">A TransactionOptions structure that describes the transaction options to use if a new transaction is created. If an existing transaction is used, the timeout value in this parameter applies to the transaction scope. If that time expires before the scope is disposed, the transaction is aborted.</param>
        /// <param name="interopOption">An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.</param>
        public TransactionDecorator(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
        {
            _scopeOption        = scopeOption;
            _transactionOptions = transactionOptions;
            _interopOption      = interopOption;

            if (_dataProvider != _OleDb)
            {
                _scope = new TransactionScope(_scopeOption, _transactionOptions, _interopOption);
            }
        }
        /// <summary>
        /// Initializes a new instance of the TransactionScope class with the specified
        /// timeout value and COM+ interoperability requirements, and sets the specified
        /// transaction as the ambient transaction, so that transactional work done inside
        /// the scope uses this transDoFactory.
        /// </summary>
        /// <param name="transactionToUse">Represents a transaction.</param>
        /// <param name="scopeTimeout">The TimeSpan after which the transaction scope times out and aborts the transaction.</param>
        /// <param name="interopOption">An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.</param>
        public TransactionDecorator(Transaction transactionToUse, TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
        {
            _transactionToUse = transactionToUse;
            _scopeTimeout     = scopeTimeout;
            _interopOption    = interopOption;

            if (_dataProvider != _OleDb)
            {
                _scope = new TransactionScope(_transactionToUse, _scopeTimeout, _interopOption);
            }
        }
Пример #13
0
        // The validate method assumes that the existing parent ambient transaction scope is already looked up.
        private void ValidateAsyncFlowOptionAndESInteropOption()
        {
            if (AsyncFlowEnabled)
            {
                EnterpriseServicesInteropOption currentInteropOption = _interopOption;
                if (!_interopModeSpecified)
                {
                    // Transaction.InteropMode will take the interop mode on
                    // for the scope in currentScope into account.
                    currentInteropOption = Transaction.InteropMode(_savedCurrentScope);
                }

                if (currentInteropOption != EnterpriseServicesInteropOption.None)
                {
                    throw new NotSupportedException(SR.AsyncFlowAndESInteropNotSupported);
                }
            }
        }
 public TransactionScope(Transaction transactionToUse, TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
 {
     if (!TransactionManager._platformValidated)
     {
         TransactionManager.ValidatePlatform();
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), "TransactionScope.ctor( Transaction, TimeSpan, EnterpriseServicesInteropOption )");
     }
     this.ValidateInteropOption(interopOption);
     this.interopOption = interopOption;
     this.Initialize(transactionToUse, scopeTimeout, true);
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), "TransactionScope.ctor( Transaction, TimeSpan, EnterpriseServicesInteropOption )");
     }
 }
Пример #15
0
        // PushScope
        //
        // Push a transaction scope onto the stack.
        private void PushScope()
        {
            // Fixup the interop mode before we set current.
            if (!_interopModeSpecified)
            {
                // Transaction.InteropMode will take the interop mode on
                // for the scope in currentScope into account.
                _interopOption = Transaction.InteropMode(_savedCurrentScope);
            }

            // async function yield at await points and main thread can continue execution. We need to make sure the TLS data are restored appropriately.
            SaveTLSContextData();

            if (AsyncFlowEnabled)
            {
                // Async Flow is enabled and CallContext will be used for ambient transaction.
                _threadContextData = CallContextCurrentData.CreateOrGetCurrentData(ContextKey);

                if (_savedCurrentScope == null && _savedCurrent == null)
                {
                    // Clear TLS data so that transaction doesn't leak from current thread.
                    ContextData.TLSCurrentData = null;
                }
            }
            else
            {
                // Legacy TransactionScope. Use TLS to track ambient transaction context.
                _threadContextData = ContextData.TLSCurrentData;
                CallContextCurrentData.ClearCurrentData(ContextKey, false);
            }

            // This call needs to be done first
            SetCurrent(_expectedCurrent);
            _threadContextData.CurrentScope = this;
        }
 /// <summary>
 /// Initializes a new instance of the TransactionScope class with the specified 
 /// timeout value and COM+ interoperability requirements, and sets the specified 
 /// transaction as the ambient transaction, so that transactional work done inside 
 /// the scope uses this transDoFactory. 
 /// </summary>
 /// <param name="transactionToUse">Represents a transaction.</param>
 /// <param name="scopeTimeout">The TimeSpan after which the transaction scope times out and aborts the transaction.</param>
 /// <param name="interopOption">An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.</param>
 public TransactionDecorator(Transaction transactionToUse, TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption )
 {
     _transactionToUse = transactionToUse;
     _scopeTimeout = scopeTimeout;
     _interopOption = interopOption;
     if (_dataProvider != "System.Data.OleDb")
         _scope = new TransactionScope(_transactionToUse, _scopeTimeout, _interopOption);
 }
Пример #17
0
        public TransactionScope(
            Transaction transactionToUse,
            TimeSpan scopeTimeout,
            EnterpriseServicesInteropOption interopOption
        )
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceBase, this);
            }

            ValidateInteropOption(interopOption);
            _interopOption = interopOption;

            Initialize(
                transactionToUse,
                scopeTimeout,
                true);

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceBase, this);
            }
        }
 //
 // Summary:
 //     Initializes a new instance of the System.Transactions.TransactionScope class
 //     with the specified timeout value and COM+ interoperability requirements,
 //     and sets the specified transaction as the ambient transaction, so that transactional
 //     work done inside the scope uses this transaction.
 //
 // Parameters:
 //   transactionToUse:
 //     The transaction to be set as the ambient transaction, so that transactional
 //     work done inside the scope uses this transaction.
 //
 //   scopeTimeout:
 //     The System.TimeSpan after which the transaction scope times out and aborts
 //     the transaction.
 //
 //   interopOption:
 //     An instance of the System.Transactions.EnterpriseServicesInteropOption enumeration
 //     that describes how the associated transaction interacts with COM+ transactions.
 public NgTsTransactionScope(Transaction transactionToUse, TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
 {
     _transactionScope = new TransactionScope(transactionToUse, scopeTimeout, interopOption);
 }
Пример #19
0
 public TransactionAttribute(TransactionScopeOption scopeOption, IsolationLevel isolationLevel, EnterpriseServicesInteropOption entOption, int timeOut)
 {
     this.ScopeOption    = scopeOption;
     this.IsolationLevel = isolationLevel;
     this.TimeOut        = TimeSpan.FromSeconds(timeOut);
 }
Пример #20
0
 public DatabaseScope BeginTransaction(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
     TransactionScope = new TransactionScope(scopeOption, transactionOptions, interopOption);
     return(this);
 }
Пример #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DbTransactionScope"/> class with the specified timeout value and COM+ interoperability requirements,
        ///     and sets the specified transaction as the ambient transaction, so that transactional
        ///     work done inside the scope uses this transaction.
        /// </summary>
        /// <param name="transactionToUse">
        ///     The transaction to be set as the ambient transaction, so that transactional
        ///     work done inside the scope uses this transaction.
        /// </param>
        /// <param name="scopeTimeout">
        ///     The System.TimeSpan after which the transaction scope times out and aborts
        ///     the transaction.
        /// </param>
        /// <param name="interopOption">
        ///     An instance of the System.Transactions.EnterpriseServicesInteropOption enumeration
        ///     that describes how the associated transaction interacts with COM+ transactions.
        /// </param>
        public DbTransactionScope(Transaction transactionToUse, TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
        {
            if (Log.Enabled) Log.Entry("DbTransactionScope", Transaction.Current);

            m_scope = new TransactionScope(transactionToUse, scopeTimeout, interopOption);
            Initialize();

            if (Log.Enabled) Log.Exit("DbTransactionScope", Transaction.Current);
        }
Пример #22
0
        public TransactionScope(
            Transaction transactionToUse,
            TimeSpan scopeTimeout,
            EnterpriseServicesInteropOption interopOption
        )
        {
            if ( !TransactionManager._platformValidated ) TransactionManager.ValidatePlatform();

            if ( DiagnosticTrace.Verbose )
            {
                 MethodEnteredTraceRecord.Trace( SR.GetString( SR.TraceSourceBase ),
                     "TransactionScope.ctor( Transaction, TimeSpan, EnterpriseServicesInteropOption )"
                     );
            }

            ValidateInteropOption( interopOption );
            this.interopOption = interopOption;

            Initialize( 
                transactionToUse,
                scopeTimeout,
                true
                );

            if ( DiagnosticTrace.Verbose )
            {
                MethodExitedTraceRecord.Trace( SR.GetString( SR.TraceSourceBase ),
                    "TransactionScope.ctor( Transaction, TimeSpan, EnterpriseServicesInteropOption )"
                    );
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionScopeCallHandler"/> class.
 /// </summary>
 /// <param name="transactionScopeOption">
 /// An instance of the TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.
 /// </param>
 /// <param name="transactionOptions">
 /// A TransactionOptions structure that describes the transaction options to use if a new transaction is created. If an existing transaction is used, the timeout value in this parameter applies to the transaction scope. If that time expires before the scope is disposed, the transaction is aborted.
 /// </param>
 /// <param name="interopOption">
 /// An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.
 /// </param>
 /// <param name="complete">
 /// Whether the Transaction should be completed when the next handler executed without exceptions.
 /// </param>
 /// <param name="order">
 /// Order in which handler will be executed.
 /// </param>
 public TransactionScopeCallHandler(
     TransactionScopeOption transactionScopeOption, 
     TransactionOptions transactionOptions, 
     EnterpriseServicesInteropOption interopOption, 
     bool complete, 
     int order)
     : this(transactionScopeOption, transactionOptions, interopOption, complete)
 {
     this.Order = order;
 }
 //
 // Summary:
 //     Initializes a new instance of the System.Transactions.TransactionScope class
 //     with the specified scope and COM+ interoperability requirements, and transaction
 //     options.
 //
 // Parameters:
 //   scopeOption:
 //     An instance of the System.Transactions.TransactionScopeOption enumeration
 //     that describes the transaction requirements associated with this transaction
 //     scope.
 //
 //   transactionOptions:
 //     A System.Transactions.TransactionOptions structure that describes the transaction
 //     options to use if a new transaction is created. If an existing transaction
 //     is used, the timeout value in this parameter applies to the transaction scope.
 //     If that time expires before the scope is disposed, the transaction is aborted.
 //
 //   interopOption:
 //     An instance of the System.Transactions.EnterpriseServicesInteropOption enumeration
 //     that describes how the associated transaction interacts with COM+ transactions.
 public NgTsTransactionScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
     _transactionScope = new TransactionScope(scopeOption, transactionOptions, interopOption);
 }
 /// <summary>
 /// Creates the transaction scope.
 /// </summary>
 /// <param name="txScopeOption">The tx scope option.</param>
 /// <param name="txOptions">The tx options.</param>
 /// <param name="interopOption">The interop option.</param>
 public void CreateTransactionScope(TransactionScopeOption txScopeOption, TransactionOptions txOptions,
                                    EnterpriseServicesInteropOption interopOption)
 {
     txScope = new TransactionScope(txScopeOption, txOptions, interopOption);
 }
 private void ValidateInteropOption(EnterpriseServicesInteropOption interopOption)
 {
     if ((interopOption < EnterpriseServicesInteropOption.None) || (interopOption > EnterpriseServicesInteropOption.Full))
     {
         throw new ArgumentOutOfRangeException("interopOption");
     }
 }
 private void PushScope()
 {
     if (!this.interopModeSpecified)
     {
         this.interopOption = Transaction.InteropMode(this.savedCurrentScope);
     }
     this.SetCurrent(this.expectedCurrent);
     this.threadContextData.CurrentScope = this;
 }
 public TransactionScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
     if (!TransactionManager._platformValidated)
     {
         TransactionManager.ValidatePlatform();
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), "TransactionScope.ctor( TransactionScopeOption, TransactionOptions, EnterpriseServicesInteropOption )");
     }
     this.ValidateScopeTimeout("transactionOptions.Timeout", transactionOptions.Timeout);
     TimeSpan timeout = transactionOptions.Timeout;
     transactionOptions.Timeout = TransactionManager.ValidateTimeout(transactionOptions.Timeout);
     TransactionManager.ValidateIsolationLevel(transactionOptions.IsolationLevel);
     this.ValidateInteropOption(interopOption);
     this.interopModeSpecified = true;
     this.interopOption = interopOption;
     if (this.NeedToCreateTransaction(scopeOption))
     {
         this.committableTransaction = new CommittableTransaction(transactionOptions);
         this.expectedCurrent = this.committableTransaction.Clone();
     }
     else if (((null != this.expectedCurrent) && (IsolationLevel.Unspecified != transactionOptions.IsolationLevel)) && (this.expectedCurrent.IsolationLevel != transactionOptions.IsolationLevel))
     {
         throw new ArgumentException(System.Transactions.SR.GetString("TransactionScopeIsolationLevelDifferentFromTransaction"), "transactionOptions.IsolationLevel");
     }
     if (((null != this.expectedCurrent) && (null == this.committableTransaction)) && (TimeSpan.Zero != timeout))
     {
         this.scopeTimer = new Timer(new System.Threading.TimerCallback(TransactionScope.TimerCallback), this, timeout, TimeSpan.Zero);
     }
     if (DiagnosticTrace.Information)
     {
         if (null == this.expectedCurrent)
         {
             TransactionScopeCreatedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), TransactionTraceIdentifier.Empty, TransactionScopeResult.NoTransaction);
         }
         else
         {
             TransactionScopeResult usingExistingCurrent;
             if (null == this.committableTransaction)
             {
                 usingExistingCurrent = TransactionScopeResult.UsingExistingCurrent;
             }
             else
             {
                 usingExistingCurrent = TransactionScopeResult.CreatedTransaction;
             }
             TransactionScopeCreatedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), this.expectedCurrent.TransactionTraceId, usingExistingCurrent);
         }
     }
     this.PushScope();
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), "TransactionScope.ctor( TransactionScopeOption, TransactionOptions, EnterpriseServicesInteropOption )");
     }
 }
 public TransactionScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
 }
Пример #30
0
 /// <summary>
 /// См. <see cref="IDataContext.CreateScope(TransactionScopeOption, TransactionOptions, EnterpriseServicesInteropOption)"/>.
 /// </summary>
 public ITransactionScope CreateScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
     return(_context.CreateScope(scopeOption, transactionOptions, interopOption));
 }
Пример #31
0
 // ValidateInteropOption
 //
 // Validate a given interop Option
 private void ValidateInteropOption(EnterpriseServicesInteropOption interopOption)
 {
     if (interopOption < EnterpriseServicesInteropOption.None || interopOption > EnterpriseServicesInteropOption.Full)
     {
         throw new ArgumentOutOfRangeException(nameof(interopOption));
     }
 }
Пример #32
0
 /// <summary>
 /// Initializes a new instance of the TransactionScope class
 ///     with the specified scope and COM+ interoperability requirements, and transaction
 ///     options.
 /// </summary>
 /// <param name="scopeOption">An instance of the TransactionScopeOption enumeration
 ///     that describes the transaction requirements associated with this transaction
 ///     scope.</param>
 /// <param name="transactionOptions">A TransactionOptions structure that describes the transaction
 ///     options to use if a new transaction is created. If an existing transaction
 ///     is used, the timeout value in this parameter applies to the transaction scope.
 ///     If that time expires before the scope is disposed, the transaction is aborted.</param>
 /// <param name="interopOption">An instance of the EnterpriseServicesInteropOption enumeration
 ///     that describes how the associated transaction interacts with COM+ transactions.
 /// </param>
 public TransactionScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
     this.scope = new System.Transactions.TransactionScope(scopeOption, transactionOptions, interopOption);
 }
Пример #33
0
        public TransactionScope(
            TransactionScopeOption scopeOption,
            TransactionOptions transactionOptions,
            EnterpriseServicesInteropOption interopOption)
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceBase,
                    "TransactionScope.ctor( TransactionScopeOption, TransactionOptions, EnterpriseServicesInteropOption )");
            }

            ValidateScopeTimeout("transactionOptions.Timeout", transactionOptions.Timeout);
            TimeSpan scopeTimeout = transactionOptions.Timeout;

            transactionOptions.Timeout = TransactionManager.ValidateTimeout(transactionOptions.Timeout);
            TransactionManager.ValidateIsolationLevel(transactionOptions.IsolationLevel);

            ValidateInteropOption(interopOption);
            _interopModeSpecified = true;
            _interopOption = interopOption;

            if (NeedToCreateTransaction(scopeOption))
            {
                _committableTransaction = new CommittableTransaction(transactionOptions);
                _expectedCurrent = _committableTransaction.Clone();
            }
            else
            {
                if (null != _expectedCurrent)
                {
                    // If the requested IsolationLevel is stronger than that of the specified transaction, throw.
                    if ((IsolationLevel.Unspecified != transactionOptions.IsolationLevel) && (_expectedCurrent.IsolationLevel != transactionOptions.IsolationLevel))
                    {
                        throw new ArgumentException(SR.TransactionScopeIsolationLevelDifferentFromTransaction, "transactionOptions.IsolationLevel");
                    }
                }
            }

            if ((null != _expectedCurrent) && (null == _committableTransaction) && (TimeSpan.Zero != scopeTimeout))
            {
                // BUGBUG: Scopes should use a shared timer
                _scopeTimer = new Timer(
                    TimerCallback,
                    this,
                    scopeTimeout,
                    TimeSpan.Zero);
            }

            if (DiagnosticTrace.Information)
            {
                if (null == _expectedCurrent)
                {
                    TransactionScopeCreatedTraceRecord.Trace(SR.TraceSourceBase,
                        TransactionTraceIdentifier.Empty,
                        TransactionScopeResult.NoTransaction);
                }
                else
                {
                    TransactionScopeResult scopeResult;

                    if (null == _committableTransaction)
                    {
                        scopeResult = TransactionScopeResult.UsingExistingCurrent;
                    }
                    else
                    {
                        scopeResult = TransactionScopeResult.CreatedTransaction;
                    }

                    TransactionScopeCreatedTraceRecord.Trace(SR.TraceSourceBase,
                        _expectedCurrent.TransactionTraceId,
                        scopeResult);
                }
            }

            PushScope();

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceBase,
                    "TransactionScope.ctor( TransactionScopeOption, TransactionOptions, EnterpriseServicesInteropOption )");
            }
        }
Пример #34
0
 public TransactionAttribute(TransactionScopeOption scopeOption = TransactionScopeOption.Required, IsolationLevel isolationLevel = IsolationLevel.Serializable, EnterpriseServicesInteropOption entOption = EnterpriseServicesInteropOption.None) : this(scopeOption, isolationLevel, entOption, DefaultTimeOut)
 {
 }
Пример #35
0
        public TransactionScope(
            Transaction transactionToUse,
            TimeSpan scopeTimeout,
            EnterpriseServicesInteropOption interopOption
        )
        {
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceBase,
                    "TransactionScope.ctor( Transaction, TimeSpan, EnterpriseServicesInteropOption )");
            }

            ValidateInteropOption(interopOption);
            _interopOption = interopOption;

            Initialize(
                transactionToUse,
                scopeTimeout,
                true);

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceBase,
                    "TransactionScope.ctor( Transaction, TimeSpan, EnterpriseServicesInteropOption )");
            }
        }
Пример #36
0
        public TransactionScope(
            TransactionScopeOption scopeOption,
            TransactionOptions transactionOptions,
            EnterpriseServicesInteropOption interopOption)
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceBase, this);
            }

            ValidateScopeTimeout("transactionOptions.Timeout", transactionOptions.Timeout);
            TimeSpan scopeTimeout = transactionOptions.Timeout;

            transactionOptions.Timeout = TransactionManager.ValidateTimeout(transactionOptions.Timeout);
            TransactionManager.ValidateIsolationLevel(transactionOptions.IsolationLevel);

            ValidateInteropOption(interopOption);
            _interopModeSpecified = true;
            _interopOption        = interopOption;

            if (NeedToCreateTransaction(scopeOption))
            {
                _committableTransaction = new CommittableTransaction(transactionOptions);
                _expectedCurrent        = _committableTransaction.Clone();
            }
            else
            {
                if (null != _expectedCurrent)
                {
                    // If the requested IsolationLevel is stronger than that of the specified transaction, throw.
                    if ((IsolationLevel.Unspecified != transactionOptions.IsolationLevel) && (_expectedCurrent.IsolationLevel != transactionOptions.IsolationLevel))
                    {
                        throw new ArgumentException(SR.TransactionScopeIsolationLevelDifferentFromTransaction, "transactionOptions.IsolationLevel");
                    }
                }
            }

            if ((null != _expectedCurrent) && (null == _committableTransaction) && (TimeSpan.Zero != scopeTimeout))
            {
                // BUGBUG: Scopes should use a shared timer
                _scopeTimer = new Timer(
                    TimerCallback,
                    this,
                    scopeTimeout,
                    TimeSpan.Zero);
            }

            if (null == _expectedCurrent)
            {
                if (etwLog.IsEnabled())
                {
                    etwLog.TransactionScopeCreated(TransactionTraceIdentifier.Empty, TransactionScopeResult.NoTransaction);
                }
            }
            else
            {
                TransactionScopeResult scopeResult;

                if (null == _committableTransaction)
                {
                    scopeResult = TransactionScopeResult.UsingExistingCurrent;
                }
                else
                {
                    scopeResult = TransactionScopeResult.CreatedTransaction;
                }

                if (etwLog.IsEnabled())
                {
                    etwLog.TransactionScopeCreated(_expectedCurrent.TransactionTraceId, scopeResult);
                }
            }

            PushScope();

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceBase, this);
            }
        }
Пример #37
0
 //
 // Summary:
 //     Initializes a new instance of the System.Transactions.TransactionScope class
 //     with the specified timeout value and COM+ interoperability requirements,
 //     and sets the specified transaction as the ambient transaction, so that transactional
 //     work done inside the scope uses this transaction.
 //
 // Parameters:
 //   transactionToUse:
 //     The transaction to be set as the ambient transaction, so that transactional
 //     work done inside the scope uses this transaction.
 //
 //   scopeTimeout:
 //     The System.TimeSpan after which the transaction scope times out and aborts
 //     the transaction.
 //
 //   interopOption:
 //     An instance of the System.Transactions.EnterpriseServicesInteropOption enumeration
 //     that describes how the associated transaction interacts with COM+ transactions.
 public NgTsTransactionScope(Transaction transactionToUse, TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
 {
     _transactionScope = new TransactionScope(transactionToUse, scopeTimeout, interopOption);
 }
 public TransactionCallHandler(TransactionScopeOption transactionScopeOption,TransactionOptions transactionOptions,EnterpriseServicesInteropOption enterpriseServicesInteropOption)
 {
     this.TransactionOptions = transactionOptions;
     this.TransactionScopeOption = transactionScopeOption;
     this.EnterpriseServicesInteropOption = enterpriseServicesInteropOption;
 }
Пример #39
0
        public NhTransactionScope(System.Transactions.Transaction transactionToUse, TimeSpan scopeTimeout,
            EnterpriseServicesInteropOption interopOption)
        {
            // Infer equivalent transaction scope from context (to allow consistent interleaving of TransactionScopes)
            var scopeOption = GetTransactionScopeOption(transactionToUse);

            // Redirect request (System.Transactions.Transaction.Current may change!)
            m_transactionScope = new TransactionScope(transactionToUse, scopeTimeout, interopOption);
            InitializeScopeLinking(scopeOption);
        }
Пример #40
0
 /// <summary>
 /// Creates the transaction scope.
 /// </summary>
 /// <param name="txScopeOption">The tx scope option.</param>
 /// <param name="txOptions">The tx options.</param>
 /// <param name="interopOption">The interop option.</param>
 public void CreateTransactionScope(TransactionScopeOption txScopeOption, TransactionOptions txOptions,
                                    EnterpriseServicesInteropOption interopOption)
 {
     txScope = new TransactionScope(txScopeOption, txOptions, interopOption);
 }
Пример #41
0
 /// <summary>
 /// Initializes a new instance of the TransactionScope class
 ///     with the specified scope and COM+ interoperability requirements, and transaction
 ///     options.
 /// </summary>
 /// <param name="scopeOption">An instance of the TransactionScopeOption enumeration
 ///     that describes the transaction requirements associated with this transaction
 ///     scope.</param>
 /// <param name="transactionOptions">A TransactionOptions structure that describes the transaction
 ///     options to use if a new transaction is created. If an existing transaction
 ///     is used, the timeout value in this parameter applies to the transaction scope.
 ///     If that time expires before the scope is disposed, the transaction is aborted.</param>
 /// <param name="interopOption">An instance of the EnterpriseServicesInteropOption enumeration
 ///     that describes how the associated transaction interacts with COM+ transactions.
 /// </param>
 public TransactionScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
     this.scope = new System.Transactions.TransactionScope(scopeOption, transactionOptions, interopOption);
 }
 /// <summary>
 /// Initializes a new instance of the TransactionScope class with the 
 /// specified scope and COM+ interoperability requirements, and 
 /// transaction options.
 /// </summary>
 /// <param name="scopeOption">TransactionScopeOption enumeration that describes the transaction requirements associated with this transaction scope.</param>
 /// <param name="transactionOptions">A TransactionOptions structure that describes the transaction options to use if a new transaction is created. If an existing transaction is used, the timeout value in this parameter applies to the transaction scope. If that time expires before the scope is disposed, the transaction is aborted.</param>
 /// <param name="interopOption">An instance of the EnterpriseServicesInteropOption enumeration that describes how the associated transaction interacts with COM+ transactions.</param>
 public TransactionDecorator(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
     _scopeOption = scopeOption;
     _transactionOptions = transactionOptions;
     _interopOption = interopOption;
     if (_dataProvider != "System.Data.OleDb")
         _scope = new TransactionScope(_scopeOption, _transactionOptions, _interopOption);
 }
Пример #43
0
 public ITransactionScope CreateScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
     return(new Internal.TransactionScopeInternal(scopeOption, transactionOptions, interopOption));
 }
Пример #44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DbTransactionScope"/> class
        /// with the specified scope and COM+ interoperability requirements, and transaction
        ///  options.
        /// </summary>
        /// <param name="scopeOption">
        ///     An instance of the System.Transactions.TransactionScopeOption enumeration
        ///     that describes the transaction requirements associated with this transaction
        ///     scope.
        /// </param>
        /// <param name="transactionOptions">
        ///     A System.Transactions.TransactionOptions structure that describes the transaction
        ///     options to use if a new transaction is created. If an existing transaction
        ///     is used, the timeout value in this parameter applies to the transaction scope.
        ///     If that time expires before the scope is disposed, the transaction is aborted.
        /// </param>
        /// <param name="interopOption">
        ///     An instance of the System.Transactions.EnterpriseServicesInteropOption enumeration
        ///     that describes how the associated transaction interacts with COM+ transactions.
        /// </param>
        public DbTransactionScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
        {
            if (Log.Enabled) Log.Entry("DbTransactionScope", Transaction.Current);

            m_scope = new TransactionScope(scopeOption, transactionOptions, interopOption);
            Initialize();

            if (Log.Enabled) Log.Exit("DbTransactionScope", Transaction.Current);
        }
Пример #45
0
 public TransactionScopeImpl(TransactionScopeOption scopeOption, TransactionOptions transactionOptions,
                             EnterpriseServicesInteropOption interopOption)
 {
     _wrapped = new TransactionScope(scopeOption, transactionOptions, interopOption);
 }
 public TransactionScope(Transaction transactionToUse, System.TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
 {
 }
Пример #47
0
 public TransactionScopeImpl(Transaction transactionToUse, TimeSpan scopeTimeout,
                             EnterpriseServicesInteropOption interopOption)
 {
     _wrapped = new TransactionScope(transactionToUse, scopeTimeout, interopOption);
 }
Пример #48
0
 /// <summary>
 /// См. <see cref="IDataContext.CreateScope(Transaction, TimeSpan, EnterpriseServicesInteropOption)"/>.
 /// </summary>
 public ITransactionScope CreateScope(Transaction transactionToUse, TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
 {
     return(_context.CreateScope(transactionToUse, scopeTimeout, interopOption));
 }
Пример #49
0
 public DatabaseScope BeginTransaction(Transaction transactionToUse, TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
 {
     TransactionScope = new TransactionScope(transactionToUse, scopeTimeout, interopOption);
     return(this);
 }
Пример #50
0
 public TransactionScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
 }
Пример #51
0
 /// <summary>
 ///  Initializes a new instance of the TransactionScope class
 ///     with the specified timeout value and COM+ interoperability requirements,
 ///     and sets the specified transaction as the ambient transaction, so that transactional
 ///     work done inside the scope uses this transaction.
 /// </summary>
 /// <param name="transactionToUse"> The transaction to be set as the ambient transaction, so that transactional
 ///     work done inside the scope uses this transaction.</param>
 /// <param name="scopeTimeout">The System.TimeSpan after which the transaction scope times out and aborts
 ///     the transaction.</param>
 /// <param name="interopOption"> An instance of the EnterpriseServicesInteropOption enumeration
 ///     that describes how the associated transaction interacts with COM+ transactions.
 /// </param>
 public TransactionScope(Transaction transactionToUse, TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
 {
     this.scope = new System.Transactions.TransactionScope(transactionToUse, scopeTimeout, interopOption);
 }
Пример #52
0
 public TransactionScope(Transaction transactionToUse, System.TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
 {
 }
Пример #53
0
 /// <summary>
 ///  Initializes a new instance of the TransactionScope class
 ///     with the specified timeout value and COM+ interoperability requirements,
 ///     and sets the specified transaction as the ambient transaction, so that transactional
 ///     work done inside the scope uses this transaction.
 /// </summary>
 /// <param name="transactionToUse"> The transaction to be set as the ambient transaction, so that transactional
 ///     work done inside the scope uses this transaction.</param>
 /// <param name="scopeTimeout">The System.TimeSpan after which the transaction scope times out and aborts
 ///     the transaction.</param>
 /// <param name="interopOption"> An instance of the EnterpriseServicesInteropOption enumeration
 ///     that describes how the associated transaction interacts with COM+ transactions.
 /// </param>
 public TransactionScope(Transaction transactionToUse, TimeSpan scopeTimeout, EnterpriseServicesInteropOption interopOption)
 {
     this.scope = new System.Transactions.TransactionScope(transactionToUse, scopeTimeout, interopOption);
 }
Пример #54
0
 //
 // Summary:
 //     Initializes a new instance of the System.Transactions.TransactionScope class
 //     with the specified scope and COM+ interoperability requirements, and transaction
 //     options.
 //
 // Parameters:
 //   scopeOption:
 //     An instance of the System.Transactions.TransactionScopeOption enumeration
 //     that describes the transaction requirements associated with this transaction
 //     scope.
 //
 //   transactionOptions:
 //     A System.Transactions.TransactionOptions structure that describes the transaction
 //     options to use if a new transaction is created. If an existing transaction
 //     is used, the timeout value in this parameter applies to the transaction scope.
 //     If that time expires before the scope is disposed, the transaction is aborted.
 //
 //   interopOption:
 //     An instance of the System.Transactions.EnterpriseServicesInteropOption enumeration
 //     that describes how the associated transaction interacts with COM+ transactions.
 public NgTsTransactionScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions, EnterpriseServicesInteropOption interopOption)
 {
     _transactionScope = new TransactionScope(scopeOption, transactionOptions, interopOption);
 }
Пример #55
0
 public NhTransactionScope(TransactionScopeOption scopeOption, TransactionOptions transactionOptions,
     EnterpriseServicesInteropOption interopOption)
 {
     m_transactionScope = new TransactionScope(scopeOption, transactionOptions, interopOption);
     InitializeScopeLinking(scopeOption);
 }