示例#1
0
        protected unsafe int ReceiveByLookupIdCoreDtcTransacted(MsmqQueueHandle handle, long lookupId, NativeMsmqMessage message, MsmqTransactionMode transactionMode, int action)
        {
            IDtcTransaction dtcTransaction = GetNativeTransaction(transactionMode);

            IntPtr nativePropertiesPointer = message.Pin();

            try
            {
                if (dtcTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, nativePropertiesPointer, null, IntPtr.Zero, dtcTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(dtcTransaction);
                    }
                }
                else
                {
                    return(UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, nativePropertiesPointer, null, IntPtr.Zero, (IntPtr)GetTransactionConstant(transactionMode)));
                }
            }
            finally
            {
                message.Unpin();
            }
        }
示例#2
0
        int SendDtcTransacted(NativeMsmqMessage message, MsmqTransactionMode transactionMode)
        {
            IDtcTransaction dtcTransaction = GetNativeTransaction(transactionMode);

            MsmqQueueHandle handle = GetHandle();
            IntPtr          nativePropertiesPointer = message.Pin();

            try
            {
                if (dtcTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQSendMessage(handle, nativePropertiesPointer,
                                                                 dtcTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(dtcTransaction);
                    }
                }
                else
                {
                    return(UnsafeNativeMethods.MQSendMessage(handle, nativePropertiesPointer,
                                                             (IntPtr)GetTransactionConstant(transactionMode)));
                }
            }
            finally
            {
                message.Unpin();
            }
        }
