Exemplo n.º 1
0
            public void DeliverMessage(ExternalDataEventArgs eventArgs, IComparable queueName, object message, object workItem, IPendingWork workHandler)
            {
                WorkflowInstance workflow = this.eds.Runtime.GetWorkflow(eventArgs.InstanceId);

                if (eventArgs.WaitForIdle)
                {
                    workflow.EnqueueItemOnIdle(queueName, message, workHandler, workItem);
                }
                else
                {
                    workflow.EnqueueItem(queueName, message, workHandler, workItem);
                }
            }
Exemplo n.º 2
0
        public void SendMessage(IMethodMessage message)
        {
            // identity
            string identity = WorkflowInvoker.Identity();

            if (!string.IsNullOrEmpty(identity) && message.LogicalCallContext != null)
            {
                // workaround to create an IdentityContextData for LogicalCallContext
                Type   type = Type.GetType("System.Workflow.Activities.IdentityContextData, System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
                object identityContextData = Activator.CreateInstance(type, BindingFlags.CreateInstance | BindingFlags.ExactBinding | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, new object[] { identity }, CultureInfo.CurrentCulture);
                message.LogicalCallContext.SetData("__identitycontext__", identityContextData);
            }

            // contract type
            Type contractType = Type.GetType(message.TypeName);

            if (contractType == null)
            {
                throw new TypeLoadException(message.TypeName);
            }

            // create queue name
            EventQueueName qn = new EventQueueName(contractType, message.MethodName);

            // enqueue item
            if (_bStateMachine)
            {
                if (_localservice.Scheduler != null)
                {
                    _localservice.Scheduler.RunWorkflow(_instance.InstanceId);
                }
                _instance.EnqueueItemOnIdle(qn, message, null, null);
            }
            else
            {
                _instance.EnqueueItem(qn, message, null, null);
            }
            if (_localservice.Scheduler != null)
            {
                _localservice.Scheduler.RunWorkflow(_instance.InstanceId);
            }
        }