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


C# Transactions.CommittableTransaction类代码示例

本文整理汇总了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 )"
                    );
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:60,代码来源:TransactionScope.cs

示例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);
            }
        }
开发者ID:mantasaudickas,项目名称:fat-queue,代码行数:25,代码来源:FatQueueTransaction.cs

示例3: TransactionControl

      internal TransactionControl(CommittableTransaction transaction)
      {
         if ( transaction == null )
            throw new ArgumentNullException("transaction");

         _transaction = transaction;
      }
开发者ID:kakkerlakgly,项目名称:pipelinetesting,代码行数:7,代码来源:PipelineContext.cs

示例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);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:25,代码来源:EnlistTransactionInterceptionContextTests.cs

示例5: WorkerRunner

 internal WorkerRunner(WorkerCard workerCard, WorkAssignment workAssignment, CommittableTransaction committableTransaction)
 {
     WorkerCard = workerCard;
     WorkAssignment = workAssignment;
     CommittableTransaction = committableTransaction;
     Command = Command.Run;
     quitGracefully = false;
 }
开发者ID:Rajeshbharathi,项目名称:CGN.Paralegal,代码行数:8,代码来源:WorkerRunner.cs

示例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;
 }
开发者ID:ArsenShnurkov,项目名称:npgsql,代码行数:9,代码来源:NpgsqlResourceManager.cs

示例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();
            }
        }
开发者ID:SaintLoong,项目名称:TMFlow,代码行数:57,代码来源:GenericWorkBatchService.cs

示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:TransactionProxy.cs

示例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;
        }
开发者ID:Readify,项目名称:Neo4jClient,代码行数:10,代码来源:Neo4jTransactionResourceManager.cs

示例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();
		}
开发者ID:bittercoder,项目名称:Windsor,代码行数:11,代码来源:FileTransaction.cs

示例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;
 }
开发者ID:AlanLiu-AI,项目名称:Buzz,代码行数:11,代码来源:Server.cs

示例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);
		}
开发者ID:bittercoder,项目名称:Windsor,代码行数:12,代码来源:CorrectDisposalOfTransaction_Specs.cs

示例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();
     }
 }
开发者ID:sunloving,项目名称:rooms-and-furniture,代码行数:12,代码来源:TransactionForTests.cs

示例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);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:InternalTransaction.cs

示例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;
 }
开发者ID:JonasSyrstad,项目名称:Stardust,代码行数:13,代码来源:TransactedSqlConnection.cs


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