示例#3
0
        unsafe int ReceiveCoreDtcTransacted(MsmqQueueHandle handle, NativeMsmqMessage message, TimeSpan timeout, MsmqTransactionMode transactionMode, int action)
        {
            IDtcTransaction dtcTransaction        = GetNativeTransaction(transactionMode);
            int             timeoutInMilliseconds = TimeoutHelper.ToMilliseconds(timeout);

            IntPtr nativePropertiesPointer = message.Pin();

            try
            {
                if (dtcTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), timeoutInMilliseconds,
                                                                    action, nativePropertiesPointer, null, IntPtr.Zero, IntPtr.Zero, dtcTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(dtcTransaction);
                    }
                }
                else
                {
                    return(UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), timeoutInMilliseconds,
                                                                action, nativePropertiesPointer, null, IntPtr.Zero, IntPtr.Zero, (IntPtr)GetTransactionConstant(transactionMode)));
                }
            }
            finally
            {
                message.Unpin();
            }
        }
        internal static SafeTransactionHandle Create(Transaction managedTransaction)
        {
            if (managedTransaction == null)
            {
                throw new InvalidOperationException(RegistryProviderStrings.InvalidOperation_NeedTransaction);
            }

            // MSDTC is not available on WinPE machine.
            // CommitableTransaction will use DTC APIs under the covers to get KTM transaction manager interface.
            // KTM is kernel Transaction Manager to handle file, registry etc and MSDTC provides an integration support
            // with KTM to handle transaction across kernel resources and MSDTC resources like SQL, MSMQ etc.
            // We need KTMRM service as well. WinPE doesn’t have these services installed
            if (Utils.IsWinPEHost() || PsUtils.IsRunningOnProcessorArchitectureARM())
            {
                throw new NotSupportedException(RegistryProviderStrings.NotSupported_KernelTransactions);
            }

            IDtcTransaction    dtcTransaction = TransactionInterop.GetDtcTransaction(managedTransaction);
            IKernelTransaction ktmInterface   = dtcTransaction as IKernelTransaction;

            if (null == ktmInterface)
            {
                throw new NotSupportedException(RegistryProviderStrings.NotSupported_KernelTransactions);
            }

            IntPtr ktmTxHandle;
            int    hr = ktmInterface.GetHandle(out ktmTxHandle);

            HandleError(hr);

            return(new SafeTransactionHandle(ktmTxHandle));
        }
 public TxnBatch(IBTTransportProxy transportProxy, ControlledTermination control, IDtcTransaction comTxn, CommittableTransaction transaction, ManualResetEvent orderedEvent, bool makeSuccessCall) : base(transportProxy, makeSuccessCall)
 {
     Control      = control;
     ComTxn       = comTxn;
     Transaction  = transaction;
     OrderedEvent = orderedEvent;
 }
        protected int ReceiveByLookupIdCoreDtcTransacted(MsmqQueueHandle handle, long lookupId, NativeMsmqMessage message, MsmqTransactionMode transactionMode, int action)
        {
            int             num;
            IDtcTransaction nativeTransaction = this.GetNativeTransaction(transactionMode);
            IntPtr          properties        = message.Pin();

            try
            {
                if (nativeTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, properties, null, IntPtr.Zero, nativeTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(nativeTransaction);
                    }
                }
                num = UnsafeNativeMethods.MQReceiveMessageByLookupId(handle, lookupId, action, properties, null, IntPtr.Zero, (IntPtr)this.GetTransactionConstant(transactionMode));
            }
            finally
            {
                message.Unpin();
            }
            return(num);
        }
        private int ReceiveCoreDtcTransacted(MsmqQueueHandle handle, NativeMsmqMessage message, TimeSpan timeout, MsmqTransactionMode transactionMode, int action)
        {
            int             num2;
            IDtcTransaction nativeTransaction = this.GetNativeTransaction(transactionMode);
            int             num        = TimeoutHelper.ToMilliseconds(timeout);
            IntPtr          properties = message.Pin();

            try
            {
                if (nativeTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), num, action, properties, null, IntPtr.Zero, IntPtr.Zero, nativeTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(nativeTransaction);
                    }
                }
                num2 = UnsafeNativeMethods.MQReceiveMessage(handle.DangerousGetHandle(), num, action, properties, null, IntPtr.Zero, IntPtr.Zero, (IntPtr)this.GetTransactionConstant(transactionMode));
            }
            finally
            {
                message.Unpin();
            }
            return(num2);
        }
        private int SendDtcTransacted(NativeMsmqMessage message, MsmqTransactionMode transactionMode)
        {
            int             num;
            IDtcTransaction nativeTransaction = this.GetNativeTransaction(transactionMode);
            MsmqQueueHandle handle            = this.GetHandle();
            IntPtr          properties        = message.Pin();

            try
            {
                if (nativeTransaction != null)
                {
                    try
                    {
                        return(UnsafeNativeMethods.MQSendMessage(handle, properties, nativeTransaction));
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(nativeTransaction);
                    }
                }
                num = UnsafeNativeMethods.MQSendMessage(handle, properties, (IntPtr)this.GetTransactionConstant(transactionMode));
            }
            finally
            {
                message.Unpin();
            }
            return(num);
        }
示例#9
0
        public static IDtcTransaction GetDtcTransaction(Transaction transaction)
        {
            if (!TransactionManager._platformValidated)
            {
                TransactionManager.ValidatePlatform();
            }
            if (null == transaction)
            {
                throw new ArgumentNullException("transaction");
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "TransactionInterop.GetDtcTransaction");
            }
            IDtcTransaction  transactionNative = null;
            OletxTransaction transaction2      = ConvertToOletxTransaction(transaction);

            try
            {
                transaction2.realOletxTransaction.TransactionShim.GetITransactionNative(out transactionNative);
            }
            catch (COMException exception)
            {
                OletxTransactionManager.ProxyException(exception);
                throw;
            }
            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "TransactionInterop.GetDtcTransaction");
            }
            return(transactionNative);
        }
示例#10
0
    public void GetITransactionNative(out IDtcTransaction transactionNative)
    {
        var cloner = (ITransactionCloner)Transaction;

        cloner.CloneWithCommitDisabled(out ITransaction returnTransaction);

        transactionNative = (IDtcTransaction)returnTransaction;
    }
