当前位置: 首页>>代码示例>>C#>>正文


C# PreparingEnlistment.ForceRollback方法代码示例

本文整理汇总了C#中System.Transactions.PreparingEnlistment.ForceRollback方法的典型用法代码示例。如果您正苦于以下问题:C# PreparingEnlistment.ForceRollback方法的具体用法?C# PreparingEnlistment.ForceRollback怎么用?C# PreparingEnlistment.ForceRollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Transactions.PreparingEnlistment的用法示例。


在下文中一共展示了PreparingEnlistment.ForceRollback方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
   if (_transaction.IsValid(false) == false)
     preparingEnlistment.ForceRollback();
   else
     preparingEnlistment.Prepared();
 }
开发者ID:AugustoAngeletti,项目名称:blockspaces,代码行数:7,代码来源:SQLiteEnlistment.cs

示例2: 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

示例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)
		{
			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

示例4: 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

示例5: 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

示例6: 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

示例7: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     try
     {
         transaction.Commit();
         preparingEnlistment.Prepared();
     }
     catch (Exception ex)
     {
         preparingEnlistment.ForceRollback(ex);
     }
 }
开发者ID:Particular,项目名称:NServiceBus,代码行数:12,代码来源:InMemoryTransactionalSynchronizedStorageAdapter.cs

示例8: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     try
       {
     _transaction.IsValid();
       }
       catch(Exception e)
       {
     preparingEnlistment.ForceRollback(e);
     return;
       }
       preparingEnlistment.Prepared();
 }
开发者ID:ronnyMakhuddin,项目名称:SharperNLP,代码行数:13,代码来源:SQLiteEnlistment.cs

示例9: 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

示例10: 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
			{
				session.StoreRecoveryInformation(session.ResourceManagerId, PromotableRavenClientEnlistment.GetLocalOrDistributedTransactionId(transaction), 
				                                 preparingEnlistment.RecoveryInformation());
			}
			catch (Exception e)
			{
				logger.ErrorException("Could not prepare distributed transaction", e);
				preparingEnlistment.ForceRollback(e);
				return;
			}
			preparingEnlistment.Prepared();
		}
开发者ID:JPT123,项目名称:ravendb,代码行数:20,代码来源:RavenClientEnlistment.cs

示例11: Prepare

        public void Prepare(PreparingEnlistment preparingEnlistment)
        {
            try
            {
                using (var ts = new TransactionScope(_transaction))
                {
                    _unitOfWork.Commit();

                    ts.Complete();
                }

                preparingEnlistment.Prepared();
            }
            catch (Exception ex)
            {
                preparingEnlistment.ForceRollback(ex);
            }
        }
开发者ID:danielcor,项目名称:NES,代码行数:18,代码来源:EnlistmentNotification.cs

示例12: Prepare

        public void Prepare(PreparingEnlistment preparingEnlistment)
        {
            Log.Info("Prepare notification received");

            //Perform transactional work
            try
            {

                Log.InfoFormat("Trans: Status={0}, LocalId={1}, DistributedId={2}.",
                                Transaction.Current.TransactionInformation.Status,
                                Transaction.Current.TransactionInformation.LocalIdentifier,
                                Transaction.Current.TransactionInformation.DistributedIdentifier);
                //If work finished correctly, reply prepared
                preparingEnlistment.Prepared();
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                // otherwise, do a ForceRollback
                preparingEnlistment.ForceRollback();
                throw;
            }
        }
开发者ID:AlanLiu-AI,项目名称:Buzz,代码行数:23,代码来源:ConcurrentDTCLock.cs

示例13: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     // Abort if this happens before the channel is closed...
     if (this.channel.State != CommunicationState.Closed)
     {
         channel.Fault();
         Exception e = DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqSessionChannelsMustBeClosed)));
         preparingEnlistment.ForceRollback(e);
     }
     else
         preparingEnlistment.Prepared();
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:12,代码来源:MsmqOutputSessionChannel.cs

示例14: Prepare

 public void Prepare(PreparingEnlistment preparingEnlistment)
 {
     if (_unitOfWork.KeepAlive())
     {
         preparingEnlistment.Prepared();
     }
     else
     {
         preparingEnlistment.ForceRollback();
     }
 }
开发者ID:dgmachado,项目名称:CypherNet,代码行数:11,代码来源:CypherClientFactory.cs

示例15: Prepare

        public void Prepare ( PreparingEnlistment preparingEnlistment )
        {
            resource.NumPrepare++;
            if ( resource.IgnorePrepare )
                return;

            if ( resource.FailPrepare ) {
                if (resource.FailWithException)
                    preparingEnlistment.ForceRollback ( new NotSupportedException () );
                else
                    preparingEnlistment.ForceRollback ();
            } else {
                preparingEnlistment.Prepared ();
            }
        }
开发者ID:HarrievG,项目名称:mono,代码行数:15,代码来源:IntResourceManager.cs


注:本文中的System.Transactions.PreparingEnlistment.ForceRollback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。