Ejemplo n.º 1
0
        void q_QueueItemAvailable(object sender, QueueEventArgs e)
        {
            ActivityExecutionContext aec = sender as ActivityExecutionContext;
            if (aec != null)
            {
                WorkflowQueuingService qs = aec.GetService<WorkflowQueuingService>();

                WorkflowQueue q = qs.GetWorkflowQueue(e.QueueName);
                //get the outparameters from the workflow
                object o = q.Dequeue();
                //delete the queue
                qs.DeleteWorkflowQueue(e.QueueName);
                Dictionary<string,object> outparams = o as Dictionary<string,object>;
                if(outparams!=null)
                {
                    foreach (KeyValuePair<string, object>  item in outparams)
                    {
                        if (this.Parameters.Contains(item.Key))
                        {
                            //modify the value
                            this.Parameters[item.Key].SetValue(WorkflowParameterBinding.ValueProperty, item.Value);
                        }
                       
                    }
                }
                aec.CloseActivity();
            }
        }
Ejemplo n.º 2
0
        private void HandleExternalEvent(Object sender, QueueEventArgs args)
        {
            ThreadMonitor.WriteToConsole(Thread.CurrentThread, "WaitForMessageActivity", "WaitForMessageActivity: Processed External Event");

            object data = this.workflowQueue.Dequeue();

            ActivityExecutionContext context = sender as ActivityExecutionContext;
            context.CloseActivity();
        }
        private void NotifySynchronousSubscribers(IComparable queueName, EventQueueState qState, Object eventInstance)
        {
            QueueEventArgs args = new QueueEventArgs(queueName);

            for (int i = 0; i < qState.SynchronousListeners.Count; ++i)
            {
                if (qState.SynchronousListeners[i].HandlerDelegate != null)
                    qState.SynchronousListeners[i].HandlerDelegate(new WorkflowQueue(this, queueName), args);
                else
                    qState.SynchronousListeners[i].EventListener.OnEvent(new WorkflowQueue(this, queueName), args);
            }
        }
 internal void NotifyAsynchronousSubscribers(IComparable queueName, EventQueueState qState, int numberOfNotification)
 {
     for (int i = 0; i < numberOfNotification; ++i)
     {
         QueueEventArgs args = new QueueEventArgs(queueName);
         lock (SyncRoot)
         {
             foreach (ActivityExecutorDelegateInfo<QueueEventArgs> subscriber in qState.AsynchronousListeners)
             {
                 Activity contextActivity = rootWorkflowExecutor.GetContextActivityForId(subscriber.ContextId);
                 Debug.Assert(contextActivity != null);
                 subscriber.InvokeDelegate(contextActivity, args, false);
                 WorkflowTrace.Runtime.TraceInformation("Queuing Service: Notifying async subscriber on queue:'{0}' activity:{1}", queueName.ToString(), subscriber.ActivityQualifiedName);
             }
         }
     }
 }
 internal void NotifyAsynchronousSubscribers(IComparable queueName, EventQueueState qState, int numberOfNotification)
 {
     for (int i = 0; i < numberOfNotification; i++)
     {
         QueueEventArgs e = new QueueEventArgs(queueName);
         lock (this.SyncRoot)
         {
             foreach (ActivityExecutorDelegateInfo<QueueEventArgs> info in qState.AsynchronousListeners)
             {
                 Activity contextActivityForId = this.rootWorkflowExecutor.GetContextActivityForId(info.ContextId);
                 info.InvokeDelegate(contextActivityForId, e, false);
                 WorkflowTrace.Runtime.TraceInformation("Queuing Service: Notifying async subscriber on queue:'{0}' activity:{1}", new object[] { queueName.ToString(), info.ActivityQualifiedName });
             }
         }
     }
 }
Ejemplo n.º 6
0
		public void OnQueueItemAvailable (Object sender, QueueEventArgs args)
		{
			Console.WriteLine ("OnQueueItemAvailable!");
			//ThreadMonitor.WriteToConsole (Thread.CurrentThread, "WaitForMessageActivity",
			//	"WaitForMessageActivity: Processed External Event");

			object data = this.workflowQueue.Peek ();
			Console.WriteLine ("OnQueueItemAvailable event! {0}", data);

			ActivityExecutionContext context = sender as ActivityExecutionContext;
			//context.CloseActivity ();
		}
Ejemplo n.º 7
0
		public void OnQueueItemArrived (Object sender, QueueEventArgs args)
		{
			object data = this.workflowQueue.Peek ();
			Console.WriteLine ("OnQueueItemArrived!  event {0}", data);
		}
Ejemplo n.º 8
0
        // Handler when a queue item is available
        private void OnQueueItemAvailable(object sender, QueueEventArgs args)
        {
            ActivityExecutionContext context = sender as ActivityExecutionContext;

            WorkflowQueuingService qService = context.GetService<WorkflowQueuingService>() as WorkflowQueuingService;
            IComparable qName = this.Queue;

            // Dequeue the item and remove the handler 
            if (TryDequeueAndComplete(context, qName))
            {
                qService.GetWorkflowQueue(qName).QueueItemAvailable -= this.OnQueueItemAvailable;
            }
        }