當前位置: 首頁>>代碼示例>>C#>>正文


C# Transactions.PreparingEnlistment類代碼示例

本文整理匯總了C#中System.Transactions.PreparingEnlistment的典型用法代碼示例。如果您正苦於以下問題:C# PreparingEnlistment類的具體用法?C# PreparingEnlistment怎麽用?C# PreparingEnlistment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PreparingEnlistment類屬於System.Transactions命名空間,在下文中一共展示了PreparingEnlistment類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     try
     {
         log.Debug("Prepare {0}, Messages {1}. Sending the message batch.", TransactionId, Messages.Count);
         if (_onprepare != null) _onprepare(this);
         preparingEnlistment.Prepared();
     }
     catch (Exception ex)
     {
         log.Error("Error preparing transaction {0} ({1} messages): {2}", TransactionId, Messages.Count, ex);
         preparingEnlistment.ForceRollback(ex);
         TransactionOpen = false;
         if (_onrollback != null)
         {
             try
             {
                 _onrollback(this);
             }
             catch (Exception e2)
             {
                 log.Error("Error performing rollback after a failed prepare: {0}", e2);
             }
         }
     }
 }
開發者ID:BrettBailey,項目名稱:nginn-messagebus,代碼行數:26,代碼來源:MessageBatchingRM.cs

示例2: PrepareAsyncResult

 void IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment)
 {
     bool success = false;
     try
     {
         IAsyncResult result = new PrepareAsyncResult(this, TransactionContext.handleEndPrepare, preparingEnlistment);
         if (result.CompletedSynchronously)
         {
             PrepareAsyncResult.End(result);
             preparingEnlistment.Prepared();
         }
         success = true;
     }
     //we need to swollow the TransactionException as it could because another party aborting it
     catch (TransactionException) 
     {
     }
     finally
     {
         if (!success)
         {
             preparingEnlistment.ForceRollback();
         }
     }
 }
開發者ID:iskiselev,項目名稱:JSIL.NetFramework,代碼行數:25,代碼來源:TransactionContext.cs

示例3: Prepare

		/// <summary>
		/// Notifies an enlisted object that a transaction is being prepared for commitment.
		/// </summary>
		/// <param name="preparingEnlistment">A <see cref="T:System.Transactions.PreparingEnlistment"/> object used to send a response to the transaction manager.</param>
		public void Prepare(PreparingEnlistment preparingEnlistment)
		{
			try
			{

				onTxComplete();
				ctx.CreateFile(TransactionRecoveryInformationFileName, stream =>
				{
					var writer = new BinaryWriter(stream);
					writer.Write(session.ResourceManagerId.ToString());
					writer.Write(transaction.LocalIdentifier);
					writer.Write(session.DatabaseName ?? "");
					writer.Write(preparingEnlistment.RecoveryInformation());
				});

				session.PrepareTransaction(transaction.LocalIdentifier); 
			}
			catch (Exception e)
			{
				logger.ErrorException("Could not prepare distributed transaction", e);
			    try
			    {
                    session.Rollback(transaction.LocalIdentifier);
                    DeleteFile();
			    }
			    catch (Exception e2)
			    {
			        logger.ErrorException("Could not roll back transaction after prepare failed", e2);
			    }

				preparingEnlistment.ForceRollback(e);
				return;
			}
			preparingEnlistment.Prepared();
		}
開發者ID:925coder,項目名稱:ravendb,代碼行數:39,代碼來源:RavenClientEnlistment.cs

示例4: Prepare

		/// <summary>
		/// Notifies an enlisted object that a transaction is being prepared for commitment.
		/// </summary>
		/// <param name="preparingEnlistment">A <see cref="T:System.Transactions.PreparingEnlistment"/> object used to send a response to the transaction manager.</param>
		public void Prepare(PreparingEnlistment preparingEnlistment)
		{
			onTxComplete();
			try
			{
				using (var machineStoreForApplication = IsolatedStorageFile.GetMachineStoreForDomain())
				{
					var name = TransactionRecoveryInformationFileName;
					using (var file = machineStoreForApplication.CreateFile(name + ".temp"))
					using(var writer = new BinaryWriter(file))
					{
						writer.Write(session.ResourceManagerId.ToString());
						writer.Write(PromotableRavenClientEnlistment.GetLocalOrDistributedTransactionId(transaction).ToString());
						writer.Write(session.DatabaseName ?? "");
						writer.Write(preparingEnlistment.RecoveryInformation());
						file.Flush(true);
					}
					machineStoreForApplication.MoveFile(name + ".temp", name);
			}
			}
			catch (Exception e)
			{
				logger.ErrorException("Could not prepare distributed transaction", e);
				preparingEnlistment.ForceRollback(e);
				return;
			}
			preparingEnlistment.Prepared();
		}
開發者ID:remcoros,項目名稱:ravendb,代碼行數:32,代碼來源:RavenClientEnlistment.cs

示例5: Prepare

		/// <summary>
		/// Notifies an enlisted object that a transaction is being prepared for commitment.
		/// </summary>
		/// <param name="preparingEnlistment">A <see cref="T:System.Transactions.PreparingEnlistment"/> object used to send a response to the transaction manager.</param>
		public void Prepare(PreparingEnlistment preparingEnlistment)
		{
			onTxComplete();
			session.StoreRecoveryInformation(session.ResourceManagerId, PromotableRavenClientEnlistment.GetLocalOrDistributedTransactionId(transaction), 
				preparingEnlistment.RecoveryInformation());
			preparingEnlistment.Prepared();
		}
