Esempio n. 1
0
 public static ElsaOptionsBuilder UseYesSqlPersistence(this ElsaOptionsBuilder elsa, Action <IConfiguration> configure) => elsa.UseYesSqlPersistence((_, config) => configure(config));
 private static ElsaOptionsBuilder AddEmailActivitiesInternal(this ElsaOptionsBuilder services) => services.AddActivity <SendEmail>();
 public static ElsaOptionsBuilder AddRpaWebActivities(this ElsaOptionsBuilder options, Action <RpaWebOptions>?configureOptions = null)
 {
     options.Services.AddRpaWebServices(configureOptions);
     options.AddRpaWebActivitiesInternal();
     return(options);
 }
Esempio n. 4
0
 public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration)
 {
     elsa.UseHangfireDispatchers();
 }
Esempio n. 5
0
 public virtual void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration)
 {
 }
Esempio n. 6
0
 public static ElsaOptionsBuilder UseMongoDbPersistence <TDbContext>(this ElsaOptionsBuilder elsa, IConfiguration configuration) where TDbContext : ElsaMongoDbContext
 {
     AddCore <TDbContext>(elsa);
     elsa.Services.Configure <ElsaMongoDbOptions>(configuration);
     return(elsa);
 }
 public static ElsaOptionsBuilder UseAzureServiceBus(this ElsaOptionsBuilder elsaOptions, string connectionString) =>
 elsaOptions.UseServiceBus(context => ConfigureAzureServiceBusEndpoint(context, connectionString, default, default));
