TransactionManagerProxy.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / InputOutput / TransactionManagerProxy.cs / 1 / TransactionManagerProxy.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

// This file implements a friendly wrapper around TM bridge callbacks and entry-points 

using System; 
using System.Diagnostics; 
using System.ServiceModel;
 
using Microsoft.Transactions.Bridge;

using Microsoft.Transactions.Wsat.Messaging;
using Microsoft.Transactions.Wsat.Protocol; 
using Microsoft.Transactions.Wsat.StateMachines;
 
namespace Microsoft.Transactions.Wsat.InputOutput 
{
    class TransactionManagerSend 
    {
        ProtocolState state;

        TransactionManagerPropagationService propagation; 
        TransactionManagerCoordinatorService coordination;
 
        TransactionManagerCallback createTransactionResponseCallback = new TransactionManagerCallback (TransactionManagerResponse.CreateTransactionResponse); 
        TransactionManagerCallback enlistTransactionResponseCallback = new TransactionManagerCallback (TransactionManagerResponse.EnlistTransactionResponse);
 
        TransactionManagerCallback registerResponseCallback = new TransactionManagerCallback (TransactionManagerResponse.RegisterResponse);
        TransactionManagerCallback subordinateRegisterResponseCallback = new TransactionManagerCallback (TransactionManagerResponse.SubordinateRegisterResponse);
        TransactionManagerCallback completionCommitResponseCallback = new TransactionManagerCallback (TransactionManagerResponse.CompletionCommitResponse);
        TransactionManagerCallback completionRollbackResponseCallback = new TransactionManagerCallback (TransactionManagerResponse.CompletionRollbackResponse); 

        TransactionManagerCallback prePrepareResponseCallback = new TransactionManagerCallback (TransactionManagerResponse.PrePrepareResponse); 
 
        TransactionManagerCallback prepareResponseCallback = new TransactionManagerCallback (TransactionManagerResponse.PrepareResponse);
        TransactionManagerCallback commitResponseCallback = new TransactionManagerCallback (TransactionManagerResponse.CommitResponse); 
        TransactionManagerCallback rollbackResponseCallback = new TransactionManagerCallback (TransactionManagerResponse.RollbackResponse);

        public TransactionManagerSend (ProtocolState state)
        { 
            this.state = state;
 
            this.propagation = state.TransactionManager.PropagationService; 
            this.coordination = state.TransactionManager.CoordinatorService;
        } 

        //
        // Activation
        // 

        public void CreateTransaction (CompletionEnlistment completion, EnlistmentOptions options, MsgCreateTransactionEvent e) 
        { 
            DebugTrace.Trace (TraceLevel.Info, "Sending CreateTransaction to transaction manager");
 
            propagation.CreateTransaction (
                completion.Enlistment, options, this.createTransactionResponseCallback, e);
        }
 
        public void EnlistTransaction (CoordinatorEnlistment coordinator, EnlistmentOptions options, MsgEnlistTransactionEvent e)
        { 
            DebugTrace.Trace (TraceLevel.Info, "Sending CreateSuperiorEnlistment to transaction manager"); 

            propagation.CreateSuperiorEnlistment (coordinator.Enlistment, options, this.enlistTransactionResponseCallback, e); 
        }

        //
        // Registration 
        //
 
        public void Register(ParticipantEnlistment participant, MsgRegisterEvent e) 
        {
            if (DebugTrace.Info) 
            {
                DebugTrace.TxTrace (
                    TraceLevel.Info,
                    participant.EnlistmentId, 
                    "Sending Register for {0} to transaction manager",
                    participant.Enlistment.NotificationMask 
                    ); 
            }
 
            propagation.CreateSubordinateEnlistment (participant.Enlistment, this.registerResponseCallback, e);
        }

        public void Register(ParticipantEnlistment participant, InternalEnlistSubordinateTransactionEvent e) 
        {
            if (DebugTrace.Info) 
            { 
                DebugTrace.TxTrace(
                    TraceLevel.Info, 
                    participant.EnlistmentId,
                    "Sending subordinate Register for {0} to transaction manager",
                    participant.Enlistment.NotificationMask
                    ); 
            }
 
            propagation.CreateSubordinateEnlistment(participant.Enlistment, 
                                                    this.subordinateRegisterResponseCallback,
                                                    e); 
        }

        //
        // Completion 
        //
 
        public void Commit (CompletionEnlistment completion) 
        {
            if (DebugTrace.Info) 
            {
                DebugTrace.TxTrace (
                    TraceLevel.Info,
                    completion.EnlistmentId, 
                    "Sending completion Commit to transaction manager"
                    ); 
            } 

            coordination.Commit (completion.Enlistment, this.completionCommitResponseCallback, completion); 
        }

        public void Rollback (CompletionEnlistment completion)
        { 
            if (DebugTrace.Info)
            { 
                DebugTrace.TxTrace ( 
                    TraceLevel.Info,
                    completion.EnlistmentId, 
                    "Sending completion Rollback to transaction manager"
                    );
            }
 
            coordination.Rollback (completion.Enlistment, this.completionRollbackResponseCallback, completion);
        } 
 
        public void Aborted(CompletionEnlistment completion)
        { 
            if (DebugTrace.Info)
            {
                DebugTrace.TxTrace (
                    TraceLevel.Info, 
                    completion.EnlistmentId,
                    "Replying Aborted to transaction manager" 
                    ); 
            }
 
            completion.DeliverCallback (Status.Aborted);
        }

        // 
        // TwoPhaseCommit
        // 
 
