2021-03-17 12:07:14 +00:00
|
|
|
using Elsa.Activities.Telnyx.Extensions;
|
2021-01-31 11:51:51 +00:00
|
|
|
using Elsa.Persistence.EntityFramework.Core.Extensions;
|
|
|
|
|
using Elsa.Persistence.EntityFramework.Sqlite;
|
2021-04-01 16:53:26 +00:00
|
|
|
using Elsa.Server.Hangfire.Extensions;
|
2021-03-30 13:18:48 +00:00
|
|
|
using Elsa.Server.Orleans.Extensions;
|
2021-04-01 16:53:26 +00:00
|
|
|
using Hangfire;
|
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;
|
2021-04-01 16:53:26 +00:00
|
|
|
using NodaTime;
|
|
|
|
|
using NodaTime.Serialization.JsonNet;
|
2019-11-22 22:07:31 +00:00
|
|
|
|
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");
|
2021-04-01 16:53:26 +00:00
|
|
|
var hangfireSection = Configuration.GetSection("Hangfire");
|
|
|
|
|
|
|
|
|
|
services
|
|
|
|
|
.AddHangfire(configuration => configuration
|
|
|
|
|
.UseSimpleAssemblyNameTypeSerializer()
|
|
|
|
|
.UseRecommendedSerializerSettings(settings => settings.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb))
|
|
|
|
|
.UseInMemoryStorage())
|
|
|
|
|
.AddHangfireServer(options => hangfireSection.GetSection("Server").Bind(options));
|
2019-11-22 22:07:31 +00:00
|
|
|
|
|
|
|
|
services
|
2021-01-31 11:51:51 +00:00
|
|
|
.AddElsa(elsa => elsa
|
|
|
|
|
.UseEntityFrameworkPersistence(ef => ef.UseSqlite())
|
2021-04-01 16:53:26 +00:00
|
|
|
//.UseOrleansDispatchers()
|
|
|
|
|
.UseHangfireDispatchers()
|
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()
|
2021-03-17 12:07:14 +00:00
|
|
|
.AddTelnyx()
|
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-03-11 12:17:38 +00:00
|
|
|
|
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.
|
2021-03-11 12:17:38 +00:00
|
|
|
services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().WithExposedHeaders("Content-Disposition")));
|
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()
|
2021-03-11 12:17:38 +00:00
|
|
|
.UseCors()
|
2020-10-20 21:17:08 +00:00
|
|
|
.UseRouting()
|
2021-03-17 12:07:14 +00:00
|
|
|
.UseEndpoints(endpoints =>
|
|
|
|
|
{
|
|
|
|
|
endpoints.MapControllers();
|
|
|
|
|
endpoints.MapTelnyxWebhook();
|
|
|
|
|
});
|
2019-11-22 22:07:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|