示例#11
0
        public static void MoveToSubQueue(
            this MessageQueue queue,
            string subQueueName,
            Message message)
        {
            var    fullSubQueueName = @"DIRECT=OS:.\" + queue.QueueName + ";" + subQueueName;
            IntPtr queueHandle      = IntPtr.Zero;
            var    error            = NativeMethods.MQOpenQueue(fullSubQueueName, NativeMethods.MQ_MOVE_ACCESS,
                                                                NativeMethods.MQ_DENY_NONE, ref queueHandle);

            if (error != 0)
            {
                throw new TransportException("Failed to open queue: " + fullSubQueueName,
                                             new Win32Exception(error));
            }

            try
            {
                if (MsmqTransactionStrategy.Current != null)
                {
                    //var trans = _internalTransaction.GetValue(MsmqTransactionStrategy.Current, null);

                    error = NativeMethods.MQMoveMessage(queue.ReadHandle, queueHandle,
                                                        message.LookupId, null);
                    if (error != 0)
                    {
                        throw new TransportException("Failed to move message to queue: " + fullSubQueueName,
                                                     new Win32Exception(error));
                    }

                    return;
                }

                Transaction     current     = Transaction.Current;
                IDtcTransaction transaction = null;
                if (current != null && queue.Transactional)
                {
                    transaction = TransactionInterop.GetDtcTransaction(current);
                }

                error = NativeMethods.MQMoveMessage(queue.ReadHandle, queueHandle,
                                                    message.LookupId, transaction);
                if (error != 0)
                {
                    throw new TransportException("Failed to move message to queue: " + fullSubQueueName,
                                                 new Win32Exception(error));
                }
            }
            finally
            {
                error = NativeMethods.MQCloseQueue(queueHandle);
                if (error != 0)
                {
                    throw new TransportException("Failed to close queue: " + fullSubQueueName,
                                                 new Win32Exception(error));
                }
            }
        }
示例#12
0
        internal void Join(OracleInternalConnection internalConnection, Transaction indigoTransaction)
        {
            IDtcTransaction oletxTransaction = System.Data.Common.ADP.GetOletxTransaction(indigoTransaction);
            int             rc = TracedNativeMethods.OraMTSJoinTxn(this, oletxTransaction);

            if (rc != 0)
            {
                OracleException.Check(rc, internalConnection);
            }
        }
示例#13
0
        internal static IDtcTransaction GetOletxTransaction(Transaction transaction)
        {
            IDtcTransaction dtcTransaction = null;

            if (null != transaction)
            {
                dtcTransaction = TransactionInterop.GetDtcTransaction(transaction);
            }
            return(dtcTransaction);
        }
示例#14
0
        public static KtmTransactionHandle CreateKtmTransactionHandle(Transaction managedTransaction)
        {
            IDtcTransaction    dtcTransaction = TransactionInterop.GetDtcTransaction(managedTransaction);
            IKernelTransaction ktmInterface   = (IKernelTransaction)dtcTransaction;

            IntPtr ktmTxHandle;
            int    hr = ktmInterface.GetHandle(out ktmTxHandle);

            HandleError(hr);

            return(new KtmTransactionHandle(ktmTxHandle));
        }
        public static uint GetTimeoutFromTransaction(Transaction transaction)
        {
            // For transactions created inside this process, we can ask ITransactionOptions
            IDtcTransaction     dtcTransaction     = TransactionInterop.GetDtcTransaction(transaction);
            ITransactionOptions transactionOptions = (ITransactionOptions)dtcTransaction;

            XACTOPT options;

            transactionOptions.GetOptions(out options);

            // For transactions not created inside this process, this will return zero
            return(options.ulTimeout);
        }