        public void PrePrepare (VolatileCoordinatorEnlistment volatileCoordinator)
        { 
            if (DebugTrace.Info)
            {
                DebugTrace.TxTrace (
                    TraceLevel.Info, 
                    volatileCoordinator.EnlistmentId,
                    "Sending PrePrepare to transaction manager" 
                    ); 
            }
 
            coordination.PrePrepare (volatileCoordinator.Enlistment, this.prePrepareResponseCallback, volatileCoordinator);
        }

        public void Prepare (CoordinatorEnlistment coordinator) 
        {
            if (DebugTrace.Info) 
            { 
                DebugTrace.TxTrace (
                    TraceLevel.Info, 
                    coordinator.EnlistmentId,
                    "Sending Prepare to transaction manager"
                    );
            } 

            coordination.Prepare (coordinator.Enlistment, this.prepareResponseCallback, coordinator); 
        } 

        public void Commit (CoordinatorEnlistment coordinator) 
        {
            if (DebugTrace.Info)
            {
                DebugTrace.TxTrace ( 
                    TraceLevel.Info,
                    coordinator.EnlistmentId, 
                    "Sending Commit to transaction manager" 
                    );
            } 

            coordination.Commit (coordinator.Enlistment, this.commitResponseCallback, coordinator);
        }
 
        public void Rollback (TransactionEnlistment enlistment)
        { 
            if (DebugTrace.Info) 
            {
                DebugTrace.TxTrace ( 
                    TraceLevel.Info,
                    enlistment.EnlistmentId,
                    "Sending Rollback to transaction manager"
                    ); 
            }
 
            coordination.Rollback (enlistment.Enlistment, this.rollbackResponseCallback, enlistment); 
        }
 
        public void Aborted(CoordinatorEnlistment coordinator)
        {
            if (DebugTrace.Info)
            { 
                DebugTrace.TxTrace (
                    TraceLevel.Info, 
                    coordinator.EnlistmentId, 
                    "Replying Aborted to transaction manager"
                    ); 
            }

            coordinator.DeliverCallback (Status.Aborted);
        } 

        public void PrePrepared (ParticipantEnlistment participant) 
        { 
            if (DebugTrace.Info)
            { 
                DebugTrace.TxTrace (
                    TraceLevel.Info,
                    participant.EnlistmentId,
                    "Replying PrePrepared to transaction manager" 
                    );
            } 
 
            participant.DeliverCallback (Status.PrePrepared);
        } 

        public void PrePrepareAborted(ParticipantEnlistment participant)
        {
            if (DebugTrace.Info) 
            {
                DebugTrace.TxTrace ( 
                    TraceLevel.Info, 
                    participant.EnlistmentId,
                    "Replying Aborted to transaction manager" 
                    );
            }

            participant.DeliverCallback (Status.Aborted); 
        }
 
        public void Prepared (ParticipantEnlistment participant) 
        {
            if (DebugTrace.Info) 
            {
                DebugTrace.TxTrace (
                    TraceLevel.Info,
                    participant.EnlistmentId, 
                    "Replying Prepared to transaction manager"
                    ); 
            } 

            participant.DeliverCallback (Status.Prepared); 
        }

        public void ReadOnly (ParticipantEnlistment participant)
        { 
            if (DebugTrace.Info)
            { 
                DebugTrace.TxTrace ( 
                    TraceLevel.Info,
                    participant.EnlistmentId, 
                    "Replying Readonly to transaction manager"
                    );
            }
 
            participant.DeliverCallback (Status.Readonly);
        } 
 
        public void Committed (ParticipantEnlistment participant)
        { 
            if (DebugTrace.Info)
            {
                DebugTrace.TxTrace (
                    TraceLevel.Info, 
                    participant.EnlistmentId,
                    "Replying Committed to transaction manager" 
                    ); 
            }
 
            participant.DeliverCallback (Status.Committed);
        }

        public void Aborted(ParticipantEnlistment participant) 
        {
            if (DebugTrace.Info) 
            { 
                DebugTrace.TxTrace (
                    TraceLevel.Info, 
                    participant.EnlistmentId,
                    "Replying Aborted to transaction manager"
                    );
            } 

            participant.DeliverCallback (Status.Aborted); 
        } 

        public void EnlistPrePrepareResponse (CoordinatorEnlistment coordinator, Status status) 
        {
            if (DebugTrace.Info)
            {
                DebugTrace.TxTrace ( 
                    TraceLevel.Info,
                    coordinator.EnlistmentId, 
                    "Replying {0} to transaction manager's EnlistPrePrepare", 
                    status
                    ); 
            }

            coordinator.DeliverCallback (status);
        } 

        public void ForgetResponse(TransactionEnlistment enlistment, Status status) 
        { 
            if (DebugTrace.Info)
            { 
                DebugTrace.TxTrace(TraceLevel.Info,
                                   enlistment.EnlistmentId,
                                   "Replying {0} to transaction manager's Forget",
                                   status); 
            }
 
            enlistment.DeliverCallback(status); 
        }
 
        public void Rejoined (ParticipantEnlistment participant)
        {
            if (DebugTrace.Info)
            { 
                DebugTrace.TxTrace (
                    TraceLevel.Info, 
                    participant.EnlistmentId, 
                    "Replying Success to transaction manager's Rejoin"
                    ); 
            }

            participant.DeliverCallback (Status.Success);
        } 

        public void Replayed (CoordinatorEnlistment coordinator) 
        { 
            if (DebugTrace.Info)
            { 
                DebugTrace.TxTrace (
                    TraceLevel.Info,
                    coordinator.EnlistmentId,
                    "Replying Success to transaction manager's Replay" 
                    );
            } 
 
            coordinator.DeliverCallback (Status.Success);
        } 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK