• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Transactions.Transaction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Transaction类属于System.Transactions命名空间,在下文中一共展示了Transaction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetExportCookie

        public static byte[] GetExportCookie(Transaction transaction, byte[] whereabouts)
        {
            if (null == transaction)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            if (null == whereabouts)
            {
                throw new ArgumentNullException(nameof(whereabouts));
            }

            if (DiagnosticTrace.Verbose)
            {
                MethodEnteredTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetExportCookie");
            }

            // Copy the whereabouts so that it cannot be modified later.
            var whereaboutsCopy = new byte[whereabouts.Length];
            Buffer.BlockCopy(whereabouts, 0, whereaboutsCopy, 0, whereabouts.Length);

            DistributedTransaction dTx = ConvertToDistributedTransaction(transaction);
            byte[] cookie = dTx.GetExportCookie(whereaboutsCopy);

            if (DiagnosticTrace.Verbose)
            {
                MethodExitedTraceRecord.Trace(SR.TraceSourceDistributed, "TransactionInterop.GetExportCookie");
            }

            return cookie;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:31,代码来源:TransactionInterop.cs


示例2: SharedConnectionInfo

        /// <summary>
        /// Instantiate an opened connection enlisted to the Transaction
        /// if promotable is false, the Transaction wraps a local 
        /// transaction inside and can never be promoted
        /// </summary>
        /// <param name="dbResourceAllocator"></param>
        /// <param name="transaction"></param>
        /// <param name="wantPromotable"></param>
        internal SharedConnectionInfo(
            DbResourceAllocator dbResourceAllocator,
            Transaction transaction,
            bool wantPromotable,
            ManualResetEvent handle)
        {
            Debug.Assert((transaction != null), "Null Transaction!");

            if (null == handle)
                throw new ArgumentNullException("handle");

            this.handle = handle;

            if (wantPromotable)
            {
                // Enlist a newly opened connection to this regular Transaction
                this.connection = dbResourceAllocator.OpenNewConnection();
                this.connection.EnlistTransaction(transaction);
            }
            else
            {
                // Make this transaction no longer promotable by attaching our 
                // IPromotableSinglePhaseNotification implementation (LocalTranscaction)
                // and track the DbConnection and DbTransaction associated with the LocalTranscaction
                LocalTransaction localTransaction = new LocalTransaction(dbResourceAllocator, handle);
                transaction.EnlistPromotableSinglePhase(localTransaction);
                this.connection = localTransaction.Connection;
                this.localTransaction = localTransaction.Transaction;
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:38,代码来源:SharedConnectionInfo.cs


示例3: GetDriverInTransaction

 public static Driver GetDriverInTransaction(Transaction transaction)
 {
     lock (driversInUse.SyncRoot)
     {
         return (Driver) driversInUse[transaction.GetHashCode()];
     }
 }
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:7,代码来源:DriverTransactionManager.cs


示例4: Unlock

        //Releases the transaction lock and allows the next pending transaction to quire it.
        public void Unlock()
        {
            Debug.Assert(Locked);

             OwningTransaction = null;

             LinkedListNode<KeyValuePair<Transaction,ManualResetEvent>> node = null;

             lock(this)
             {
            if(m_PendingTransactions.Count > 0)
            {
               node = m_PendingTransactions.First;
               m_PendingTransactions.RemoveFirst();
            }
             }
             if(node != null)
             {
            Transaction transaction = node.Value.Key;
            ManualResetEvent manualEvent = node.Value.Value;
            Lock(transaction);
            lock(manualEvent)//To deal with race condition of the handle closed between the check and the set
            {
               if(manualEvent.SafeWaitHandle.IsClosed == false)
               {
                  manualEvent.Set();
               }
            }
             }
        }
开发者ID:AztecPyramid,项目名称:Labs,代码行数:31,代码来源:TransactionalLock.cs


示例5: Commit

 internal void Commit(Transaction transaction)
 {
     lock (this.mutex)
     {
         this._pendingWorkCollection.Commit(transaction);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:WorkBatch.cs


示例6: RemoveDriverInTransaction

 public static void RemoveDriverInTransaction(Transaction transaction)
 {
     lock (driversInUse.SyncRoot)
     {
         driversInUse.Remove(transaction.GetHashCode());
     }
 }
开发者ID:BGCX261,项目名称:zp-mysql-data-svn-to-git,代码行数:7,代码来源:MySqlPromotableTransaction.cs


示例7: PersistenceDBAccessor

 internal PersistenceDBAccessor(DbResourceAllocator dbResourceAllocator, Transaction transaction, WorkflowCommitWorkBatchService transactionService)
 {
     this.dbResourceAllocator = dbResourceAllocator;
     this.localTransaction = DbResourceAllocator.GetLocalTransaction(transactionService, transaction);
     this.connection = this.dbResourceAllocator.GetEnlistedConnection(transactionService, transaction, out this.needToCloseConnection);
     this.dbRetry = new DbRetry(false);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:PersistenceDBAccessor.cs


示例8: UseConnection

        public DbConnection UseConnection(IConnectionUser user) {
            if (user == null) {
                throw Error.ArgumentNull("user");
            }
            if (this.connection.State == ConnectionState.Closed) {
                this.connection.Open();
                this.autoClose = true;
                this.AddInfoMessageHandler();
                if (System.Transactions.Transaction.Current != null) {
                    System.Transactions.Transaction.Current.TransactionCompleted += this.OnTransactionCompleted;
                }
            }
            if (this.transaction == null && System.Transactions.Transaction.Current != null &&
                        System.Transactions.Transaction.Current != systemTransaction) {
                this.ClearConnection();
                systemTransaction = System.Transactions.Transaction.Current;
                this.connection.EnlistTransaction(System.Transactions.Transaction.Current);
            }

            if (this.users.Count == this.maxUsers) {
                this.BootUser(this.users[0]);
            }
            this.users.Add(user);
            return this.connection;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:25,代码来源:SqlConnectionManager.cs


示例9: StringBuilder

 /// <summary>
 /// Make the transacted changes permanent.
 /// </summary>
 void IEnlistmentNotification.Commit(Enlistment enlistment)
 {
     _value = new StringBuilder(_temporaryValue.ToString());
     _temporaryValue = null;
     _enlistedTransaction = null;
     enlistment.Done();
 }
开发者ID:40a,项目名称:PowerShell,代码行数:10,代码来源:TransactedString.cs


示例10: SqlDelegatedTransaction

        internal SqlDelegatedTransaction(SqlInternalConnection connection, System.Transactions.Transaction tx)
        {
            this._connection = connection;
            this._atomicTransaction = tx;
            this._active = false;
            System.Transactions.IsolationLevel isolationLevel = tx.IsolationLevel;
            switch (isolationLevel)
            {
                case System.Transactions.IsolationLevel.Serializable:
                    this._isolationLevel = System.Data.IsolationLevel.Serializable;
                    return;

                case System.Transactions.IsolationLevel.RepeatableRead:
                    this._isolationLevel = System.Data.IsolationLevel.RepeatableRead;
                    return;

                case System.Transactions.IsolationLevel.ReadCommitted:
                    this._isolationLevel = System.Data.IsolationLevel.ReadCommitted;
                    return;

                case System.Transactions.IsolationLevel.ReadUncommitted:
                    this._isolationLevel = System.Data.IsolationLevel.ReadUncommitted;
                    return;

                case System.Transactions.IsolationLevel.Snapshot:
                    this._isolationLevel = System.Data.IsolationLevel.Snapshot;
                    return;
            }
            throw SQL.UnknownSysTxIsolationLevel(isolationLevel);
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:SqlDelegatedTransaction.cs


示例11: AdoPersistenceResourceAccessor

        /// <summary>
        /// Construct a new <see cref="AdoPersistenceResourceAccessor" /> with the
        /// specified <see cref="IAdoResourceProvider" />, 
        /// <see cref="IPersistenceNameResolver" /> and <see cref="IAdoValueReader" /> 
        /// All work should be performed in the specified <see cref="Transaction" />.
        /// </summary>
        /// <param name="resourceProvider">
        /// An <see cref="IAdoResourceProvider" /> used to provide resources for
        /// accessing the tracking store.
        /// </param>
        /// <param name="nameResolver">
        /// An <see cref="IPersistenceNameResolver" /> that resolves names
        /// of commands and parameters for the relevant tracking store.
        /// </param>
        /// <param name="valueReader">
        /// An <see cref="IAdoValueReader" /> that reads values from
        /// <see cref="IDbCommand" /> and <see cref="IDataReader" /> implementations.
        /// </param>
        /// <param name="transaction">
        /// An <see cref="Transaction" /> in which to perform the work.
        /// </param>
        public AdoPersistenceResourceAccessor(IAdoResourceProvider resourceProvider,
            IPersistenceNameResolver nameResolver, IAdoValueReader valueReader,
            Transaction transaction)
        {
            if (resourceProvider == null)
                throw new ArgumentNullException("resourceProvider");

            if (nameResolver == null)
                throw new ArgumentNullException("nameResolver");

            if (valueReader == null)
                throw new ArgumentNullException("valueReader");

            this.resourceProvider = resourceProvider;
            this.nameResolver = nameResolver;
            this.valueReader = valueReader;

            if (transaction == null)
            {
                this.isConnectionOwner = true;
                this.dbConnection = resourceProvider.CreateConnection();
                this.dbConnection.Open();
            }
            else
                this.dbConnection = resourceProvider.CreateEnlistedConnection(transaction, out this.isConnectionOwner);
        }
开发者ID:JuRogn,项目名称:OA,代码行数:47,代码来源:AdoPersistenceResourceAccessor.cs


示例12: Create

        /// <summary>
        /// Given a provider name locate the necessary 
        /// <see cref="AdoTrackingResourceAccessor" /> in the configuration file.
        /// </summary>
        /// <returns>
        /// An <see cref="AdoTrackingResourceAccessor" />.
        /// </returns>
        public static AdoTrackingResourceAccessor Create(
            IAdoResourceProvider resourceProvider, ITrackingNameResolver nameResolver,
            IAdoValueReader valueReader, Transaction transaction, IStateProvider stateProvider)
        {
            // locate any mappings for the specified provider
            ProviderNameTypeMapping mapping = TrackingAdoProviderSettings.Get()
                    .ResourceAccessors.FindByProviderName(resourceProvider.ProviderName);

            AdoTrackingResourceAccessor resourceAccessor;
            if (mapping != null)
            {
                resourceAccessor =
                    TypeUtilities.CreateInstance<AdoTrackingResourceAccessor>(
                        mapping.Type, new object[]
                            {
                                resourceProvider, nameResolver, valueReader,
                                transaction, stateProvider
                            });
            }
            else
            {
                return new AdoTrackingResourceAccessor(
                    resourceProvider, nameResolver, valueReader,
                    transaction, stateProvider);
            }

            return resourceAccessor;
        }
开发者ID:JuRogn,项目名称:OA,代码行数:35,代码来源:AdoTrackingResourceAccessorFactory.cs


示例13: Enlist

        private void Enlist(Transaction transaction)
        {
            if (transaction == null)
            {
                // no enlistment as we are not in a TransactionScope
                return;
            }

            // try to enlist as a PSPE
            if (!transaction.EnlistPromotableSinglePhase(this))
            {
                // our enlistmente fail so we need to enlist ourselves as durable.

                // we create a transaction directly instead of using BeginTransaction that GraphClient
                // doesn't store it in its stack of scopes.
                 var localTransaction = new Neo4jTransaction(_client);
                localTransaction.ForceKeepAlive();
                _transactionId = localTransaction.Id;
                var resourceManager = GetResourceManager();
                var propagationToken = TransactionInterop.GetTransmitterPropagationToken(transaction);
                var transactionExecutionEnvironment = new TransactionExecutionEnvironment(_client.ExecutionConfiguration)
                {
                    TransactionId =  localTransaction.Id,
                    TransactionBaseEndpoint = _client.TransactionEndpoint
                };
                resourceManager.Enlist(transactionExecutionEnvironment, propagationToken);
                localTransaction.Cancel();
            }

            _enlistedInTransactions.Add(transaction);
        }
开发者ID:albumprinter,项目名称:Neo4jClient,代码行数:31,代码来源:TransactionSinglePhaseNotification.cs


示例14: AddReference

 internal void AddReference(ref MessageRpc rpc, Transaction tx, bool updateCallCount)
 {
     lock (this.mutex)
     {
         if (this.pending == null)
         {
             this.pending = new Dictionary<Transaction, RemoveReferenceRM>();
         }
         if (tx != null)
         {
             RemoveReferenceRM erm;
             if (this.pending == null)
             {
                 this.pending = new Dictionary<Transaction, RemoveReferenceRM>();
             }
             if (!this.pending.TryGetValue(tx, out erm))
             {
                 RemoveReferenceRM erm2 = new RemoveReferenceRM(this.instanceContext, tx, rpc.Operation.Name) {
                     CallCount = 1L
                 };
                 this.pending.Add(tx, erm2);
             }
             else if (updateCallCount)
             {
                 erm.CallCount += 1L;
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:TransactionInstanceContextFacet.cs


示例15: TryLoadRunnableWorkflowAsyncResult

 public TryLoadRunnableWorkflowAsyncResult(InstancePersistenceContext context, InstancePersistenceCommand command, SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, Transaction currentTransaction, TimeSpan timeout, AsyncCallback callback, object state) : base(context, command, store, storeLock, currentTransaction, timeout, callback, state)
 {
     if (base.Store.WorkflowHostType == Guid.Empty)
     {
         throw FxTrace.Exception.AsError(new InstancePersistenceCommandException(command.Name, System.Activities.DurableInstancing.SR.TryLoadRequiresWorkflowType, null));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:TryLoadRunnableWorkflowAsyncResult.cs


示例16: DeveelDbEnlistment

        public DeveelDbEnlistment(DeveelDbConnection connection, Transaction scope)
        {
            transaction = connection.BeginTransaction();

            Scope = scope;
            Scope.EnlistVolatile(this, EnlistmentOptions.None);
        }
开发者ID:deveel,项目名称:deveeldb,代码行数:7,代码来源:DeveelDbEnlistment.cs


示例17: TransmitSucceeded

 public void TransmitSucceeded(Transaction sendTransaction)
 {
     if (sendTransaction == null)
     {
         this.sent = true;
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:SendOperation.cs


示例18: Create

        internal static SafeTransactionHandle Create(Transaction managedTransaction)
        {
            if (managedTransaction == null)
            {
                throw new InvalidOperationException(RegistryProviderStrings.InvalidOperation_NeedTransaction);
            }

            // MSDTC is not available on WinPE machine.
            // CommitableTransaction will use DTC APIs under the covers to get KTM transaction manager interface. 
            // KTM is kernel Transaction Manager to handle file, registry etc and MSDTC provides an integration support 
            // with KTM to handle transaction across kernel resources and MSDTC resources like SQL, MSMQ etc. 
            // We need KTMRM service as well. WinPE doesn’t have these services installed 
            if (Utils.IsWinPEHost() || PsUtils.IsRunningOnProcessorArchitectureARM())
            {
                throw new NotSupportedException(RegistryProviderStrings.NotSupported_KernelTransactions);
            }

            IDtcTransaction dtcTransaction = TransactionInterop.GetDtcTransaction(managedTransaction);
            IKernelTransaction ktmInterface = dtcTransaction as IKernelTransaction;
            if (null == ktmInterface)
            {
                throw new NotSupportedException(RegistryProviderStrings.NotSupported_KernelTransactions);
            }

            IntPtr ktmTxHandle;
            int hr = ktmInterface.GetHandle(out ktmTxHandle);
            HandleError(hr);

            return new SafeTransactionHandle(ktmTxHandle);
        }
开发者ID:40a,项目名称:PowerShell,代码行数:30,代码来源:SafeTransactionHandle.cs


示例19: Commit

 public void Commit(Guid guid)
 {
     try
     {
         if (this.committableTx == null)
         {
             Marshal.ThrowExceptionForHR(-2147418113);
         }
         else if (this.owned)
         {
             if (guid == this.ownerGuid)
             {
                 this.committableTx.Commit();
             }
             else
             {
                 Marshal.ThrowExceptionForHR(-2147418113);
             }
         }
         else
         {
             this.committableTx.Commit();
         }
     }
     catch (TransactionException exception)
     {
         this.MapTxExceptionToHR(exception, true);
     }
     finally
     {
         this.committableTx.Dispose();
         this.committableTx = null;
         this.systemTx = null;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:35,代码来源:TransactionProxy.cs


示例20: GetDtcTransaction

 public static IDtcTransaction GetDtcTransaction(Transaction transaction)
 {
     if (!TransactionManager._platformValidated)
     {
         TransactionManager.ValidatePlatform();
     }
     if (null == transaction)
     {
         throw new ArgumentNullException("transaction");
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodEnteredTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "TransactionInterop.GetDtcTransaction");
     }
     IDtcTransaction transactionNative = null;
     OletxTransaction transaction2 = ConvertToOletxTransaction(transaction);
     try
     {
         transaction2.realOletxTransaction.TransactionShim.GetITransactionNative(out transactionNative);
     }
     catch (COMException exception)
     {
         OletxTransactionManager.ProxyException(exception);
         throw;
     }
     if (DiagnosticTrace.Verbose)
     {
         MethodExitedTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceOletx"), "TransactionInterop.GetDtcTransaction");
     }
     return transactionNative;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:TransactionInterop.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Transactions.TransactionOptions类代码示例发布时间:2022-05-26
下一篇:
C# Transactions.SinglePhaseEnlistment类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap