本文整理汇总了C#中System.Transactions.CommittableTransaction类的典型用法代码示例。如果您正苦于以下问题:C# CommittableTransaction类的具体用法?C# CommittableTransaction怎么用?C# CommittableTransaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommittableTransaction类属于System.Transactions命名空间,在下文中一共展示了CommittableTransaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransactionScope
public TransactionScope(
TransactionScopeOption scopeOption,
TransactionScopeAsyncFlowOption asyncFlowOption
)
{
if ( !TransactionManager._platformValidated ) TransactionManager.ValidatePlatform();
if ( DiagnosticTrace.Verbose )
{
MethodEnteredTraceRecord.Trace( SR.GetString( SR.TraceSourceBase ),
"TransactionScope.ctor( TransactionScopeOption )"
);
}
ValidateAndSetAsyncFlowOption(asyncFlowOption);
if ( NeedToCreateTransaction( scopeOption ) )
{
committableTransaction = new CommittableTransaction();
expectedCurrent = committableTransaction.Clone();
}
if ( DiagnosticTrace.Information )
{
if ( null == expectedCurrent )
{
TransactionScopeCreatedTraceRecord.Trace( SR.GetString( SR.TraceSourceBase ),
TransactionTraceIdentifier.Empty,
TransactionScopeResult.NoTransaction
);
}
else
{
TransactionScopeResult scopeResult;
if ( null == committableTransaction )
{
scopeResult = TransactionScopeResult.UsingExistingCurrent;
}
else
{
scopeResult = TransactionScopeResult.CreatedTransaction;
}
TransactionScopeCreatedTraceRecord.Trace( SR.GetString( SR.TraceSourceBase ),
expectedCurrent.TransactionTraceId,
scopeResult
);
}
}
PushScope();
if ( DiagnosticTrace.Verbose )
{
MethodExitedTraceRecord.Trace( SR.GetString( SR.TraceSourceBase ),
"TransactionScope.ctor( TransactionScopeOption )"
);
}
}
示例2: FatQueueTransaction
public FatQueueTransaction(
IsolationLevel isolationLevel,
TimeSpan? timeout,
Func<IDbConnection> connectionFactory,
TransactionScopeOption transactionScopeOption = TransactionScopeOption.Required,
TransactionScopeAsyncFlowOption transactionScopeAsyncFlowOption = TransactionScopeAsyncFlowOption.Enabled)
{
_connectionFactory = connectionFactory;
var transactionOptions = new TransactionOptions
{
IsolationLevel = isolationLevel,
};
if (timeout != null)
{
transactionOptions.Timeout = timeout.Value;
}
if (System.Transactions.Transaction.Current == null || transactionScopeOption == TransactionScopeOption.RequiresNew)
{
_transaction = new CommittableTransaction(transactionOptions);
_transactionScope = new TransactionScope(_transaction, transactionScopeAsyncFlowOption);
}
}
示例3: TransactionControl
internal TransactionControl(CommittableTransaction transaction)
{
if ( transaction == null )
throw new ArgumentNullException("transaction");
_transaction = transaction;
}
示例4: Cloning_the_interception_context_preserves_contextual_information_but_not_mutable_state
public void Cloning_the_interception_context_preserves_contextual_information_but_not_mutable_state()
{
var objectContext = new ObjectContext();
var dbContext = DbContextMockHelper.CreateDbContext(objectContext);
var interceptionContext = new EnlistTransactionInterceptionContext();
interceptionContext.SuppressExecution();
interceptionContext.Exception = new Exception("Cheez Whiz");
var transaction = new CommittableTransaction();
interceptionContext = interceptionContext
.WithDbContext(dbContext)
.WithObjectContext(objectContext)
.WithTransaction(transaction)
.AsAsync();
Assert.Equal(new[] { objectContext }, interceptionContext.ObjectContexts);
Assert.Equal(new[] { dbContext }, interceptionContext.DbContexts);
Assert.True(interceptionContext.IsAsync);
Assert.Same(transaction, interceptionContext.Transaction);
Assert.Null(interceptionContext.Exception);
Assert.Null(interceptionContext.OriginalException);
Assert.False(interceptionContext.IsExecutionSuppressed);
}
示例5: WorkerRunner
internal WorkerRunner(WorkerCard workerCard, WorkAssignment workAssignment, CommittableTransaction committableTransaction)
{
WorkerCard = workerCard;
WorkAssignment = workAssignment;
CommittableTransaction = committableTransaction;
Command = Command.Run;
quitGracefully = false;
}
示例6: Promote
public byte[] Promote(INpgsqlTransactionCallbacks callbacks)
{
CommittableTransaction tx = new CommittableTransaction();
DurableResourceManager rm = new DurableResourceManager(this, callbacks, tx);
byte[] token = TransactionInterop.GetTransmitterPropagationToken(tx);
_transactions.Add(rm.TxName, tx);
rm.Enlist(tx);
return token;
}
示例7: CommitWorkBatch
protected override void CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback)
{
TraceHelper.Trace();
Transaction transactionToUse;
if (Transaction.Current == null)
{
transactionToUse = new CommittableTransaction();
Tracer.Debug("CommitWorkBatch�ύTransactionScope����Transaction.Current==null");
}
else
{
transactionToUse = Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
Tracer.Debug("CommitWorkBatch�ύTransactionScope����Transaction.Current!=null" );
}
TransactionCreated(transactionToUse);
try
{
using (TransactionScope txScope = new TransactionScope(transactionToUse))
{
commitWorkBatchCallback();
txScope.Complete();
Tracer.Debug("CommitWorkBatch�ύTransactionScope����Complete���......");
}
CommittableTransaction committableTransaction = transactionToUse as CommittableTransaction;
if (committableTransaction != null)
{
committableTransaction.Commit();
Tracer.Debug("CommitWorkBatch�ύcommittableTransaction����Complete���......");
}
DependentTransaction dependentTransaction = transactionToUse as DependentTransaction;
if (dependentTransaction != null)
{
dependentTransaction.Complete();
Tracer.Debug("CommitWorkBatch�ύdependentTransaction����Complete���......");
}
WorkBatchCommitted(transactionToUse);
}
catch (Exception e)
{
transactionToUse.Rollback(e);
WorkBatchRolledback(transactionToUse);
throw;
}
finally
{
if (transactionToUse != null)
transactionToUse.Dispose();
}
}
示例8: TransactionProxy
public TransactionProxy(DtcIsolationLevel isoLevel, int timeout)
{
TransactionOptions options = new TransactionOptions {
Timeout = TimeSpan.FromSeconds((double) timeout),
IsolationLevel = ConvertIsolationLevelFromDtc(isoLevel)
};
this.committableTx = new CommittableTransaction(options);
this.systemTx = this.committableTx.Clone();
this.owned = false;
}
示例9: Promote
public byte[] Promote(ITransactionExecutionEnvironment transactionExecutionEnvironment)
{
var promotedTx = new CommittableTransaction();
var neo4jTransactionHandler = new Neo4jTransationSinglePhaseNotification(transactionExecutionEnvironment);
var token = TransactionInterop.GetTransmitterPropagationToken(promotedTx);
_transactions[transactionExecutionEnvironment.TransactionId] = promotedTx;
neo4jTransactionHandler.Enlist(promotedTx);
return token;
}
示例10: FileTransaction
public FileTransaction(string name, CommittableTransaction inner, uint stackDepth, ITransactionOptions creationOptions,
Action onDispose)
{
Contract.Requires(inner != null);
Contract.Requires(creationOptions != null);
_Inner = new Transaction(inner, stackDepth, creationOptions, onDispose);
_Name = name;
InnerBegin();
}
示例11: Promote
public byte[] Promote()
{
Log.Info("PSPEDBServer.Promote");
this.tx = new CommittableTransaction();
//Debug.Assert(this.internalServerRM == null);
if (this.internalServerRM != null) Log.Error("this.internalServerRM != null");
// the following statement will cause the transaction to be promoted to MSDTC
byte[] txToken = TransactionInterop.GetTransmitterPropagationToken(this.tx);
Enlist(txToken);
return txToken;
}
示例12: Dispose_ITransaction_using_IDisposable_should_run_action
public void Dispose_ITransaction_using_IDisposable_should_run_action()
{
var actionWasCalled = false;
var opt = new DefaultTransactionOptions();
var cmt = new CommittableTransaction();
using (ITransaction tx = new Transaction(cmt, 1, opt, () => actionWasCalled = true))
tx.Complete();
Assert.That(actionWasCalled);
}
示例13: GoAndRollback
public static void GoAndRollback(Action action)
{
var transaction = new CommittableTransaction(new TransactionOptions
{
IsolationLevel = IsolationLevel.ReadCommitted
});
using (var scope = new TransactionScope(transaction))
{
action();
scope.Dispose();
}
}
示例14: InternalTransaction
internal InternalTransaction(TimeSpan timeout, CommittableTransaction committableTransaction)
{
if (!TransactionManager._platformValidated)
{
TransactionManager.ValidatePlatform();
}
this.absoluteTimeout = TransactionManager.TransactionTable.TimeoutTicks(timeout);
TransactionState._TransactionStateActive.EnterState(this);
this.promoteState = TransactionState._TransactionStatePromoted;
this.committableTransaction = committableTransaction;
this.outcomeSource = committableTransaction;
this.transactionHash = TransactionManager.TransactionTable.Add(this);
}
示例15: GetConnection
public SqlConnection GetConnection(CommittableTransaction transaction = null)
{
if (Connection.IsNull())
{
Connection = new SqlConnection(Runtime.Context.GetDefaultConnectionString());
if (transaction.IsInstance())
{
Connection.Open();
Connection.EnlistTransaction(transaction);
}
}
return Connection;
}