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 void Phase0Request(bool abortHint) { OletxVolatileEnlistment enlistment = null; int count = 0; OletxCommittableTransaction committableTransaction = null; bool flag = false; lock (this) { if (DiagnosticTrace.Verbose) { string methodName = "OletxPhase0VolatileEnlistmentContainer.Phase0Request, abortHint = " + abortHint.ToString(CultureInfo.CurrentCulture) + ", phase = " + this.phase.ToString(CultureInfo.CurrentCulture); MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), methodName); } this.aborting = abortHint; committableTransaction = base.realOletxTransaction.committableTransaction; if ((committableTransaction != null) && !committableTransaction.CommitCalled) { flag = true; this.aborting = true; } if ((2 == base.phase) || (-1 == base.phase)) { if (-1 == base.phase) { base.phase = 0; } if ((this.aborting || this.tmWentDown) || (flag || (2 == base.phase))) { if (this.phase0EnlistmentShim != null) { try { this.phase0EnlistmentShim.Phase0Done(false); base.alreadyVoted = true; } catch (COMException exception) { if (DiagnosticTrace.Verbose) { ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception); } } } return; } base.outstandingNotifications = base.enlistmentList.Count; count = base.enlistmentList.Count; if (count == 0) { base.outstandingNotifications = 1; } } else { if (DiagnosticTrace.Critical) { InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxPhase0VolatileEnlistmentContainer.Phase0Request, phase != -1"); } throw new InvalidOperationException(System.Transactions.SR.GetString("InternalError")); } } if (count == 0) { this.DecrementOutstandingNotifications(true); } else { for (int i = 0; i < count; i++) { enlistment = base.enlistmentList[i] as OletxVolatileEnlistment; if (enlistment == null) { if (DiagnosticTrace.Critical) { InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), ""); } throw new InvalidOperationException(System.Transactions.SR.GetString("InternalError")); } enlistment.Prepare(this); } } if (DiagnosticTrace.Verbose) { string str = "OletxPhase0VolatileEnlistmentContainer.Phase0Request, abortHint = " + abortHint.ToString(CultureInfo.CurrentCulture); MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), str); } }
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; }
public void Phase0Request(bool abortingHint) { IEnlistmentNotificationInternal iEnlistmentNotification = null; OletxEnlistmentState active = OletxEnlistmentState.Active; OletxCommittableTransaction committableTransaction = null; bool flag = false; if (DiagnosticTrace.Verbose) { MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxEnlistment.Phase0Request"); } committableTransaction = base.oletxTransaction.realOletxTransaction.committableTransaction; if ((committableTransaction != null) && !committableTransaction.CommitCalled) { flag = true; } lock (this) { this.aborting = abortingHint; if (this.state == OletxEnlistmentState.Active) { if ((this.aborting || flag) || this.tmWentDown) { if (this.phase0Shim != null) { try { this.phase0Shim.Phase0Done(false); } catch (COMException exception) { if (DiagnosticTrace.Verbose) { ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception); } } } } else { active = this.state = OletxEnlistmentState.Phase0Preparing; iEnlistmentNotification = this.iEnlistmentNotification; } } } if (iEnlistmentNotification != null) { if (OletxEnlistmentState.Phase0Preparing != active) { if (DiagnosticTrace.Verbose) { MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxEnlistment.Phase0Request"); } return; } byte[] buffer = this.transactionGuid.ToByteArray(); byte[] buffer2 = base.oletxResourceManager.resourceManagerIdentifier.ToByteArray(); byte[] buffer4 = new byte[buffer.Length + buffer2.Length]; Thread.MemoryBarrier(); this.proxyPrepareInfoByteArray = buffer4; int index = 0; for (index = 0; index < buffer.Length; index++) { this.proxyPrepareInfoByteArray[index] = buffer[index]; } for (index = 0; index < buffer2.Length; index++) { this.proxyPrepareInfoByteArray[buffer.Length + index] = buffer2[index]; } OletxRecoveryInformation thingToConvert = new OletxRecoveryInformation(this.proxyPrepareInfoByteArray); byte[] resourceManagerRecoveryInformation = TransactionManager.ConvertToByteArray(thingToConvert); this.prepareInfoByteArray = TransactionManager.GetRecoveryInformation(base.oletxResourceManager.oletxTransactionManager.CreationNodeName, resourceManagerRecoveryInformation); if (DiagnosticTrace.Verbose) { EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.Prepare); } iEnlistmentNotification.Prepare(this); } if (DiagnosticTrace.Verbose) { MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "OletxEnlistment.Phase0Request"); } }
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); }
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; }