コード例 #1
0
        public ControlOperationInvoker(OperationDescription description, ServiceEndpoint endpoint,
            CorrelationKeyCalculator correlationKeyCalculator, IOperationInvoker innerInvoker, ServiceHostBase host)
        {
            Fx.Assert(host is WorkflowServiceHost, "ControlOperationInvoker must be used with a WorkflowServiceHost");

            this.host = (WorkflowServiceHost)host;
            this.instanceManager = this.host.DurableInstanceManager;
            this.operationName = description.Name;
            this.isOneWay = description.IsOneWay;
            this.endpoint = endpoint;
            this.innerInvoker = innerInvoker;
            this.keyCalculator = correlationKeyCalculator;
            this.persistTimeout = this.host.PersistTimeout;

            if (description.DeclaringContract == WorkflowControlEndpoint.WorkflowControlServiceContract ||
                description.DeclaringContract == WorkflowControlEndpoint.WorkflowControlServiceBaseContract)
            {
                //Mode1: This invoker belongs to IWorkflowInstanceManagement operation.
                this.isControlOperation = true;
                switch (this.operationName)
                {
                    case XD2.WorkflowInstanceManagementService.Cancel:
                    case XD2.WorkflowInstanceManagementService.TransactedCancel:
                    case XD2.WorkflowInstanceManagementService.Run:
                    case XD2.WorkflowInstanceManagementService.TransactedRun:
                    case XD2.WorkflowInstanceManagementService.Unsuspend:
                    case XD2.WorkflowInstanceManagementService.TransactedUnsuspend:
                        this.inputParameterCount = 1;
                        break;
                    case XD2.WorkflowInstanceManagementService.Abandon:
                    case XD2.WorkflowInstanceManagementService.Suspend:
                    case XD2.WorkflowInstanceManagementService.TransactedSuspend:
                    case XD2.WorkflowInstanceManagementService.Terminate:
                    case XD2.WorkflowInstanceManagementService.TransactedTerminate:
                    case XD2.WorkflowInstanceManagementService.Update:
                    case XD2.WorkflowInstanceManagementService.TransactedUpdate:
                        this.inputParameterCount = 2;
                        break;
                    default:
                        throw Fx.AssertAndThrow("Unreachable code");
                }
            }
            else if (endpoint is WorkflowHostingEndpoint)
            {
                this.CanCreateInstance = true;
            }
            else
            {
                this.bufferedReceiveManager = this.host.Extensions.Find<BufferedReceiveManager>();
            }
        }
        public ControlOperationInvoker(OperationDescription description, ServiceEndpoint endpoint, CorrelationKeyCalculator correlationKeyCalculator, IOperationInvoker innerInvoker, ServiceHostBase host)
        {
            this.host = (WorkflowServiceHost) host;
            this.instanceManager = this.host.DurableInstanceManager;
            this.operationName = description.Name;
            this.isOneWay = description.IsOneWay;
            this.endpoint = endpoint;
            this.innerInvoker = innerInvoker;
            this.keyCalculator = correlationKeyCalculator;
            this.persistTimeout = this.host.PersistTimeout;
            if (description.DeclaringContract == WorkflowControlEndpoint.WorkflowControlServiceContract)
            {
                this.isControlOperation = true;
                switch (this.operationName)
                {
                    case "Cancel":
                    case "TransactedCancel":
                    case "Run":
                    case "TransactedRun":
                    case "Unsuspend":
                    case "TransactedUnsuspend":
                        this.inputParameterCount = 1;
                        return;

                    case "Abandon":
                    case "Suspend":
                    case "TransactedSuspend":
                    case "Terminate":
                    case "TransactedTerminate":
                        this.inputParameterCount = 2;
                        return;
                }
                throw Fx.AssertAndThrow("Unreachable code");
            }
            if (endpoint is WorkflowHostingEndpoint)
            {
                this.CanCreateInstance = true;
            }
            else
            {
                this.bufferedReceiveManager = this.host.Extensions.Find<System.ServiceModel.Activities.Dispatcher.BufferedReceiveManager>();
            }
        }