示例#16
0
        internal static int OraMTSJoinTxn(OciEnlistContext pCtxt, IDtcTransaction pTrans)
        {
            if (Bid.AdvancedOn)
            {
                Bid.Trace("<oc.OraMTSJoinTxn|ADV|OCI> pCtxt=0x%-07Ix pTrans=...\n", OciEnlistContext.HandleValueToTrace(pCtxt));
            }
            int num = System.Data.Common.UnsafeNativeMethods.OraMTSJoinTxn(pCtxt, pTrans);

            if (Bid.AdvancedOn)
            {
                Bid.Trace("<oc.OraMTSJoinTxn|ADV|OCI|RET> rc=%d\n", num);
            }
            return(num);
        }
        public static void GetTransactionAttributes(Transaction transaction, out uint timeout, out IsolationFlags isoFlags, out string description)
        {
            XACTOPT             xactopt;
            XACTTRANSINFO       xacttransinfo;
            IDtcTransaction     dtcTransaction = TransactionInterop.GetDtcTransaction(transaction);
            ITransactionOptions options        = (ITransactionOptions)dtcTransaction;
            ISaneDtcTransaction transaction3   = (ISaneDtcTransaction)dtcTransaction;

            options.GetOptions(out xactopt);
            timeout     = xactopt.ulTimeout;
            description = xactopt.szDescription;
            transaction3.GetTransactionInfo(out xacttransinfo);
            isoFlags = xacttransinfo.isoFlags;
        }
        private int TryMoveMessageDtcTransacted(long lookupId, MsmqQueueHandle sourceQueueHandle, MsmqQueueHandle destinationQueueHandle, MsmqTransactionMode transactionMode)
        {
            IDtcTransaction nativeTransaction = this.GetNativeTransaction(transactionMode);

            if (nativeTransaction != null)
            {
                try
                {
                    return(UnsafeNativeMethods.MQMoveMessage(sourceQueueHandle, destinationQueueHandle, lookupId, nativeTransaction));
                }
                finally
                {
                    Marshal.ReleaseComObject(nativeTransaction);
                }
            }
            return(UnsafeNativeMethods.MQMoveMessage(sourceQueueHandle, destinationQueueHandle, lookupId, (IntPtr)this.GetTransactionConstant(transactionMode)));
        }
示例#19
0
        public static IDtcTransaction GetDtcTransaction(
            Transaction transaction
            )
        {
            if (!TransactionManager._platformValidated)
            {
                TransactionManager.ValidatePlatform();
            }

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

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

            IDtcTransaction transactionNative = null;

            // First, make sure we are working with an OletxTransaction.
            OletxTransaction oletxTx = TransactionInterop.ConvertToOletxTransaction(transaction);

            try
            {
                oletxTx.realOletxTransaction.TransactionShim.GetITransactionNative(out transactionNative);
            }
            catch (COMException comException)
            {
                OletxTransactionManager.ProxyException(comException);
                throw;
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx),
                                              "TransactionInterop.GetDtcTransaction"
                                              );
            }
            return(transactionNative);
        }
        public static Transaction GetTransactionFromDtcTransaction(IDtcTransaction transactionNative)
        {
            ArgumentNullException.ThrowIfNull(transactionNative);

            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceOleTx, "TransactionInterop.GetTransactionFromDtcTransaction");
            }

            Transaction transaction = OletxTransactionManager.GetTransactionFromDtcTransaction(transactionNative);

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceOleTx, "TransactionInterop.GetTransactionFromDtcTransaction");
            }
            return(transaction);
        }
示例#21
0
        public static Transaction GetTransactionFromDtcTransaction(IDtcTransaction transactionNative)
        {
            if (null == transactionNative)
            {
                throw new ArgumentNullException(nameof(transactionNative));
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtc");
            }

            Transaction transaction = DistributedTransactionManager.GetTransactionFromDtcTransaction(transactionNative);

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtc");
            }
            return(transaction);
        }
        public static IDtcTransaction GetDtcTransaction(Transaction transaction)
        {
            ArgumentNullException.ThrowIfNull(transaction);

            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceOleTx, "TransactionInterop.GetDtcTransaction");
            }

            ConvertToOletxTransaction(transaction);
            IDtcTransaction transactionNative = OletxTransaction.GetDtcTransaction();

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceOleTx, "TransactionInterop.GetDtcTransaction");
            }

            return(transactionNative);
        }
        public static Transaction GetTransactionFromDtcTransaction(IDtcTransaction transactionNative)
        {
            if (null == transactionNative)
            {
                throw new ArgumentNullException(nameof(transactionNative));
            }

            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtcTransaction");
            }

            Transaction transaction = DistributedTransactionManager.GetTransactionFromDtcTransaction(transactionNative);

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtcTransaction");
            }
            return(transaction);
        }