Esempio n. 8
0
 public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration)
 {
     elsa.AddJavaScriptActivities();
 }
 public static bool HasService <T>(this ElsaOptionsBuilder options) => options.Services.HasService <T>();
 /// <summary>
 /// Configures Elsa to use Entity Framework Core for persistence, using pooled DB Context instances.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Pooled DB Context instances is a performance optimisation which is documented in more detail at
 /// https://docs.microsoft.com/en-us/ef/core/performance/advanced-performance-topics?tabs=with-constant#dbcontext-pooling.
 /// </para>
 /// </remarks>
 /// <param name="elsa">An Elsa options builder</param>
 /// <param name="configure">A configuration builder callback, which also provides access to a service provider</param>
 /// <param name="autoRunMigrations">If <c>true</c> then database migrations will be auto-executed on startup</param>
 /// <returns>The Elsa options builder, so calls may be chained</returns>
 public static ElsaOptionsBuilder UseEntityFrameworkPersistence(this ElsaOptionsBuilder elsa,
                                                                Action <IServiceProvider, DbContextOptionsBuilder> configure,
                                                                bool autoRunMigrations = true) =>
 elsa.UseEntityFrameworkPersistence <ElsaContext>(configure, autoRunMigrations);
 /// <summary>
 /// Configures Elsa to use Entity Framework Core for persistence, using pooled DB Context instances.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Pooled DB Context instances is a performance optimisation which is documented in more detail at
 /// https://docs.microsoft.com/en-us/ef/core/performance/advanced-performance-topics?tabs=with-constant#dbcontext-pooling.
 /// </para>
 /// </remarks>
 /// <param name="elsa">An Elsa options builder</param>
 /// <param name="configure">A configuration builder callback, which also provides access to a service provider</param>
 /// <param name="autoRunMigrations">If <c>true</c> then database migrations will be auto-executed on startup</param>
 /// <typeparam name="TElsaContext">The concrete type of <see cref="ElsaContext"/> to use.</typeparam>
 /// <returns>The Elsa options builder, so calls may be chained</returns>
 public static ElsaOptionsBuilder UseEntityFrameworkPersistence <TElsaContext>(this ElsaOptionsBuilder elsa,
                                                                               Action <IServiceProvider, DbContextOptionsBuilder> configure,
                                                                               bool autoRunMigrations = true) where TElsaContext : ElsaContext =>
 UseEntityFrameworkPersistence <TElsaContext>(elsa, configure, autoRunMigrations, true, ServiceLifetime.Singleton);
 /// <summary>
 /// Configures Elsa to use Entity Framework Core for persistence, using pooled DB Context instances.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Pooled DB Context instances is a performance optimisation which is documented in more detail at
 /// https://docs.microsoft.com/en-us/ef/core/performance/advanced-performance-topics?tabs=with-constant#dbcontext-pooling.
 /// </para>
 /// </remarks>
 /// <param name="elsa">An Elsa options builder</param>
 /// <param name="configure">A configuration builder callback</param>
 /// <param name="autoRunMigrations">If <c>true</c> then database migrations will be auto-executed on startup</param>
 /// <typeparam name="TElsaContext">The concrete type of <see cref="ElsaContext"/> to use.</typeparam>
 /// <returns>The Elsa options builder, so calls may be chained</returns>
 public static ElsaOptionsBuilder UseEntityFrameworkPersistence <TElsaContext>(this ElsaOptionsBuilder elsa,
                                                                               Action <DbContextOptionsBuilder> configure,
                                                                               bool autoRunMigrations = true) where TElsaContext : ElsaContext =>
 elsa.UseEntityFrameworkPersistence <TElsaContext>((_, builder) => configure(builder), autoRunMigrations);
 /// <summary>
 /// Configures Elsa to use Entity Framework Core for persistence, without using pooled DB Context instances.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Use this method when you do not wish to use DB connection pooling, such as when integrating with a multi-tenant
 /// application, where re-use of DB Context objects is impractical.
 /// </para>
 /// <para>
 /// Although auto-running of migrations is supported in this scenario, use this with caution. When pooling is not in use and each instance of
 /// the DB Context may differ, it is not feasible to try to automatically migrate them.
 /// Your application is ultimately responsible for executing the contents of the <see cref="RunMigrations"/> class in a manner
 /// which is suitable for your use-case.
 /// </para>
 /// </remarks>
 /// <param name="elsa">An Elsa options builder</param>
 /// <param name="configure">A configuration builder callback, which also provides access to a service provider</param>
 /// <param name="serviceLifetime">The service lifetime which will be used for each DB Context instance</param>
 /// <param name="autoRunMigrations">If <c>true</c> then database migrations will be auto-executed on startup</param>
 /// <returns>The Elsa options builder, so calls may be chained</returns>
 public static ElsaOptionsBuilder UseNonPooledEntityFrameworkPersistence(this ElsaOptionsBuilder elsa,
                                                                         Action <IServiceProvider, DbContextOptionsBuilder> configure,
                                                                         ServiceLifetime serviceLifetime = ServiceLifetime.Singleton,
                                                                         bool autoRunMigrations          = false) =>
 elsa.UseNonPooledEntityFrameworkPersistence <ElsaContext>(configure, serviceLifetime, autoRunMigrations);
 /// <summary>
 /// Configures Elsa to use Entity Framework Core for persistence, without using pooled DB Context instances.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Use this method when you do not wish to use DB connection pooling, such as when integrating with a multi-tenant
 /// application, where re-use of DB Context objects is impractical.
 /// </para>
 /// <para>
 /// Although auto-running of migrations is supported in this scenario, use this with caution. When pooling is not in use and each instance of
 /// the DB Context may differ, it is not feasible to try to automatically migrate them.
 /// Your application is ultimately responsible for executing the contents of the <see cref="RunMigrations"/> class in a manner
 /// which is suitable for your use-case.
 /// </para>
 /// </remarks>
 /// <param name="elsa">An Elsa options builder</param>
 /// <param name="configure">A configuration builder callback</param>
 /// <param name="serviceLifetime">The service lifetime which will be used for each DB Context instance</param>
 /// <param name="autoRunMigrations">If <c>true</c> then database migrations will be auto-executed on startup</param>
 /// <typeparam name="TElsaContext">The concrete type of <see cref="ElsaContext"/> to use.</typeparam>
 /// <returns>The Elsa options builder, so calls may be chained</returns>
 public static ElsaOptionsBuilder UseNonPooledEntityFrameworkPersistence <TElsaContext>(this ElsaOptionsBuilder elsa,
                                                                                        Action <DbContextOptionsBuilder> configure,
                                                                                        ServiceLifetime serviceLifetime = ServiceLifetime.Singleton,
                                                                                        bool autoRunMigrations          = false) where TElsaContext : ElsaContext =>
 elsa.UseNonPooledEntityFrameworkPersistence <TElsaContext>((_, builder) => configure(builder), serviceLifetime, autoRunMigrations);
Esempio n. 15
0
 public static ElsaOptionsBuilder UseMongoDbPersistence(this ElsaOptionsBuilder elsa, Action <ElsaMongoDbOptions> configureOptions) => UseMongoDbPersistence <ElsaMongoDbContext>(elsa, configureOptions);
 public static ElsaOptionsBuilder UseHangfireDispatchers(this ElsaOptionsBuilder elsaOptions)
 {
     return(elsaOptions.UseDispatcher <HangfireWorkflowDispatcher>());
 }
