Пример #1
0
 protected override void Execute(NativeActivityContext context)
 {
     //Access to the current transaction in Workflow is through the GetCurrentTransaction method on a RuntimeTransactionHandle
     RuntimeTransactionHandle rth = new RuntimeTransactionHandle();
     rth = context.Properties.Find(rth.ExecutionPropertyName) as RuntimeTransactionHandle;
     Console.WriteLine("    TransactionID: " + rth.GetCurrentTransaction(context).TransactionInformation.LocalIdentifier.ToString());
 }
Пример #2
0
        void IPropertyRegistrationCallback.Register(RegistrationContext context)
        {
            if (!this.isHandleInitialized)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.UnInitializedRuntimeTransactionHandle));
            }
            RuntimeTransactionHandle handle = (RuntimeTransactionHandle)context.FindProperty(typeof(RuntimeTransactionHandle).FullName);

            if ((handle != null) && handle.SuppressTransaction)
            {
                this.isSuppressed = true;
            }
            this.isPropertyRegistered = true;
        }
Пример #3
0
        protected override void Execute(NativeActivityContext context)
        {
            //Access to the current transaction in Workflow is through the runtime transaction handle
            //Because workflow is not guaranteed to always run on the same thread the runtime maintains a clone
            //of the current transaction. The thread on which the workflow is currently executing will be set
            //up so that the transaction may be accessed using Transaction.Current the best practice is to use
            //the runtime's transaction by calling GetCurrentTransaction on the runtime transaction handle.
            RuntimeTransactionHandle rth = new RuntimeTransactionHandle();

            rth = context.Properties.Find(rth.ExecutionPropertyName) as RuntimeTransactionHandle;
            if (rth != null)
            {
                TransactionInformation ti = rth.GetCurrentTransaction(context).TransactionInformation;
                Console.WriteLine("Transaction: {0} is {1}.", ti.DistributedIdentifier.ToString(), ti.Status);
            }
            else
            {
                Console.WriteLine("There is no runtime transaction.");
            }
        }
Пример #4
0
            protected override void Execute(NativeActivityContext context)
            {
                //In workflow access to the current transaction is through the runtime transaction handle
                RuntimeTransactionHandle rth = new RuntimeTransactionHandle();
                Transaction tx = null;
                rth = context.Properties.Find(rth.ExecutionPropertyName) as RuntimeTransactionHandle;

                if (rth != null)
                {
                    tx = rth.GetCurrentTransaction(context);
                }

                if (tx == null)
                {
                    Console.WriteLine("    Workflow - There is no current transaction.");
                }
                else
                {
                    Console.WriteLine("    Workflow - Tx local ID: " + rth.GetCurrentTransaction(context).TransactionInformation.LocalIdentifier);
                }
            }
 internal NativeActivityTransactionContext(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarks, RuntimeTransactionHandle handle)
     : base(instance, executor, bookmarks)
 {
     this.executor = executor;
     this.transactionHandle = handle;
 }
 internal NativeActivityTransactionContext(System.Activities.ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarks, RuntimeTransactionHandle handle) : base(instance, executor, bookmarks)
 {
     this.executor          = executor;
     this.transactionHandle = handle;
 }