Esempio n. 1
0
        public static IServiceCollection AddWorkflowEngineServices <TContext>(
            this IServiceCollection services,
            WorkflowConfiguration workflowConfiguration
            ) where TContext : EngineDbContext
        {
            if (workflowConfiguration == null)
            {
                throw new ArgumentNullException(nameof(workflowConfiguration));
            }

            services.Configure <WorkflowConfiguration>(config =>
            {
                config.Types = workflowConfiguration.Types;
            });

            services.AddTransient <IUserContextService, UserContextService>();
            services.AddSingleton <IWorkflowDefinitionProvider, WorkflowDefinitionProvider>();
            services.AddTransient <IWorkItemService, WorkItemService <TContext> >();
            services.AddTransient <IWorkflowEngine, WorkflowEngine <TContext> >();
            services.AddTransient <IWorkflowService, WorkflowService <TContext> >();
            services.AddTransient <IUserWorkflowMappingService, NoopUserWorkflowMappingService>();
            services.AddTransient <IWorkflowDefinitionViewModelCreator,
                                   ConfigurationWorkflowDefinitionViewModelCreator>();

            // Policies
            services.AddAuthorization(options =>
            {
                options.AddPolicy(
                    Constants.MANAGE_WORKFLOWS_POLICY,
                    policy => policy.RequireRole(Constants.WORKFLOW_ADMIN_ROLE)
                    );
            });

            return(services);
        }
Esempio n. 2
0
        public static IServiceCollection AddWorkflowEngineServices <TContext>(
            this IServiceCollection services,
            WorkflowConfiguration workflowConfiguration,
            ProcessorConfiguration processorConfiguration
            ) where TContext : EngineDbContext
        {
            if (workflowConfiguration == null)
            {
                throw new ArgumentNullException(nameof(workflowConfiguration));
            }

            if (processorConfiguration == null)
            {
                throw new ArgumentNullException(nameof(processorConfiguration));
            }

            services.Configure <WorkflowConfiguration>(config =>
            {
                config.Types = workflowConfiguration.Types;
            });

            services.Configure <ProcessorConfiguration>(config =>
            {
                config.Enabled   = processorConfiguration.Enabled;
                config.Intervall = processorConfiguration.Intervall;
            });

            if (processorConfiguration.Enabled)
            {
                services.AddSingleton <IHostedService, WorkflowProcessor>();
                services.AddSingleton <IJobQueueService, JobQueueService>();
                services.AddTransient <EnqueueWorkItemMessageHandler>();
            }

            services.AddTransient <IUserContextService, UserContextService>();
            services.AddSingleton <IWorkflowDefinitionProvider, WorkflowDefinitionProvider>();
            services.AddTransient <IWorkItemService, WorkItemService <TContext> >();
            services.AddTransient <IWorkflowEngine, WorkflowEngine <TContext> >();
            services.AddTransient <IWorkflowService, WorkflowService>();
            services.AddTransient <IUserWorkflowMappingService, NoopUserWorkflowMappingService>();
            services.AddTransient <IWorkflowDefinitionViewModelCreator,
                                   ConfigurationWorkflowDefinitionViewModelCreator>();

            // MessageBus
            services.AddSingleton <IMessageBus, InMemoryMessageBus>();

            return(services);
        }
Esempio n. 3
0
 public ConfigurationWorkflowDefinitionViewModelCreator(
     IOptions <WorkflowConfiguration> workflows
     )
 {
     _workflowConfiguration = workflows.Value;
 }