Beispiel #1
0
        private async Task RegisterRoutesAsync()
        {
            // Registers all the routes that running workflow instances are paused on.

            int skip     = 0;
            int pageSize = 50;

            var workflowTypeDictionary = (await _workflowTypeStore.ListAsync()).ToDictionary(x => x.WorkflowTypeId);

            var workflowTypeRouteEntryQuery =
                from workflowType in workflowTypeDictionary.Values
                from entry in WorkflowTypeRouteEntries.GetWorkflowTypeRoutesEntries(workflowType, _activityLibrary)
                select entry;

            _workflowTypeRouteEntries.AddEntries(workflowTypeRouteEntryQuery);

            while (true)
            {
                // TODO: Clear the session when the feature is available
                // Right now the identity map is keep even after CommitAsync() is invoked
                //using (var session = _store.CreateSession())
                //{
                var query = await _session
                            .QueryIndex <WorkflowBlockingActivitiesIndex>(index =>
                                                                          index.ActivityName == HttpRequestFilterEvent.EventName)
                            .Skip(skip)
                            .Take(pageSize)
                            .ListAsync();

                if (!query.Any())
                {
                    break;
                }

                skip += pageSize;
                var pendingWorkflowIndexes = query.ToList();
                var pendingWorkflowIds     = pendingWorkflowIndexes.Select(x => x.WorkflowId).Distinct().ToArray();
                var pendingWorkflows       = await _session.Query <Workflow, WorkflowIndex>(x => x.WorkflowId.IsIn(pendingWorkflowIds)).ListAsync();

                var workflowRouteEntryQuery =
                    from workflow in pendingWorkflows
                    from entry in WorkflowRouteEntries.GetWorkflowRoutesEntries(workflowTypeDictionary[workflow.WorkflowTypeId], workflow, _activityLibrary)
                    select entry;

                _workflowInstanceRouteEntries.AddEntries(workflowRouteEntryQuery);
                //}
            }
        }
        private async Task RegisterRoutesAsync()
        {
            // Registers all the routes that running workflow instances are paused on.

            var skip     = 0;
            var pageSize = 50;

            var workflowTypeDictionary = (await _workflowTypeStore.ListAsync()).ToDictionary(x => x.WorkflowTypeId);

            var workflowTypeRouteEntryQuery =
                from workflowType in workflowTypeDictionary.Values
                from entry in WorkflowTypeRouteEntries.GetWorkflowTypeRoutesEntries(workflowType, _activityLibrary)
                select entry;

            _workflowTypeRouteEntries.AddEntries(workflowTypeRouteEntryQuery);

            while (true)
            {
                var pendingWorkflows = await _session
                                       .Query <Workflow, WorkflowBlockingActivitiesIndex>(index =>
                                                                                          index.ActivityName == HttpRequestFilterEvent.EventName)
                                       .Skip(skip)
                                       .Take(pageSize)
                                       .ListAsync();

                if (!pendingWorkflows.Any())
                {
                    break;
                }

                var workflowRouteEntryQuery =
                    from workflow in pendingWorkflows
                    from entry in WorkflowRouteEntries.GetWorkflowRoutesEntries(workflowTypeDictionary[workflow.WorkflowTypeId], workflow, _activityLibrary)
                    select entry;

                _workflowInstanceRouteEntries.AddEntries(workflowRouteEntryQuery);

                if (pendingWorkflows.Count() < pageSize)
                {
                    break;
                }

                skip += pageSize;
            }
        }