當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。