public void Begin()
 {
     if (transactionId == null)
     {
         transactionId = session.Connection.CreateLocalTransactionId();
         
         TransactionInfo info = new TransactionInfo();
         info.ConnectionId = session.Connection.ConnectionId;
         info.TransactionId = transactionId;
         info.Type = (int) TransactionType.Begin;
         session.Connection.OneWay(info);
     }
 }
        public void Rollback()
        {
            if (transactionId != null)
            {
                TransactionInfo info = new TransactionInfo();
                info.ConnectionId = session.Connection.ConnectionId;
                info.TransactionId = transactionId;
                info.Type = (int) TransactionType.Rollback;
                
                transactionId = null;
                session.Connection.OneWay(info);
            }
            
            foreach (ISynchronization synchronization in synchronizations)
			{
                synchronization.AfterRollback();
            }
            synchronizations.Clear();
        }
        public void Commit()
        {
            foreach (ISynchronization synchronization in synchronizations)
			{
                synchronization.BeforeCommit();
            }
            
            if (transactionId != null)
            {
                TransactionInfo info = new TransactionInfo();
                info.ConnectionId = session.Connection.ConnectionId;
                info.TransactionId = transactionId;
                info.Type = (int) TransactionType.CommitOnePhase;
                
                transactionId = null;
                session.Connection.OneWay(info);
            }
            
            foreach (ISynchronization synchronization in synchronizations)
			{
                synchronization.AfterCommit();
            }
            synchronizations.Clear();
        }