本文整理汇总了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;
}
}
示例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));
}
}
示例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;
}
示例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();
}
}
示例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();
}
}