Example #1
0
        internal void Prepare(OletxVolatileEnlistmentContainer container)
        {
            OletxVolatileEnlistmentState    active = OletxVolatileEnlistmentState.Active;
            IEnlistmentNotificationInternal iEnlistmentNotification = null;

            lock (this)
            {
                iEnlistmentNotification = this.iEnlistmentNotification;
                if (this.state == OletxVolatileEnlistmentState.Active)
                {
                    active = this.state = OletxVolatileEnlistmentState.Preparing;
                }
                else
                {
                    active = this.state;
                }
                this.container = container;
            }
            if (OletxVolatileEnlistmentState.Preparing == active)
            {
                if (iEnlistmentNotification != null)
                {
                    if (DiagnosticTrace.Verbose)
                    {
                        EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.Prepare);
                    }
                    iEnlistmentNotification.Prepare(this);
                    return;
                }
                if (DiagnosticTrace.Critical)
                {
                    InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "");
                }
                throw new InvalidOperationException(System.Transactions.SR.GetString("InternalError"));
            }
            if (OletxVolatileEnlistmentState.Done == active)
            {
                container.DecrementOutstandingNotifications(true);
            }
            else if ((OletxVolatileEnlistmentState.Prepared == active) && this.enlistDuringPrepareRequired)
            {
                container.DecrementOutstandingNotifications(true);
            }
            else if ((OletxVolatileEnlistmentState.Aborting == active) || (OletxVolatileEnlistmentState.Aborted == active))
            {
                container.DecrementOutstandingNotifications(false);
            }
            else
            {
                if (DiagnosticTrace.Critical)
                {
                    InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "");
                }
                throw new InvalidOperationException(System.Transactions.SR.GetString("InternalError"));
            }
        }
 internal void Prepare(OletxVolatileEnlistmentContainer container)
 {
     OletxVolatileEnlistmentState active = OletxVolatileEnlistmentState.Active;
     IEnlistmentNotificationInternal iEnlistmentNotification = null;
     lock (this)
     {
         iEnlistmentNotification = this.iEnlistmentNotification;
         if (this.state == OletxVolatileEnlistmentState.Active)
         {
             active = this.state = OletxVolatileEnlistmentState.Preparing;
         }
         else
         {
             active = this.state;
         }
         this.container = container;
     }
     if (OletxVolatileEnlistmentState.Preparing == active)
     {
         if (iEnlistmentNotification != null)
         {
             if (DiagnosticTrace.Verbose)
             {
                 EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.Prepare);
             }
             iEnlistmentNotification.Prepare(this);
             return;
         }
         if (DiagnosticTrace.Critical)
         {
             InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "");
         }
         throw new InvalidOperationException(System.Transactions.SR.GetString("InternalError"));
     }
     if (OletxVolatileEnlistmentState.Done == active)
     {
         container.DecrementOutstandingNotifications(true);
     }
     else if ((OletxVolatileEnlistmentState.Prepared == active) && this.enlistDuringPrepareRequired)
     {
         container.DecrementOutstandingNotifications(true);
     }
     else if ((OletxVolatileEnlistmentState.Aborting == active) || (OletxVolatileEnlistmentState.Aborted == active))
     {
         container.DecrementOutstandingNotifications(false);
     }
     else
     {
         if (DiagnosticTrace.Critical)
         {
             InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "");
         }
         throw new InvalidOperationException(System.Transactions.SR.GetString("InternalError"));
     }
 }
        public bool PrepareRequest(bool singlePhase, byte[] prepareInfo)
        {
            IEnlistmentShim                 enlistmentShim          = null;
            OletxEnlistmentState            active                  = OletxEnlistmentState.Active;
            IEnlistmentNotificationInternal iEnlistmentNotification = null;
            OletxRecoveryInformation        thingToConvert          = null;

            lock (this)
            {
                if (this.state == OletxEnlistmentState.Active)
                {
                    active = this.state = OletxEnlistmentState.Preparing;
                }
                else
                {
                    active = this.state;
                }
                iEnlistmentNotification = this.iEnlistmentNotification;
                enlistmentShim          = this.EnlistmentShim;
                base.oletxTransaction.realOletxTransaction.TooLateForEnlistments = true;
            }
            if (OletxEnlistmentState.Preparing == active)
            {
                thingToConvert     = new OletxRecoveryInformation(prepareInfo);
                this.isSinglePhase = singlePhase;
                long length = prepareInfo.Length;
                this.proxyPrepareInfoByteArray = new byte[length];
                Array.Copy(prepareInfo, this.proxyPrepareInfoByteArray, length);
                if (this.isSinglePhase && this.canDoSinglePhase)
                {
                    ISinglePhaseNotificationInternal internal3 = (ISinglePhaseNotificationInternal)iEnlistmentNotification;
                    this.state = OletxEnlistmentState.SinglePhaseCommitting;
                    if (DiagnosticTrace.Verbose)
                    {
                        EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.SinglePhaseCommit);
                    }
                    internal3.SinglePhaseCommit(this);
                    return(true);
                }
                byte[] resourceManagerRecoveryInformation = TransactionManager.ConvertToByteArray(thingToConvert);
                this.state = OletxEnlistmentState.Preparing;
                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);
                return(false);
            }
            if (OletxEnlistmentState.Prepared == active)
            {
                try
                {
                    enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Prepared);
                    return(false);
                }
                catch (COMException exception3)
                {
                    OletxTransactionManager.ProxyException(exception3);
                    throw;
                }
            }
            if (OletxEnlistmentState.Done == active)
            {
                try
                {
                    bool flag;
                    try
                    {
                        enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.ReadOnly);
                        flag = true;
                    }
                    finally
                    {
                        this.FinishEnlistment();
                    }
                    return(flag);
                }
                catch (COMException exception2)
                {
                    OletxTransactionManager.ProxyException(exception2);
                    throw;
                }
            }
            try
            {
                enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Failed);
            }
            catch (COMException exception)
            {
                if (DiagnosticTrace.Verbose)
                {
                    ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
                }
            }
            return(true);
        }
        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");
            }
        }
 public bool PrepareRequest(bool singlePhase, byte[] prepareInfo)
 {
     IEnlistmentShim enlistmentShim = null;
     OletxEnlistmentState active = OletxEnlistmentState.Active;
     IEnlistmentNotificationInternal iEnlistmentNotification = null;
     OletxRecoveryInformation thingToConvert = null;
     lock (this)
     {
         if (this.state == OletxEnlistmentState.Active)
         {
             active = this.state = OletxEnlistmentState.Preparing;
         }
         else
         {
             active = this.state;
         }
         iEnlistmentNotification = this.iEnlistmentNotification;
         enlistmentShim = this.EnlistmentShim;
         base.oletxTransaction.realOletxTransaction.TooLateForEnlistments = true;
     }
     if (OletxEnlistmentState.Preparing == active)
     {
         thingToConvert = new OletxRecoveryInformation(prepareInfo);
         this.isSinglePhase = singlePhase;
         long length = prepareInfo.Length;
         this.proxyPrepareInfoByteArray = new byte[length];
         Array.Copy(prepareInfo, this.proxyPrepareInfoByteArray, length);
         if (this.isSinglePhase && this.canDoSinglePhase)
         {
             ISinglePhaseNotificationInternal internal3 = (ISinglePhaseNotificationInternal) iEnlistmentNotification;
             this.state = OletxEnlistmentState.SinglePhaseCommitting;
             if (DiagnosticTrace.Verbose)
             {
                 EnlistmentNotificationCallTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), base.InternalTraceIdentifier, NotificationCall.SinglePhaseCommit);
             }
             internal3.SinglePhaseCommit(this);
             return true;
         }
         byte[] resourceManagerRecoveryInformation = TransactionManager.ConvertToByteArray(thingToConvert);
         this.state = OletxEnlistmentState.Preparing;
         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);
         return false;
     }
     if (OletxEnlistmentState.Prepared == active)
     {
         try
         {
             enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Prepared);
             return false;
         }
         catch (COMException exception3)
         {
             OletxTransactionManager.ProxyException(exception3);
             throw;
         }
     }
     if (OletxEnlistmentState.Done == active)
     {
         try
         {
             bool flag;
             try
             {
                 enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.ReadOnly);
                 flag = true;
             }
             finally
             {
                 this.FinishEnlistment();
             }
             return flag;
         }
         catch (COMException exception2)
         {
             OletxTransactionManager.ProxyException(exception2);
             throw;
         }
     }
     try
     {
         enlistmentShim.PrepareRequestDone(OletxPrepareVoteType.Failed);
     }
     catch (COMException exception)
     {
         if (DiagnosticTrace.Verbose)
         {
             ExceptionConsumedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), exception);
         }
     }
     return true;
 }