コード例 #3
0
 private void InitializeFromConstructor(WorkflowService serviceDefinition, params Uri[] baseAddresses)
 {
     this.idleTimeToPersist        = WorkflowIdleBehavior.defaultTimeToPersist;
     this.idleTimeToUnload         = WorkflowIdleBehavior.defaultTimeToUnload;
     this.unhandledExceptionAction = WorkflowUnhandledExceptionAction.AbandonAndSuspend;
     this.workflowExtensions       = new WorkflowServiceHostExtensions();
     if (System.ServiceModel.Activities.TD.CreateWorkflowServiceHostStartIsEnabled())
     {
         System.ServiceModel.Activities.TD.CreateWorkflowServiceHostStart();
     }
     if (serviceDefinition != null)
     {
         this.InitializeDescription(serviceDefinition, new UriSchemeKeyedCollection(baseAddresses));
     }
     this.durableInstanceManager = new System.ServiceModel.Activities.Dispatcher.DurableInstanceManager(this);
     if (System.ServiceModel.Activities.TD.CreateWorkflowServiceHostStopIsEnabled())
     {
         System.ServiceModel.Activities.TD.CreateWorkflowServiceHostStop();
     }
 }
コード例 #4
0
 internal DurableInstancingOptions(DurableInstanceManager instanceManager)
 {
     this.instanceManager = instanceManager;
 }
コード例 #5
0
            public CloseAsyncResult(DurableInstanceManager instanceManager, TimeSpan timeout, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.instanceManager = instanceManager;
                this.timeoutHelper = new TimeoutHelper(timeout);
                this.instanceQueueLock = new object();
                this.allReleaseInstancesCompletedSynchronously = true;

                if (this.instanceManager.state == States.Opened && this.instanceManager.handle != null)
                {
                    // Note: since we change state before actual openning, this may 
                    // get NullRef (---- already exists in other places) if Close 
                    // is called on an unsuccessful or incompleted opened DIM.  
                    // Assuming it is a non supported scenario.  
                    this.instanceManager.handle.Free();
                    if (WaitForStoreEventsLoop())
                    {
                        Complete(true);
                    }
                }
                else
                {
                    if (PerformClose())
                    {
                        Complete(true);
                    }
                }
            }
コード例 #6
0
            public OpenInstanceStoreAsyncResult(DurableInstanceManager instanceManager, TimeSpan timeout, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.instanceManager = instanceManager;
                this.timeoutHelper = new TimeoutHelper(timeout);

                lock (this.instanceManager.thisLock)
                {
                    DurableInstanceManager.ThrowIfDisposedOrImmutable(this.instanceManager.state);
                    this.instanceManager.state = States.Opened;
                }

                this.instanceManager.InitializeDefinitionProvider();

                instanceManager.CheckPersistenceProviderBehavior();

                this.instanceManager.SetDefaultOwnerMetadata();

                this.OnCompleting = OpenInstanceStoreAsyncResult.onFinally;

                bool completeSelf;
                Exception completionException = null;
                try
                {
                    if (instanceManager.InstanceStore == null)
                    {
                        completeSelf = CreateDirectory();
                    }
                    else
                    {
                        this.handle = this.instanceManager.InstanceStore.CreateInstanceHandle(null);
                        IAsyncResult executeResult = this.instanceManager.InstanceStore.BeginExecute(this.handle,
                            this.instanceManager.GetCreateOwnerCommand(), this.timeoutHelper.RemainingTime(),
                            this.PrepareAsyncCompletion(OpenInstanceStoreAsyncResult.handleEndExecute), this);
                        completeSelf = SyncContinue(executeResult);
                    }
                }
                catch (Exception exception)
                {
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }

                    completionException = exception;
                    completeSelf = true;
                }
                if (completeSelf)
                {
                    Complete(true, completionException);
                }
            }