示例#24
0
        public static IDtcTransaction GetDtcTransaction(Transaction transaction)
        {
            if (null == transaction)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetDtcTransaction");
            }

            DistributedTransaction dTx = ConvertToDistributedTransaction(transaction);
            IDtcTransaction        transactionNative = dTx.GetDtcTransaction();

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetDtcTransaction");
            }

            return(transactionNative);
        }
示例#25
0
        internal void Open_EnlistTransaction(Transaction transaction)
        {
            ODBC32.RetCode code;
            if ((this.weakTransaction != null) && this.weakTransaction.IsAlive)
            {
                throw ADP.LocalTransactionPresent();
            }
            IDtcTransaction      oletxTransaction = ADP.GetOletxTransaction(transaction);
            OdbcConnectionHandle connectionHandle = this.ConnectionHandle;

            if (oletxTransaction == null)
            {
                code = connectionHandle.SetConnectionAttribute2(ODBC32.SQL_ATTR.SQL_COPT_SS_ENLIST_IN_DTC, IntPtr.Zero, 1);
            }
            else
            {
                code = connectionHandle.SetConnectionAttribute4(ODBC32.SQL_ATTR.SQL_COPT_SS_ENLIST_IN_DTC, oletxTransaction, 1);
            }
            if (code != ODBC32.RetCode.SUCCESS)
            {
                this.HandleError(connectionHandle, code);
            }
            ((OdbcConnectionOpen)this.InnerConnection).EnlistedTransaction = transaction;
        }
        public static void GetTransactionAttributes(Transaction transaction,
                                                    out uint timeout,
                                                    out IsolationFlags isoFlags,
                                                    out string description)
        {
            IDtcTransaction     dtcTransaction     = TransactionInterop.GetDtcTransaction(transaction);
            ITransactionOptions transactionOptions = (ITransactionOptions)dtcTransaction;
            ISaneDtcTransaction saneTransaction    = (ISaneDtcTransaction)dtcTransaction;

            XACTOPT options;

            transactionOptions.GetOptions(out options);

            // For transactions not created inside this process, this will be zero
            timeout = options.ulTimeout;

            description = options.szDescription;

            XACTTRANSINFO info;

            saneTransaction.GetTransactionInfo(out info);

            isoFlags = info.isoFlags;
        }
        internal void EnlistTransactionInternal(Transaction transaction)
        {
            IntPtr          ptr;
            IDtcTransaction oletxTransaction = ADP.GetOletxTransaction(transaction);

            Bid.ScopeEnter(out ptr, "<oledb.ITransactionJoin.JoinTransaction|API|OLEDB> %d#\n", base.ObjectID);
            try
            {
                using (ITransactionJoinWrapper wrapper = this.ITransactionJoin())
                {
                    if (wrapper.Value == null)
                    {
                        throw ODB.TransactionsNotSupported(this.Provider, null);
                    }
                    wrapper.Value.JoinTransaction(oletxTransaction, -1, 0, IntPtr.Zero);
                    this._unEnlistDuringDeactivate = null != transaction;
                }
            }
            finally
            {
                Bid.ScopeLeave(ref ptr);
            }
            base.EnlistedTransaction = transaction;
        }
        public static IDtcTransaction GetDtcTransaction(Transaction transaction)
        {
            if (null == transaction)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;

            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetDtcTransaction");
            }

            DistributedTransaction dTx = ConvertToDistributedTransaction(transaction);
            IDtcTransaction        transactionNative = dTx.GetDtcTransaction();

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetDtcTransaction");
            }

            return(transactionNative);
        }
示例#29
0
 internal static Transaction GetTransactionFromDtcTransaction(IDtcTransaction transactionNative)
 {
     throw DistributedTransaction.NotSupported();
 }
