Пример #1
0
        protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }

            object[] args = null;
            ActivityExecutionStatus status = InboundActivityHelper.ExecuteForActivity(this, executionContext, this.InterfaceType, this.EventName, out args);

            if (status == ActivityExecutionStatus.Closed)
            {
                RaiseEvent(args);
                UnsubscribeForActivity(executionContext);
                executionContext.CloseActivity();
                return(status);
            }

            // cannot resolve queue name or message not available
            // hence subscribe for message arrival
            if (!this.ActivitySubscribed)
            {
                this.ActivitySubscribed = CorrelationService.Subscribe(executionContext, this, this.InterfaceType, this.EventName, this, this.WorkflowInstanceId);
            }

            return(ActivityExecutionStatus.Executing);
        }
        void IActivityEventListener <QueueEventArgs> .OnEvent(object sender, QueueEventArgs e)
        {
            ActivityExecutionContext    context  = (ActivityExecutionContext)sender;
            HandleExternalEventActivity activity = context.Activity as HandleExternalEventActivity;

            if (activity.ExecutionStatus == ActivityExecutionStatus.Executing)
            {
                object[] args = null;
                if (InboundActivityHelper.ExecuteForActivity(this, context, this.InterfaceType, this.EventName, out args) == ActivityExecutionStatus.Closed)
                {
                    this.RaiseEvent(args);
                    this.UnsubscribeForActivity(context);
                    context.CloseActivity();
                }
            }
        }
Пример #3
0
        private ActivityExecutionStatus ExecuteForActivity(ActivityExecutionContext context, Type interfaceType, string operation)
        {
            WorkflowQueuingService queueSvcs = (WorkflowQueuingService)context.GetService(typeof(WorkflowQueuingService));
            IComparable            queueId   = new EventQueueName(interfaceType, operation);

            if (queueId != null)
            {
                WorkflowQueue queue;
                object        msg = InboundActivityHelper.DequeueMessage(queueId, queueSvcs, this, out queue);
                if (msg != null)
                {
                    this.ProcessMessage(context, msg, interfaceType, operation);
                    return(ActivityExecutionStatus.Closed);
                }
            }
            return(ActivityExecutionStatus.Executing);
        }
Пример #4
0
        private void ProcessMessage(ActivityExecutionContext context, object msg, Type interfaceType, string operation)
        {
            IMethodMessage message = msg as IMethodMessage;

            if (message == null)
            {
                Exception exception = msg as Exception;
                if (exception != null)
                {
                    throw exception;
                }
                throw new ArgumentNullException("msg");
            }
            CorrelationService.InvalidateCorrelationToken(this, interfaceType, operation, message.Args);
            IdentityContextData data = (IdentityContextData)message.LogicalCallContext.GetData("__identitycontext__");

            InboundActivityHelper.ValidateRoles(this, data.Identity);
            this.ProcessParameters(context, message, interfaceType, operation);
            base.RaiseEvent(InputReceivedEvent, this, EventArgs.Empty);
        }
Пример #5
0
        void IActivityEventListener <QueueEventArgs> .OnEvent(object sender, QueueEventArgs e)
        {
            ActivityExecutionContext    context  = (ActivityExecutionContext)sender;
            HandleExternalEventActivity activity = context.Activity as HandleExternalEventActivity;

            // if activity is not scheduled for execution do not dequeue the message
            if (activity.ExecutionStatus != ActivityExecutionStatus.Executing)
            {
                return;
            }

            object[] args = null;
            ActivityExecutionStatus status = InboundActivityHelper.ExecuteForActivity(this, context, this.InterfaceType, this.EventName, out args);

            if (status == ActivityExecutionStatus.Closed)
            {
                RaiseEvent(args);
                UnsubscribeForActivity(context);
                context.CloseActivity();
            }
        }
        protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException("executionContext");
            }
            object[] args = null;
            ActivityExecutionStatus status = InboundActivityHelper.ExecuteForActivity(this, executionContext, this.InterfaceType, this.EventName, out args);

            if (status == ActivityExecutionStatus.Closed)
            {
                this.RaiseEvent(args);
                this.UnsubscribeForActivity(executionContext);
                executionContext.CloseActivity();
                return(status);
            }
            if (!this.ActivitySubscribed)
            {
                this.ActivitySubscribed = CorrelationService.Subscribe(executionContext, this, this.InterfaceType, this.EventName, this, base.WorkflowInstanceId);
            }
            return(ActivityExecutionStatus.Executing);
        }