Esempio n. 17
0
 public static ElsaOptionsBuilder UseMongoDbPersistence(this ElsaOptionsBuilder elsa, IConfiguration configuration) => UseMongoDbPersistence <ElsaMongoDbContext>(elsa, configuration);
    public static ElsaOptionsBuilder AddAbpActivities(this ElsaOptionsBuilder builder)
    {
        builder.AddActivity <AbpEventHandler>();

        return(builder);
    }
Esempio n. 19
0
 public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration)
 {
     elsa.AddEmailActivities(options => configuration.GetSection("Elsa:Smtp").Bind(options));
 }
Esempio n. 20
0
 /// <summary>
 /// Starts the specified workflow upon application startup.
 /// </summary>
 public static IServiceCollection StartWorkflow <T>(this ElsaOptionsBuilder elsaOptions) where T : class, IWorkflow
 {
     elsaOptions.AddWorkflow <T>();
     return(elsaOptions.Services.AddHostedService <StartWorkflow <T> >());
 }
Esempio n. 21
0
 private static ElsaOptionsBuilder AddHttpActivitiesInternal(this ElsaOptionsBuilder options) =>
 options
 .AddActivity <HttpEndpoint>()
 .AddActivity <WriteHttpResponse>()
 .AddActivity <SendHttpRequest>()
 .AddActivity <Redirect>();
Esempio n. 22
0
 /// <summary>
 /// Registers a consumer and associated message type using the competing consumer pattern. With the competing consumer pattern, only the first consumer on a given node to obtain a message will handle that message.
 /// This is in contrast to the Publisher-Subscriber pattern, where a message will be delivered to the consumer on all nodes in a cluster. To register a Publisher-Subscriber consumer, use <seealso cref="AddPubSubConsumer{TConsumer,TMessage}"/>
 /// </summary>
 public static ElsaOptionsBuilder AddCompetingConsumer <TConsumer, TMessage>(this ElsaOptionsBuilder elsaOptions, string?queueName = default) where TConsumer : class, IHandleMessages <TMessage>
 {
     elsaOptions.AddCompetingConsumerService <TConsumer, TMessage>();
     elsaOptions.AddCompetingMessageType <TMessage>(queueName);
     return(elsaOptions);
 }
Esempio n. 23
0
 public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration)
 {
     elsa.AddHttpActivities(configuration.GetSection("Elsa:Http").Bind);
 }
Esempio n. 24
0
 private static ElsaOptionsBuilder AddCompetingConsumerService <TConsumer, TMessage>(this ElsaOptionsBuilder elsaOptions) where TConsumer : class, IHandleMessages <TMessage>
 {
     elsaOptions.Services.AddTransient <IHandleMessages <TMessage>, TConsumer>();
     return(elsaOptions);
 }
 public static ElsaOptionsBuilder AddEmailActivities(this ElsaOptionsBuilder options, Action <SmtpOptions>?configureOptions = null)
 {
     options.Services.AddEmailServices(configureOptions);
     options.AddEmailActivitiesInternal();
     return(options);
 }
Esempio n. 26
0
 public static ElsaOptionsBuilder AddPubSubConsumer <TConsumer, TMessage>(this ElsaOptionsBuilder elsaOptions, string?queueName = default) where TConsumer : class, IHandleMessages <TMessage>
 {
     elsaOptions.Services.AddTransient <IHandleMessages <TMessage>, TConsumer>();
     elsaOptions.AddPubSubMessageType <TMessage>(queueName);
     return(elsaOptions);
 }
Esempio n. 27
0
 public static ElsaOptionsBuilder UseRabbitMq(this ElsaOptionsBuilder elsaOptions, string connectionString) => elsaOptions.UseServiceBus(context => ConfigureRabbitMqEndpoint(context, connectionString));
