2021-01-31 11:51:51 +00:00
|
|
|
using Elsa.Persistence.EntityFramework.Core.Extensions;
|
|
|
|
|
using Elsa.Persistence.EntityFramework.Sqlite;
|
2019-11-22 22:07:31 +00:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
2020-12-27 10:53:52 +00:00
|
|
|
namespace Elsa.Samples.Server.Host
|
2019-11-22 22:07:31 +00:00
|
|
|
{
|
|
|
|
|
public class Startup
|
|
|
|
|
{
|
|
|
|
|
public Startup(IWebHostEnvironment environment, IConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
Environment = environment;
|
|
|
|
|
Configuration = configuration;
|
|
|
|
|
}
|
2019-11-24 14:25:16 +00:00
|
|
|
|
|
|
|
|
private IWebHostEnvironment Environment { get; }
|
|
|
|
|
private IConfiguration Configuration { get; }
|
2019-11-22 22:07:31 +00:00
|
|
|
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
var elsaSection = Configuration.GetSection("Elsa");
|
|
|
|
|
|
|
|
|
|
services
|
2021-01-31 11:51:51 +00:00
|
|
|
.AddElsa(elsa => elsa
|
|
|
|
|
.UseEntityFrameworkPersistence(ef => ef.UseSqlite())
|
2020-12-26 11:21:08 +00:00
|
|
|
.AddConsoleActivities()
|
|
|
|
|
.AddHttpActivities(elsaSection.GetSection("Http").Bind)
|
|
|
|
|
.AddEmailActivities(elsaSection.GetSection("Smtp").Bind)
|
2021-02-28 15:44:23 +00:00
|
|
|
.AddQuartzTemporalActivities()
|
2020-12-26 20:55:02 +00:00
|
|
|
.AddWorkflowsFrom<Startup>()
|
2020-12-26 11:21:08 +00:00
|
|
|
);
|
2020-01-16 20:23:45 +00:00
|
|
|
|
|
|
|
|
services
|
2020-10-19 20:12:11 +00:00
|
|
|
.AddElsaApiEndpoints()
|
2021-01-19 19:17:14 +00:00
|
|
|
.AddElsaSwagger();
|
2021-02-16 08:55:13 +00:00
|
|
|
|
|
|
|
|
// Allow arbitrary client browser apps to access the API for demo purposes only.
|
|
|
|
|
// In a production environment, make sure to allow only origins you trust.
|
|
|
|
|
services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()));
|
2019-11-22 22:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Configure(IApplicationBuilder app)
|
|
|
|
|
{
|
|
|
|
|
if (Environment.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
app.UseDeveloperExceptionPage();
|
2020-11-11 20:32:12 +00:00
|
|
|
app.UseSwagger();
|
|
|
|
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Elsa"));
|
2019-11-22 22:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
2020-02-15 19:32:16 +00:00
|
|
|
app
|
|
|
|
|
.UseCors()
|
2020-10-20 21:17:08 +00:00
|
|
|
.UseHttpActivities()
|
|
|
|
|
.UseRouting()
|
|
|
|
|
.UseEndpoints(configure => configure.MapControllers());
|
2019-11-22 22:07:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|