コード例 #7
0
 public WaitAndHandleStoreEventsAsyncResult(DurableInstanceManager instanceManager, AsyncCallback callback, object state)
     : base(callback, state)
 {
     this.instanceManager = instanceManager;
     ActionItem.Schedule(waitAndHandleStoreEvents, this);
 }
コード例 #8
0
            GetInstanceAsyncResult(DurableInstanceManager instanceManager, WorkflowGetInstanceContext parameters,
                TimeSpan timeout, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.instanceManager = instanceManager;
                this.parameters = parameters;
                this.timeout = timeout;
                this.loadAny = parameters == null;
                this.OnCompleting = onCompleting;

                Transaction currentTransaction = Transaction.Current;
                if (currentTransaction == null && this.instanceManager.Host.IsLoadTransactionRequired)
                {
                    this.committableTransaction = new CommittableTransaction(this.timeout);
                    currentTransaction = committableTransaction;
                }
                if (currentTransaction != null)
                {
                    this.transaction = currentTransaction.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
                }
            }
コード例 #9
0
            public GetInstanceAsyncResult(DurableInstanceManager instanceManager, Guid instanceId, WorkflowGetInstanceContext parameters, WorkflowIdentityKey updatedIdentity,
                TimeSpan timeout, AsyncCallback callback, object state)
                : this(instanceManager, parameters, timeout, callback, state)
            {
                this.instanceId = instanceId;
                this.updatedIdentity = updatedIdentity;

                if (this.GetInstance())
                {
                    this.Complete(true);
                }
            }
コード例 #10
0
            public GetInstanceAsyncResult(DurableInstanceManager instanceManager, InstanceKey instanceKey, ICollection<InstanceKey> additionalKeys, WorkflowGetInstanceContext parameters,
                TimeSpan timeout, AsyncCallback callback, object state)
                : this(instanceManager, parameters, timeout, callback, state)
            {
                Fx.Assert(instanceKey != null, "Instance key must be set.");

                this.instanceKey = instanceKey;
                this.additionalKeys = additionalKeys;

                if (this.GetInstance())
                {
                    this.Complete(true);
                }
            }
 public OpenInstanceStoreAsyncResult(DurableInstanceManager instanceManager, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     bool flag;
     this.instanceManager = instanceManager;
     this.timeoutHelper = new TimeoutHelper(timeout);
     lock (this.instanceManager.thisLock)
     {
         DurableInstanceManager.ThrowIfDisposedOrImmutable(this.instanceManager.state);
         this.instanceManager.state = 1;
     }
     instanceManager.CheckPersistenceProviderBehavior();
     this.instanceManager.SetDefaultOwnerMetadata();
     base.OnCompleting = onFinally;
     Exception exception = null;
     try
     {
         if (instanceManager.InstanceStore == null)
         {
             flag = this.CreateDirectory();
         }
         else
         {
             this.handle = this.instanceManager.InstanceStore.CreateInstanceHandle((InstanceOwner) null);
             IAsyncResult result = this.instanceManager.InstanceStore.BeginExecute(this.handle, this.instanceManager.createOwnerCommand, this.timeoutHelper.RemainingTime(), base.PrepareAsyncCompletion(handleEndExecute), this);
             flag = base.SyncContinue(result);
         }
     }
     catch (Exception exception2)
     {
         if (Fx.IsFatal(exception2))
         {
             throw;
         }
         exception = exception2;
         flag = true;
     }
     if (flag)
     {
         base.Complete(true, exception);
     }
 }
 public CloseAsyncResult(DurableInstanceManager instanceManager, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.instanceManager = instanceManager;
     this.timeoutHelper = new TimeoutHelper(timeout);
     if ((this.instanceManager.state == 1) && (this.instanceManager.handle != null))
     {
         this.instanceManager.handle.Free();
         if (this.WaitForStoreEventsLoop())
         {
             base.Complete(true);
         }
     }
     else if (this.PerformClose())
     {
         base.Complete(true);
     }
 }