示例#30
0
 public static extern int MQMoveMessage(IntPtr sourceQueue, IntPtr targetQueue, long lookupID, IDtcTransaction transaction);
 internal ODBC32.RetCode SetConnectionAttribute4(ODBC32.SQL_ATTR attribute, IDtcTransaction transaction, int length)
 {
     ODBC32.RetCode retcode = UnsafeNativeMethods.SQLSetConnectAttrW(this, attribute, transaction, length);
     ODBC.TraceODBC(3, "SQLSetConnectAttrW", retcode);
     return retcode;
 }
 public unsafe static extern int MQReceiveMessageByLookupId(MsmqQueueHandle handle, long lookupId, int action,
     IntPtr properties, NativeOverlapped* nativeOverlapped, IntPtr receiveCallback, IDtcTransaction transaction);
示例#33
0
 internal static Transaction GetTransactionFromDtcTransaction(IDtcTransaction transactionNative)
 {
     throw DistributedTransaction.NotSupported();
 }
 public static Transaction GetTransactionFromDtcTransaction(IDtcTransaction transactionNative)
 {
 }
 public unsafe static extern int MQReceiveMessage(IntPtr handle, int timeout, int action, IntPtr properties,
     NativeOverlapped* nativeOverlapped, IntPtr receiveCallback, IntPtr cursorHandle, IDtcTransaction transaction);
        public static Transaction GetTransactionFromDtcTransaction(
            IDtcTransaction transactionNative
            )
        {
            if ( !TransactionManager._platformValidated ) TransactionManager.ValidatePlatform();

            bool tooLate = false;
            ITransactionShim transactionShim = null;
            Guid txIdentifier = Guid.Empty;
            OletxTransactionIsolationLevel oletxIsoLevel = OletxTransactionIsolationLevel.ISOLATIONLEVEL_SERIALIZABLE;
            OutcomeEnlistment outcomeEnlistment = null;
            RealOletxTransaction realTx = null;
            OletxTransaction oleTx = null;

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

            Transaction transaction = null;

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

            // Let's get the guid of the transaction from the proxy to see if we already
            // have an object.
            ITransactionNativeInternal myTransactionNative = transactionNative as ITransactionNativeInternal;
            if ( null == myTransactionNative )
            {
                throw new ArgumentException( SR.GetString( SR.InvalidArgument ), "transactionNative" );
            }

            OletxXactTransInfo xactInfo;
            try
            {
                myTransactionNative.GetTransactionInfo( out xactInfo );
            }
            catch ( COMException ex )
            {
                if ( Oletx.NativeMethods.XACT_E_NOTRANSACTION != ex.ErrorCode )
                {
                    throw;
                }

                // If we get here, the transaction has appraently already been committed or aborted.  Allow creation of the
                // OletxTransaction, but it will be marked with a status of InDoubt and attempts to get its Identifier
                // property will result in a TransactionException.
                tooLate = true;
                xactInfo.uow = Guid.Empty;

            }

            OletxTransactionManager oletxTm = TransactionManager.DistributedTransactionManager;
            if ( ! tooLate )
            {
                // First check to see if there is a promoted LTM transaction with the same ID.  If there
                // is, just return that.
                transaction = TransactionManager.FindPromotedTransaction( xactInfo.uow );
                if ( null != transaction )
                {
                    if ( DiagnosticTrace.Verbose )
                    {
                        MethodExitedTraceRecord.Trace( SR.GetString( SR.TraceSourceOletx ),
                            "TransactionInterop.GetTransactionFromDtcTransaction"
                            );
                    }
                    return transaction;
                }

                // We need to create a new RealOletxTransaction...
                oletxTm.dtcTransactionManagerLock.AcquireReaderLock( -1 );
                try
                {
                    outcomeEnlistment = new OutcomeEnlistment();
                    IntPtr outcomeEnlistmentHandle = IntPtr.Zero;
                    RuntimeHelpers.PrepareConstrainedRegions();
                    try
                    {
                        outcomeEnlistmentHandle = HandleTable.AllocHandle( outcomeEnlistment );
                        oletxTm.DtcTransactionManager.ProxyShimFactory.CreateTransactionShim(
                            transactionNative,
                            outcomeEnlistmentHandle,
                            out txIdentifier,
                            out oletxIsoLevel,
                            out transactionShim );
                    }
                    finally
                    {
                        if ( transactionShim == null && outcomeEnlistmentHandle != IntPtr.Zero )
                        {
                            HandleTable.FreeHandle( outcomeEnlistmentHandle );
                        }
                    }
                }
                catch ( COMException comException )
                {
                    OletxTransactionManager.ProxyException( comException );
                    throw;
                }
                finally
                {
                    oletxTm.dtcTransactionManagerLock.ReleaseReaderLock();
                }

                // We need to create a new RealOletxTransaction.
                realTx = new RealOletxTransaction(
                    oletxTm,
                    transactionShim,
                    outcomeEnlistment,
                    txIdentifier,
                    oletxIsoLevel,
                    false );

                oleTx = new OletxTransaction( realTx );

                // If a transaction is found then FindOrCreate will Dispose the oletx
                // created.
                transaction = TransactionManager.FindOrCreatePromotedTransaction( xactInfo.uow, oleTx );
            }
            else
            {
                // It was too late to do a clone of the provided ITransactionNative, so we are just going to
                // create a RealOletxTransaction without a transaction shim or outcome enlistment.
                realTx = new RealOletxTransaction(
                    oletxTm,
                    null,
                    null,
                    txIdentifier,
                    OletxTransactionIsolationLevel.ISOLATIONLEVEL_SERIALIZABLE,
                    false );

                oleTx = new OletxTransaction( realTx );
                transaction = new Transaction( oleTx );
                TransactionManager.FireDistributedTransactionStarted( transaction );
                oleTx.savedLtmPromotedTransaction = transaction;

                InternalTransaction.DistributedTransactionOutcome(transaction.internalTransaction, TransactionStatus.InDoubt);
            }


            if ( DiagnosticTrace.Verbose )
            {
                MethodExitedTraceRecord.Trace( SR.GetString( SR.TraceSourceOletx ),
                    "TransactionInterop.GetTransactionFromDtc"
                    );
            }
            return transaction;
        }
 public static extern int MQMoveMessage(MsmqQueueHandle sourceQueueHandle,
                                        MsmqQueueHandle destinationQueueHandle,
                                        long lookupId,
                                        IDtcTransaction transaction);
 internal static int OraMTSJoinTxn(OciEnlistContext pCtxt, IDtcTransaction pTrans)
 {
     if (Bid.AdvancedOn)
     {
         Bid.Trace("<oc.OraMTSJoinTxn|ADV|OCI> pCtxt=0x%-07Ix pTrans=...\n", OciEnlistContext.HandleValueToTrace(pCtxt));
     }
     int num = System.Data.Common.UnsafeNativeMethods.OraMTSJoinTxn(pCtxt, pTrans);
     if (Bid.AdvancedOn)
     {
         Bid.Trace("<oc.OraMTSJoinTxn|ADV|OCI|RET> rc=%d\n", num);
     }
     return num;
 }
