public static byte[] GetTransmitterPropagationToken( Transaction transaction ) { if (!TransactionManager._platformValidated) { TransactionManager.ValidatePlatform(); } if (null == transaction) { throw new ArgumentNullException("transaction"); } if (DiagnosticTrace.Verbose) { MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx), "TransactionInterop.GetTransmitterPropagationToken" ); } // First, make sure we are working with an OletxTransaction. OletxTransaction oletxTx = TransactionInterop.ConvertToOletxTransaction(transaction); byte[] token = GetTransmitterPropagationToken(oletxTx); if (DiagnosticTrace.Verbose) { MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx), "TransactionInterop.GetTransmitterPropagationToken" ); } return(token); }
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); }
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 byte[] GetExportCookie( Transaction transaction, byte[] whereabouts ) { if (!TransactionManager._platformValidated) { TransactionManager.ValidatePlatform(); } byte[] cookie = null; if (null == transaction) { throw new ArgumentNullException("transaction"); } if (null == whereabouts) { throw new ArgumentNullException("whereabouts"); } if (DiagnosticTrace.Verbose) { MethodEnteredTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx), "TransactionInterop.GetExportCookie" ); } // Copy the whereabouts so that it cannot be modified later. byte[] whereaboutsCopy = new byte[whereabouts.Length]; Array.Copy(whereabouts, whereaboutsCopy, whereabouts.Length); whereabouts = whereaboutsCopy; int cookieIndex = 0; UInt32 cookieSize = 0; CoTaskMemHandle cookieBuffer = null; // First, make sure we are working with an OletxTransaction. OletxTransaction oletxTx = TransactionInterop.ConvertToOletxTransaction(transaction); try { oletxTx.realOletxTransaction.TransactionShim.Export( Convert.ToUInt32(whereabouts.Length), whereabouts, out cookieIndex, out cookieSize, out cookieBuffer); // allocate and fill in the cookie cookie = new byte[cookieSize]; Marshal.Copy(cookieBuffer.DangerousGetHandle(), cookie, 0, Convert.ToInt32(cookieSize)); } catch (COMException comException) { OletxTransactionManager.ProxyException(comException); // We are unsure of what the exception may mean. It is possible that // we could get E_FAIL when trying to contact a transaction manager that is // being blocked by a fire wall. On the other hand we may get a COMException // based on bad data. The more common situation is that the data is fine // (since it is generated by Microsoft code) and the problem is with // communication. So in this case we default for unknown exceptions to // assume that the problem is with communication. throw TransactionManagerCommunicationException.Create(SR.GetString(SR.TraceSourceOletx), comException); } finally { if (null != cookieBuffer) { cookieBuffer.Close(); } } if (DiagnosticTrace.Verbose) { MethodExitedTraceRecord.Trace(SR.GetString(SR.TraceSourceOletx), "TransactionInterop.GetExportCookie" ); } return(cookie); }
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); }