開發者ID:nzdunic,項目名稱:ravendb,代碼行數:11,代碼來源:RavenClientEnlistment.cs

示例6: Prepare

        public virtual void Prepare(PreparingEnlistment preparingEnlistment)
        {
            Trace.WriteIf(Tracing.Is.TraceVerbose, string.Empty);
            if (null == preparingEnlistment)
            {
                return;
            }

            try
            {
                Operation.Info = Convert.ToBase64String(preparingEnlistment.RecoveryInformation());
                if (ConfigureOperation() &&
                    Operation.Do())
                {
                    Trace.WriteIf(Tracing.Is.TraceVerbose, "preparingEnlistment.Prepared()");
                    preparingEnlistment.Prepared();
                    return;
                }

                Trace.WriteIf(Tracing.Is.TraceVerbose, "preparingEnlistment.ForceRollback()");
                preparingEnlistment.ForceRollback();
            }
            catch (Exception exception)
            {
                Trace.TraceError("{0}", exception);
                preparingEnlistment.ForceRollback(exception);
            }
        }
開發者ID:KarlDirck,項目名稱:cavity,代碼行數:28,代碼來源:DurableEnlistmentNotification.cs

示例7: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
   if (_transaction.IsValid(false) == false)
     preparingEnlistment.ForceRollback();
   else
     preparingEnlistment.Prepared();
 }
開發者ID:AugustoAngeletti,項目名稱:blockspaces,代碼行數:7,代碼來源:SQLiteEnlistment.cs

示例8: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     lock (_sharedLock)
     {
         if (PrepareCommitAction != null) PrepareCommitAction();
     }
     preparingEnlistment.Done();
 }
開發者ID:PaulStovell,項目名稱:bindable,代碼行數:8,代碼來源:TransactionStep.cs

示例9: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     DeveelDbException error;
     if (!transaction.IsOpen(out error)) {
         preparingEnlistment.ForceRollback(error);
     } else {
         preparingEnlistment.Prepared();
     }
 }
開發者ID:deveel,項目名稱:deveeldb,代碼行數:9,代碼來源:DeveelDbEnlistment.cs

示例10: Prepare

			public void Prepare(PreparingEnlistment preparingEnlistment)
			{
				byte[] recoveryInformation = preparingEnlistment.RecoveryInformation();
				var ravenJObject = new RavenJObject
				{
					{Constants.NotForReplication, true}
				};
				database.PutStatic("transactions/recoveryInformation/" + txId, null, new MemoryStream(recoveryInformation), ravenJObject);
				preparingEnlistment.Prepared();
			}
開發者ID:bstrausser,項目名稱:ravendb,代碼行數:10,代碼來源:PendingTransactionRecovery.cs

示例11: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     _assertNotDisposed();
     _logger.Debug("Preparing enlistment with id: {0}", Id);
     var information = preparingEnlistment.RecoveryInformation();
     _queueStorage.Global(actions =>
     {
         actions.RegisterRecoveryInformation(Id, information);
     });
     preparingEnlistment.Prepared();
     _logger.Debug("Prepared enlistment with id: {0}", Id);
 }
開發者ID:JackGilliam1,項目名稱:LightningQueues,代碼行數:12,代碼來源:TransactionEnlistment.cs

示例12: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     try
     {
         transaction.Commit();
         preparingEnlistment.Prepared();
     }
     catch (Exception ex)
     {
         preparingEnlistment.ForceRollback(ex);
     }
 }
開發者ID:Particular,項目名稱:NServiceBus,代碼行數:12,代碼來源:InMemoryTransactionalSynchronizedStorageAdapter.cs

示例13: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     try
       {
     _transaction.IsValid();
       }
       catch(Exception e)
       {
     preparingEnlistment.ForceRollback(e);
     return;
       }
       preparingEnlistment.Prepared();
 }
開發者ID:ronnyMakhuddin,項目名稱:SharperNLP,代碼行數:13,代碼來源:SQLiteEnlistment.cs

示例14: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     if (commit)
     {
         preparingEnlistment.Prepared();
     }
     else
     {
         preparingEnlistment.ForceRollback();
         // Rollback is not called after 'Rollback' vote
         this.WasRollback = true;
         preparingEnlistment.Done();
     }
 }
開發者ID:CedricDumont,項目名稱:NMemory.Next,代碼行數:14,代碼來源:FakeEnlistmentNotification.cs

示例15: Prepare

        /// <summary>
        /// Notifies an enlisted object that a transaction is being prepared for commitment.
        /// </summary>
        /// <param name="preparingEnlistment">A <see cref="T:System.Transactions.PreparingEnlistment"/> object used to send a response to the transaction manager.</param>
        public void Prepare( PreparingEnlistment preparingEnlistment )
        {
            Status = TxfmStatus.InPrepare;

            // TODO: Write to recovery log.

            foreach( var operation in operations )
            {
                operation.Commit();
            }

            preparingEnlistment.Prepared();

            Status = TxfmStatus.InTransaction;
        }
開發者ID:dbremner,項目名稱:TransactionalFileManager,代碼行數:19,代碼來源:TxfmEnlistment.cs


注:本文中的System.Transactions.PreparingEnlistment類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。