Ejemplo n.º 1
0
        internal OletxTransaction PSPEPromote(InternalTransaction tx)
        {
            TransactionState state = tx.State;

            base.CommonEnterState(tx);
            OletxTransaction oletxTransactionFromTransmitterPropigationToken = null;

            try
            {
                byte[] propagationToken = tx.promoter.Promote();
                if (propagationToken == null)
                {
                    throw TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceLtm"), System.Transactions.SR.GetString("PromotedReturnedInvalidValue"), null);
                }
                try
                {
                    oletxTransactionFromTransmitterPropigationToken = TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(propagationToken);
                }
                catch (ArgumentException exception)
                {
                    throw TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceLtm"), System.Transactions.SR.GetString("PromotedReturnedInvalidValue"), exception);
                }
                if (TransactionManager.FindPromotedTransaction(oletxTransactionFromTransmitterPropigationToken.Identifier) != null)
                {
                    oletxTransactionFromTransmitterPropigationToken.Dispose();
                    throw TransactionException.CreateInvalidOperationException(System.Transactions.SR.GetString("TraceSourceLtm"), System.Transactions.SR.GetString("PromotedTransactionExists"), null);
                }
            }
            finally
            {
                state.CommonEnterState(tx);
            }
            return(oletxTransactionFromTransmitterPropigationToken);
        }
Ejemplo n.º 2
0
        public static Transaction GetTransactionFromTransmitterPropagationToken(
            byte[] propagationToken
            )
        {
            if (!TransactionManager._platformValidated)
            {
                TransactionManager.ValidatePlatform();
            }

            Transaction returnValue = null;

            if (null == propagationToken)
            {
                throw new ArgumentNullException("propagationToken");
            }

            if (propagationToken.Length < 24)
            {
                throw new ArgumentException(SR.GetString(SR.InvalidArgument), "propagationToken");
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                               "TransactionInterop.GetTransactionFromTransmitterPropagationToken"
                                               );
            }

            // Extract the transaction guid from the propagation token to see if we already have a
            // transaction object for the transaction.
            byte[] guidByteArray = new byte[16];
            for (int i = 0; i < guidByteArray.Length; i++)
            {
                // In a propagation token, the transaction guid is preceeded by two version DWORDs.
                guidByteArray[i] = propagationToken[i + 8];
            }

            Guid txId = new Guid(guidByteArray);

            // First check to see if there is a promoted LTM transaction with the same ID.  If there
            // is, just return that.
            Transaction tx = TransactionManager.FindPromotedTransaction(txId);

            if (null != tx)
            {
                if (DiagnosticTrace.Verbose)
                {
                    MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                                  "TransactionInterop.GetTransactionFromTransmitterPropagationToken"
                                                  );
                }
                return(tx);
            }

            OletxTransaction oleTx = TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(propagationToken);

            // If a transaction is found then FindOrCreate will Dispose the oletx
            // created.
            returnValue = TransactionManager.FindOrCreatePromotedTransaction(txId, oleTx);

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                              "TransactionInterop.GetTransactionFromTransmitterPropagationToken"
                                              );
            }
            return(returnValue);
        }