示例#39
0
		public static Transaction GetTransactionFromDtcTransaction (
			IDtcTransaction dtc)
		{
			throw new NotImplementedException ();
		}
示例#40
0
 public static extern int MQMoveMessage(IntPtr sourceQueue, IntPtr targetQueue, long lookupID, IDtcTransaction transaction);
 internal static extern int OraMTSJoinTxn(OciEnlistContext pCtxt, IDtcTransaction pTrans);
 public static Transaction GetTransactionFromDtcTransaction(IDtcTransaction transactionNative)
 {
     OletxXactTransInfo info;
     if (!TransactionManager._platformValidated)
     {
         TransactionManager.ValidatePlatform();
     }
     bool flag = false;
     ITransactionShim transactionShim = null;
     Guid empty = Guid.Empty;
     OletxTransactionIsolationLevel isolationLevel = OletxTransactionIsolationLevel.ISOLATIONLEVEL_SERIALIZABLE;
     OutcomeEnlistment target = null;
     RealOletxTransaction realOletxTransaction = null;
     OletxTransaction oletx = null;
     if (transactionNative == null)
     {
         throw new ArgumentNullException("transactionNative");
     }
     Transaction transaction = null;
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "TransactionInterop.GetTransactionFromDtc");
     }
     ITransactionNativeInternal internal2 = transactionNative as ITransactionNativeInternal;
     if (internal2 == null)
     {
         throw new ArgumentException(System.Transactions.SR.GetString("InvalidArgument"), "transactionNative");
     }
     try
     {
         internal2.GetTransactionInfo(out info);
     }
     catch (COMException exception2)
     {
         if (System.Transactions.Oletx.NativeMethods.XACT_E_NOTRANSACTION != exception2.ErrorCode)
         {
             throw;
         }
         flag = true;
         info.uow = Guid.Empty;
     }
     OletxTransactionManager distributedTransactionManager = TransactionManager.DistributedTransactionManager;
     if (!flag)
     {
         transaction = TransactionManager.FindPromotedTransaction(info.uow);
         if (null != transaction)
         {
             if (DiagnosticTrace.Verbose)
             {
                 MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "TransactionInterop.GetTransactionFromDtcTransaction");
             }
             return transaction;
         }
         distributedTransactionManager.dtcTransactionManagerLock.AcquireReaderLock(-1);
         try
         {
             target = new OutcomeEnlistment();
             IntPtr zero = IntPtr.Zero;
             RuntimeHelpers.PrepareConstrainedRegions();
             try
             {
                 zero = HandleTable.AllocHandle(target);
                 distributedTransactionManager.DtcTransactionManager.ProxyShimFactory.CreateTransactionShim(transactionNative, zero, out empty, out isolationLevel, out transactionShim);
             }
             finally
             {
                 if ((transactionShim == null) && (zero != IntPtr.Zero))
                 {
                     HandleTable.FreeHandle(zero);
                 }
             }
         }
         catch (COMException exception)
         {
             OletxTransactionManager.ProxyException(exception);
             throw;
         }
         finally
         {
             distributedTransactionManager.dtcTransactionManagerLock.ReleaseReaderLock();
         }
         realOletxTransaction = new RealOletxTransaction(distributedTransactionManager, transactionShim, target, empty, isolationLevel, false);
         oletx = new OletxTransaction(realOletxTransaction);
         transaction = TransactionManager.FindOrCreatePromotedTransaction(info.uow, oletx);
     }
     else
     {
         realOletxTransaction = new RealOletxTransaction(distributedTransactionManager, null, null, empty, OletxTransactionIsolationLevel.ISOLATIONLEVEL_SERIALIZABLE, false);
         oletx = new OletxTransaction(realOletxTransaction);
         transaction = new Transaction(oletx);
         TransactionManager.FireDistributedTransactionStarted(transaction);
         oletx.savedLtmPromotedTransaction = transaction;
         InternalTransaction.DistributedTransactionOutcome(transaction.internalTransaction, TransactionStatus.InDoubt);
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "TransactionInterop.GetTransactionFromDtc");
     }
     return transaction;
 }
示例#43
0
        public static Transaction GetTransactionFromDtcTransaction(IDtcTransaction transactionNative)
        {
            if (null == transactionNative)
            {
                throw new ArgumentNullException(nameof(transactionNative));
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtc");
            }

            Transaction transaction = DistributedTransactionManager.GetTransactionFromDtcTransaction(transactionNative);

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtc");
            }
            return transaction;
        }
 public static extern int MQSendMessage(MsmqQueueHandle handle, IntPtr properties, IDtcTransaction transaction);
示例#45
0
        public static Transaction GetTransactionFromDtcTransaction(IDtcTransaction transactionNative)
        {
            if (null == transactionNative)
            {
                throw new ArgumentNullException(nameof(transactionNative));
            }

            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtcTransaction");
            }

            Transaction transaction = DistributedTransactionManager.GetTransactionFromDtcTransaction(transactionNative);

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromDtcTransaction");
            }
            return transaction;
        }
 internal static extern ODBC32.RetCode SQLSetConnectAttrW(OdbcConnectionHandle ConnectionHandle, ODBC32.SQL_ATTR Attribute, IDtcTransaction Value, int StringLength);