Ejemplo n.º 1
0
        public async void Feed(Message message)
        {
            if (message.LeadScoreConditionType == (int)LeadScoreConditionType.WorkflowActivated)
            {
                IEnumerable <Message> messages = await loadWorkflow((short)message.EntityId, message.AccountId);

                client.Complete(message.LockToken);

                foreach (var feedMessage in messages)
                {
                    blockingCollection.Add(feedMessage);
                }
            }
            else if (message.LeadScoreConditionType == (int)LeadScoreConditionType.WorkflowInactive || message.LeadScoreConditionType == (int)LeadScoreConditionType.WorkflowPaused)
            {
                AutomationWorkflow workflow = null;
                bool result = automationWorkflows.TryRemove(message.EntityId, out workflow);
                if (message.ConditionValue != null && message.ConditionValue.Equals("delayed") && message.ConditionValue.Equals("delayed"))
                {
                    workflowService.DeactivateWorkflow(new DeactivateWorkflowRequest()
                    {
                        WorkflowId = message.EntityId
                    });
                }

                if (result && workflow != null)
                {
                    client.Complete(message.LockToken);
                }
            }
            else
            {
                blockingCollection.Add(message);
            }
        }