Exemplo n.º 1
0
 public override void EnlistTransaction(Transaction transaction)
 {
     if (transaction != null)
     {
         if (this.driver.CurrentTransaction != null)
         {
             if (this.driver.CurrentTransaction.BaseTransaction != transaction)
             {
                 throw new MySqlException("Already enlisted");
             }
         }
         else
         {
             Driver driverInTransaction = DriverTransactionManager.GetDriverInTransaction(transaction);
             if (driverInTransaction != null)
             {
                 if (driverInTransaction.IsInActiveUse)
                 {
                     throw new NotSupportedException(Resources.MultipleConnectionsInTransactionNotSupported);
                 }
                 string connectionString = driverInTransaction.Settings.GetConnectionString(true);
                 string strB             = this.Settings.GetConnectionString(true);
                 if (string.Compare(connectionString, strB, true) != 0)
                 {
                     throw new NotSupportedException(Resources.MultipleConnectionsInTransactionNotSupported);
                 }
                 this.CloseFully();
                 this.driver = driverInTransaction;
             }
             if (this.driver.CurrentTransaction == null)
             {
                 MySqlPromotableTransaction promotableSinglePhaseNotification = new MySqlPromotableTransaction(this, transaction);
                 if (!transaction.EnlistPromotableSinglePhase(promotableSinglePhaseNotification))
                 {
                     throw new NotSupportedException(Resources.DistributedTxnNotSupported);
                 }
                 this.driver.CurrentTransaction = promotableSinglePhaseNotification;
                 DriverTransactionManager.SetDriverInTransaction(this.driver);
                 this.driver.IsInActiveUse = true;
             }
         }
     }
 }
Exemplo n.º 2
0
		public override void EnlistTransaction(Transaction transaction) {
			if (transaction != null) {
				if (this.driver.CurrentTransaction != null) {
					if (this.driver.CurrentTransaction.BaseTransaction != transaction) {
						throw new MySqlException("Already enlisted");
					}
				} else {
					Driver driverInTransaction = DriverTransactionManager.GetDriverInTransaction(transaction);
					if (driverInTransaction != null) {
						if (driverInTransaction.IsInActiveUse) {
							throw new NotSupportedException(Resources.MultipleConnectionsInTransactionNotSupported);
						}
						string connectionString = driverInTransaction.Settings.GetConnectionString(true);
						string strB = this.Settings.GetConnectionString(true);
						if (string.Compare(connectionString, strB, true) != 0) {
							throw new NotSupportedException(Resources.MultipleConnectionsInTransactionNotSupported);
						}
						this.CloseFully();
						this.driver = driverInTransaction;
					}
					if (this.driver.CurrentTransaction == null) {
						MySqlPromotableTransaction promotableSinglePhaseNotification = new MySqlPromotableTransaction(this, transaction);
						if (!transaction.EnlistPromotableSinglePhase(promotableSinglePhaseNotification)) {
							throw new NotSupportedException(Resources.DistributedTxnNotSupported);
						}
						this.driver.CurrentTransaction = promotableSinglePhaseNotification;
						DriverTransactionManager.SetDriverInTransaction(this.driver);
						this.driver.IsInActiveUse = true;
					}
				}
			}
		}