Esempio n. 28
0
        private static ElsaOptionsBuilder AddWorkflowsCore(this ElsaOptionsBuilder elsaOptions)
        {
            var services = elsaOptions.Services;

            services
            .TryAddSingleton <IClock>(SystemClock.Instance);

            services
            .AddLogging()
            .AddLocalization()
            .AddSingleton <IContainerNameAccessor, OptionsContainerNameAccessor>()
            .AddSingleton <IIdGenerator, IdGenerator>()
            .AddScoped <IWorkflowRegistry, WorkflowRegistry>()
            .AddSingleton <IActivityActivator, ActivityActivator>()
            .AddSingleton <ITokenService, TokenService>()
            .AddScoped <IWorkflowRunner, WorkflowRunner>()
            .AddScoped <WorkflowStarter>()
            .AddScoped <WorkflowResumer>()
            .AddScoped <IStartsWorkflow>(sp => sp.GetRequiredService <WorkflowStarter>())
            .AddScoped <IStartsWorkflows>(sp => sp.GetRequiredService <WorkflowStarter>())
            .AddScoped <IFindsAndStartsWorkflows>(sp => sp.GetRequiredService <WorkflowStarter>())
            .AddScoped <IBuildsAndStartsWorkflow>(sp => sp.GetRequiredService <WorkflowStarter>())
            .AddScoped <IFindsAndResumesWorkflows>(sp => sp.GetRequiredService <WorkflowResumer>())
            .AddScoped <IResumesWorkflow>(sp => sp.GetRequiredService <WorkflowResumer>())
            .AddScoped <IResumesWorkflows>(sp => sp.GetRequiredService <WorkflowResumer>())
            .AddScoped <IBuildsAndResumesWorkflow>(sp => sp.GetRequiredService <WorkflowResumer>())
            .AddScoped <IWorkflowLaunchpad, WorkflowLaunchpad>()
            .AddScoped <IWorkflowInstanceExecutor, WorkflowInstanceExecutor>()
            .AddScoped <IWorkflowTriggerInterruptor, WorkflowTriggerInterruptor>()
            .AddScoped <IWorkflowReviver, WorkflowReviver>()
            .AddScoped <IWorkflowInstanceCanceller, WorkflowInstanceCanceller>()
            .AddScoped <IWorkflowInstanceDeleter, WorkflowInstanceDeleter>()
            .AddSingleton <IWorkflowFactory, WorkflowFactory>()
            .AddTransient <IWorkflowBlueprintMaterializer, WorkflowBlueprintMaterializer>()
            .AddSingleton <IWorkflowBlueprintReflector, WorkflowBlueprintReflector>()
            .AddSingleton <IBackgroundWorker, BackgroundWorker>()
            .AddScoped <IWorkflowPublisher, WorkflowPublisher>()
            .AddScoped <IWorkflowContextManager, WorkflowContextManager>()
            .AddScoped <IActivityTypeService, ActivityTypeService>()
            .AddActivityTypeProvider <TypeBasedActivityProvider>()
            .AddTransient <ICreatesWorkflowExecutionContextForWorkflowBlueprint, WorkflowExecutionContextForWorkflowBlueprintFactory>()
            .AddTransient <ICreatesActivityExecutionContextForActivityBlueprint, ActivityExecutionContextForActivityBlueprintFactory>()
            .AddTransient <IGetsStartActivities, GetsStartActivitiesProvider>()
            ;

            // Data Protection.
            services.AddDataProtection();

            // Serialization.
            services
            .AddTransient <Func <JsonSerializer> >(sp => sp.GetRequiredService <JsonSerializer>)
            .AddTransient(sp => sp.GetRequiredService <ElsaOptions>().CreateJsonSerializer(sp))
            .AddSingleton <IContentSerializer, DefaultContentSerializer>()
            .AddSingleton <TypeJsonConverter>();

            // Expressions.
            services
            .TryAddProvider <IExpressionHandler, LiteralHandler>(ServiceLifetime.Singleton)
            .TryAddProvider <IExpressionHandler, VariableHandler>(ServiceLifetime.Singleton)
            .TryAddProvider <IExpressionHandler, JsonHandler>(ServiceLifetime.Singleton)
            .TryAddProvider <IExpressionHandler, SwitchHandler>(ServiceLifetime.Singleton)
            .AddScoped <IExpressionEvaluator, ExpressionEvaluator>();

            // Workflow providers.
            services
            .AddWorkflowProvider <ProgrammaticWorkflowProvider>()
            .AddWorkflowProvider <BlobStorageWorkflowProvider>()
            .AddWorkflowProvider <DatabaseWorkflowProvider>();

            services.Configure <BlobStorageWorkflowProviderOptions>(o => o.BlobStorageFactory = StorageFactory.Blobs.InMemory);

            // Workflow Storage Providers.
            services
            .AddSingleton <IWorkflowStorageService, WorkflowStorageService>()
            .AddWorkflowStorageProvider <TransientWorkflowStorageProvider>()
            .AddWorkflowStorageProvider <WorkflowInstanceWorkflowStorageProvider>()
            .AddWorkflowStorageProvider <BlobStorageWorkflowStorageProvider>();

            services.Configure <BlobStorageWorkflowStorageProviderOptions>(o => o.BlobStorageFactory = StorageFactory.Blobs.InMemory);

            // Metadata.
            services
            .AddSingleton <IDescribesActivityType, TypedActivityTypeDescriber>()
            .AddSingleton <IActivityPropertyOptionsResolver, ActivityPropertyOptionsResolver>()
            .AddSingleton <IActivityPropertyDefaultValueResolver, ActivityPropertyDefaultValueResolver>()
            .AddSingleton <IActivityPropertyUIHintResolver, ActivityPropertyUIHintResolver>();

            // Bookmarks.
            services
            .AddSingleton <IBookmarkHasher, BookmarkHasher>()
            .AddSingleton <IBookmarkSerializer, BookmarkSerializer>()
            .AddScoped <IBookmarkIndexer, BookmarkIndexer>()
            .AddScoped <IBookmarkFinder, BookmarkFinder>()
            .AddScoped <ITriggerIndexer, TriggerIndexer>()
            .AddScoped <IGetsTriggersForWorkflowBlueprints, TriggersForBlueprintsProvider>()
            .AddTransient <IGetsTriggersForActivityBlueprintAndWorkflow, TriggersForActivityBlueprintAndWorkflowProvider>()
            .AddScoped <ITriggerFinder, TriggerFinder>()
            .AddBookmarkProvider <SignalReceivedBookmarkProvider>()
            .AddBookmarkProvider <RunWorkflowBookmarkProvider>();

            // Mediator.
            services
            .AddMediatR(mediatr => mediatr.AsScoped(), typeof(IActivity), typeof(LogWorkflowExecution));

            // Service Bus.
            services
            .AddSingleton <ServiceBusFactory>()
            .AddSingleton <IServiceBusFactory>(sp => sp.GetRequiredService <ServiceBusFactory>())
            .AddSingleton <ICommandSender, CommandSender>()
            .AddSingleton <IEventPublisher, EventPublisher>();

            elsaOptions
            .AddCompetingConsumer <TriggerWorkflowsRequestConsumer, TriggerWorkflowsRequest>("ExecuteWorkflow")
            .AddCompetingConsumer <ExecuteWorkflowDefinitionRequestConsumer, ExecuteWorkflowDefinitionRequest>("ExecuteWorkflow")
            .AddCompetingConsumer <ExecuteWorkflowInstanceRequestConsumer, ExecuteWorkflowInstanceRequest>("ExecuteWorkflow");

            // AutoMapper.
            services
            .AddAutoMapperProfile <NodaTimeProfile>()
            .AddAutoMapperProfile <CloningProfile>()
            .AddAutoMapperProfile <ExceptionProfile>()
            .AddTransient <ExceptionConverter>()
            .AddSingleton <ICloner, AutoMapperCloner>();

            // Caching.
            services
            .AddMemoryCache()
            .AddScoped <ISignaler, Signaler>()
            .Decorate <IWorkflowRegistry, CachingWorkflowRegistry>();

            // Builder API.
            services
            .AddTransient <IWorkflowBuilder, WorkflowBuilder>()
            .AddTransient <ICompositeActivityBuilder, CompositeActivityBuilder>()
            .AddTransient <Func <IWorkflowBuilder> >(sp => sp.GetRequiredService <IWorkflowBuilder>);

            return(elsaOptions);
        }
Esempio n. 29
0
 public static ElsaOptionsBuilder AddEntityActivities(this ElsaOptionsBuilder options)
 {
     options.AddActivity <EntityChanged>();
     options.Services.AddBookmarkProvider <EntityChangedWorkflowTriggerProvider>();
     return(options);
 }
Esempio n. 30
0
 public static ElsaOptionsBuilder UseYesSqlPersistence(this ElsaOptionsBuilder elsa) => elsa.UseYesSqlPersistence(config => config.UseSqLite("Data Source=elsa.yessql.db;Cache=Shared", IsolationLevel.ReadUncommitted));