internal CommittableTransaction(IsolationLevel isoLevel, TimeSpan timeout) : base(isoLevel, (InternalTransaction)null) { base.internalTransaction = new InternalTransaction(timeout, this); base.internalTransaction.cloneCount = 1; base.cloneId = 1; if (DiagnosticTrace.Information) { TransactionCreatedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceLtm"), base.TransactionTraceId); } }
internal OletxCommittableTransaction CreateTransaction(TransactionOptions properties) { OletxCommittableTransaction transaction = null; ITransactionShim transactionShim = null; RealOletxTransaction realOletxTransaction = null; Guid empty = Guid.Empty; OutcomeEnlistment target = null; new DistributedTransactionPermission(PermissionState.Unrestricted).Demand(); TransactionManager.ValidateIsolationLevel(properties.IsolationLevel); if (IsolationLevel.Unspecified == properties.IsolationLevel) { properties.IsolationLevel = this.configuredTransactionOptions.IsolationLevel; } properties.Timeout = TransactionManager.ValidateTimeout(properties.Timeout); this.dtcTransactionManagerLock.AcquireReaderLock(-1); try { OletxTransactionIsolationLevel isolationLevel = ConvertIsolationLevel(properties.IsolationLevel); uint timeout = System.Transactions.Oletx.DtcTransactionManager.AdjustTimeout(properties.Timeout); target = new OutcomeEnlistment(); IntPtr zero = IntPtr.Zero; RuntimeHelpers.PrepareConstrainedRegions(); try { zero = HandleTable.AllocHandle(target); this.dtcTransactionManager.ProxyShimFactory.BeginTransaction(timeout, isolationLevel, zero, out empty, out transactionShim); } catch (COMException exception) { ProxyException(exception); throw; } finally { if ((transactionShim == null) && (zero != IntPtr.Zero)) { HandleTable.FreeHandle(zero); } } realOletxTransaction = new RealOletxTransaction(this, transactionShim, target, empty, isolationLevel, true); transaction = new OletxCommittableTransaction(realOletxTransaction); if (DiagnosticTrace.Information) { TransactionCreatedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), transaction.TransactionTraceId); } } finally { this.dtcTransactionManagerLock.ReleaseReaderLock(); } return(transaction); }
internal CommittableTransaction(IsolationLevel isoLevel, TimeSpan timeout) : base(isoLevel, (InternalTransaction)null) { // object to use for synchronization rather than locking on a public object _internalTransaction = new InternalTransaction(timeout, this); // Because we passed null for the internal transaction to the base class, we need to // fill in the traceIdentifier field here. _internalTransaction._cloneCount = 1; _cloneId = 1; if (DiagnosticTrace.Information) { TransactionCreatedTraceRecord.Trace(SR.TraceSourceLtm, TransactionTraceId); } }
internal OletxCommittableTransaction CreateTransaction( TransactionOptions properties ) { OletxCommittableTransaction tx = null; RealOletxTransaction realTransaction = null; ITransactionShim transactionShim = null; Guid txIdentifier = Guid.Empty; OutcomeEnlistment outcomeEnlistment = null; // Demand the distributed transation permission to create one of // these. DistributedTransactionPermission txPerm = new DistributedTransactionPermission(PermissionState.Unrestricted); txPerm.Demand(); TransactionManager.ValidateIsolationLevel(properties.IsolationLevel); // Never create a transaction with an IsolationLevel of Unspecified. if (IsolationLevel.Unspecified == properties.IsolationLevel) { properties.IsolationLevel = configuredTransactionOptions.IsolationLevel; } properties.Timeout = TransactionManager.ValidateTimeout(properties.Timeout); this.dtcTransactionManagerLock.AcquireReaderLock(-1); try { // OletxTransactionIsolationLevel oletxIsoLevel = OletxTransactionManager.ConvertIsolationLevel(properties.IsolationLevel); UInt32 oletxTimeout = DtcTransactionManager.AdjustTimeout(properties.Timeout); outcomeEnlistment = new OutcomeEnlistment(); IntPtr outcomeEnlistmentHandle = IntPtr.Zero; RuntimeHelpers.PrepareConstrainedRegions(); try { outcomeEnlistmentHandle = HandleTable.AllocHandle(outcomeEnlistment); dtcTransactionManager.ProxyShimFactory.BeginTransaction( oletxTimeout, oletxIsoLevel, outcomeEnlistmentHandle, out txIdentifier, out transactionShim ); } catch (COMException ex) { OletxTransactionManager.ProxyException(ex); throw; } finally { if (transactionShim == null && outcomeEnlistmentHandle != IntPtr.Zero) { HandleTable.FreeHandle(outcomeEnlistmentHandle); } } realTransaction = new RealOletxTransaction( this, transactionShim, outcomeEnlistment, txIdentifier, oletxIsoLevel, true ); tx = new OletxCommittableTransaction(realTransaction); if (DiagnosticTrace.Information) { TransactionCreatedTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx), tx.TransactionTraceId ); } } finally { this.dtcTransactionManagerLock.ReleaseReaderLock(); } return(tx); }