Ejemplo n.º 1
0
        public void ClearAmbientTransactionAndServiceEnvironment()
        {
            try
            {
                if (this.resourceManager.IsBatchDirty)
                {
                    this.ServiceProvider.AddResourceManager(this.resourceManager);
                }

                if (this.currentAtomicActivity != null)
                {
                    TransactionalProperties transactionalProperties = (TransactionalProperties)this.currentAtomicActivity.GetValue(WorkflowExecutor.TransactionalPropertiesProperty);
                    Debug.Assert(transactionalProperties != null, "The current atomic activity is missing transactional properties");
                    transactionalProperties.Transaction = null;
                    if (transactionalProperties.TransactionScope != null)
                    {
                        transactionalProperties.TransactionScope.Complete();
                        transactionalProperties.TransactionScope.Dispose();
                        transactionalProperties.TransactionScope = null;
                    }
                }
            }
            finally
            {
                ((IDisposable)this.serviceEnvironment).Dispose();
                this.serviceEnvironment = null;
            }
        }
Ejemplo n.º 2
0
        public void SetAmbientTransactionAndServiceEnvironment(Transaction transaction)
        {
            this.serviceEnvironment = new ServiceEnvironment(this.RootActivity);

            if (transaction != null && this.currentAtomicActivity != null)
            {
                TransactionalProperties transactionalProperties = (TransactionalProperties)this.currentAtomicActivity.GetValue(WorkflowExecutor.TransactionalPropertiesProperty);
                Debug.Assert(transactionalProperties != null, "The current atomic activity is missing transactional properties");
                transactionalProperties.Transaction = transaction;
                transactionalProperties.TransactionScope = new System.Transactions.TransactionScope(transactionalProperties.Transaction, TimeSpan.Zero, EnterpriseServicesInteropOption.Full);
            }
        }