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


C# Transaction.Rollback方法代码示例

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


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

示例1: TransactedAccept

 private bool TransactedAccept(out Transaction tx)
 {
     tx = null;
     try
     {
         tx = TransactionBehavior.CreateTransaction(this.ChannelDispatcher.TransactionIsolationLevel, this.ChannelDispatcher.TransactionTimeout);
         IChannelBinder channelBinder = null;
         using (TransactionScope scope = new TransactionScope(tx))
         {
             TimeSpan timeout = TimeoutHelper.Min(this.ChannelDispatcher.TransactionTimeout, this.ChannelDispatcher.DefaultCommunicationTimeouts.ReceiveTimeout);
             if (!this.acceptor.TryAccept(TransactionBehavior.NormalizeTimeout(timeout), out channelBinder))
             {
                 return false;
             }
             scope.Complete();
         }
         if (channelBinder != null)
         {
             this.channel = new ListenerChannel(channelBinder);
             this.idleManager = ServiceChannel.SessionIdleManager.CreateIfNeeded(this.channel.Binder, this.channelDispatcher.DefaultCommunicationTimeouts.ReceiveTimeout);
             return true;
         }
         this.AcceptedNull();
         tx = null;
         return false;
     }
     catch (CommunicationException exception)
     {
         if (null != tx)
         {
             try
             {
                 tx.Rollback();
             }
             catch (TransactionException exception2)
             {
                 if (DiagnosticUtility.ShouldTraceInformation)
                 {
                     DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
                 }
             }
         }
         tx = null;
         if (DiagnosticUtility.ShouldTraceInformation)
         {
             DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
         }
         return false;
     }
     catch (TransactionException exception3)
     {
         tx = null;
         if (DiagnosticUtility.ShouldTraceInformation)
         {
             DiagnosticUtility.ExceptionUtility.TraceHandledException(exception3, TraceEventType.Information);
         }
         return false;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:59,代码来源:ListenerHandler.cs

示例2: Complete

 internal static void Complete(Transaction transaction, Exception error)
 {
     try
     {
         if (error == null)
         {
             CommittableTransaction transaction2 = transaction as CommittableTransaction;
             if (transaction2 != null)
             {
                 transaction2.Commit();
             }
             else
             {
                 DependentTransaction transaction3 = transaction as DependentTransaction;
                 if (transaction3 != null)
                 {
                     transaction3.Complete();
                 }
             }
         }
         else
         {
             transaction.Rollback();
         }
     }
     catch (TransactionException exception)
     {
         DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Error);
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(TransactionBehavior.CreateFault(System.ServiceModel.SR.GetString("SFxTransactionAsyncAborted"), "TransactionAborted", true));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:TransactionInstanceContextFacet.cs

示例3: Complete

        // ........................................................................................................
        internal static void Complete(Transaction transaction, Exception error)
        {
            try
            {
                if (error == null)
                {
                    CommittableTransaction commit = (transaction as CommittableTransaction);
                    if (commit != null)
                    {
                        commit.Commit();
                    }
                    else
                    {
                        DependentTransaction complete = (transaction as DependentTransaction);
                        if (complete != null)
                        {
                            complete.Complete();
                        }
                    }
                }
                else
                {
                    transaction.Rollback();
                }

            }
            catch (TransactionException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Error);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(TransactionBehavior.CreateFault(SR.GetString(SR.SFxTransactionAsyncAborted), FaultCodeConstants.Codes.TransactionAborted, true));
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:33,代码来源:TransactionBehavior.cs

示例4: ExecuteXml

		public XmlDocument ExecuteXml(SqlCommand cmd, Transaction ts)
		{
			XmlDocument xd = null;
			XmlReader xr = null;
			try
			{
				if (cmd.Connection.State != ConnectionState.Open)
				{
					cmd.Connection.Open();
				}
				if (ts != null)
				{
					cmd.Connection.EnlistTransaction(ts);
				}
				xr = cmd.ExecuteXmlReader();
			}
			catch (Exception err)
			{
				Exceptions.LogOnly(err);
				if (ts != null)
				{
					ts.Rollback();
				}
			}
			finally
			{
				cmd.Connection.Close();
			}
			xd = new XmlDocument();
			xd.AppendChild(xd.CreateElement("root"));
			//xr.ReadStartElement("row");
			xd.Load(xr);
			xr.Close();
			return xd;
		}
开发者ID:mind0n,项目名称:hive,代码行数:35,代码来源:DbSqlServer.cs

示例5: Execute

		public ExecuteResult Execute(string Sql, DbConnection Connection, Transaction Tst)
		{
			int RowCount;
			if (Connection == null)
			{
				Connection = GetConnection();
			}
			try
			{
				if (Connection.State == ConnectionState.Closed)
				{
					Connection.Open();
				}
				if (Tst != null)
				{
					Connection.EnlistTransaction(Tst);
				}
				DbCommand cm = GetCommand(Sql, Connection);
				RowCount = cm.ExecuteNonQuery();
				return new ExecuteResult(RowCount, null);
			}
			catch (TransactionException err)
			{
				if (Tst != null)
				{
					Tst.Rollback(err);
				}
				Exceptions.LogOnly(err);
				return new ExecuteResult(null, err);
			}
			catch (Exception err)
			{
				if (Tst != null)
				{
					Tst.Rollback(err);
				}
				Exceptions.LogOnly(err);
				return new ExecuteResult(null, err);
			}
			finally
			{
				Connection.Close();
			}
		}
开发者ID:mind0n,项目名称:hive,代码行数:44,代码来源:Db.cs

示例6: ExecuteReader

		public ExecuteResult ExecuteReader(string Sql, DbConnection Connection, Transaction Tst)
		{
			IDataReader rlt;
			if (Connection == null)
			{
				Connection = GetConnection();
			}
			try
			{
				if (Connection.State == ConnectionState.Closed)
				{
					Connection.Open();
				}
				if (Tst != null)
				{
					Connection.EnlistTransaction(Tst);
				}
				DbCommand cm = GetCommand(Sql, Connection);
				rlt = cm.ExecuteReader(CommandBehavior.CloseConnection);
				return new ExecuteResult(rlt, null);
			}
			catch (TransactionException err)
			{
				if (Tst != null)
				{
					Tst.Rollback(err);
				}
				Exceptions.LogOnly(err);
				return new ExecuteResult(null, err);
			}
			catch (Exception err)
			{
				if (Tst != null)
				{
					Tst.Rollback(err);
				}
				Exceptions.LogOnly(err);
				return new ExecuteResult(null, err);
			}
			finally
			{
				Connection.Close();
			}
		}
开发者ID:mind0n,项目名称:hive,代码行数:44,代码来源:Db.cs


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