Пример #1
0
        private async Task <TriggerResult> ProcessItemAsync(WorkItem item)
        {
            _logger.LogTrace("Processing work item", item);

            using (var scope = _serviceScopeFactory.CreateScope())
            {
                IServiceProvider serviceProvider = scope.ServiceProvider;

                _logger.LogTrace($"Aquire instance of IWorkflowEngine.");
                var engine = serviceProvider.GetRequiredService <IWorkflowEngine>();
                var workflowDefinitionProvider
                    = serviceProvider.GetRequiredService <IWorkflowDefinitionProvider>();
                _logger.LogTrace($"WorkflowProcessor task is doing background work.");

                // process list of WorkflowProcessorItem's
                EntityWorkflowDefinitionBase workflowDefinition
                    = (EntityWorkflowDefinitionBase)workflowDefinitionProvider
                      .GetWorkflowDefinition(item.WorkflowType);

                IWorkflow    workflow     = engine.Find(item.EntityId, workflowDefinition.EntityType);
                TriggerParam triggerParam = new TriggerParam(item.TriggerName, workflow);

                return(await engine.TriggerAsync(triggerParam));
            }
        }
Пример #2
0
        private async Task <TriggerResult> ProcessItemAsync(WorkItem item)
        {
            this.logger.LogTrace("Processing work item {WorkItem}", item);

            using (var scope = this.serviceScopeFactory.CreateScope())
            {
                IServiceProvider serviceProvider = scope.ServiceProvider;
                var engine = serviceProvider.GetRequiredService <IWorkflowEngineService>();
                var workflowDefinitionProvider
                    = serviceProvider.GetRequiredService <IWorkflowDefinitionProvider>();

                EntityWorkflowDefinitionBase workflowDefinition
                    = (EntityWorkflowDefinitionBase)workflowDefinitionProvider
                      .GetWorkflowDefinition(item.WorkflowType);

                IWorkflow    workflow     = engine.Find(item.EntityId, workflowDefinition.EntityType);
                TriggerParam triggerParam = new TriggerParam(item.TriggerName, workflow);

                return(await engine.TriggerAsync(triggerParam));
            }
        }