Add project files.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Workflows;
|
||||
|
||||
namespace Elsa.ServerAndStudio.Web.Activities;
|
||||
|
||||
public class CustomDelay : Activity
|
||||
{
|
||||
protected override ValueTask ExecuteAsync(ActivityExecutionContext context)
|
||||
{
|
||||
context.DelayFor(TimeSpan.FromSeconds(5), FailAsync);
|
||||
context.DelayFor(TimeSpan.FromSeconds(500), OnDelayElapsedAsync);
|
||||
return default;
|
||||
}
|
||||
|
||||
private ValueTask FailAsync(ActivityExecutionContext context)
|
||||
{
|
||||
Console.WriteLine("Failing!");
|
||||
throw new("Failing!");
|
||||
}
|
||||
|
||||
private async ValueTask OnDelayElapsedAsync(ActivityExecutionContext context)
|
||||
{
|
||||
Console.WriteLine("Delay elapsed");
|
||||
await context.CompleteActivityAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Elsa.Expressions.Models;
|
||||
using Elsa.Workflows;
|
||||
using Elsa.Workflows.Runtime.Activities;
|
||||
|
||||
namespace Elsa.ServerAndStudio.Web.Activities;
|
||||
|
||||
public class CustomEvent : EventBase<object>
|
||||
{
|
||||
protected override string GetEventName(ExpressionExecutionContext context)
|
||||
{
|
||||
return "MyEvent";
|
||||
}
|
||||
|
||||
protected override void OnEventReceived(ActivityExecutionContext context, object? eventData)
|
||||
{
|
||||
Console.WriteLine("Event received with data: " + eventData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Elsa.Http;
|
||||
using Elsa.Workflows;
|
||||
|
||||
namespace Elsa.ServerAndStudio.Web.Activities;
|
||||
|
||||
public class CustomHttpEndpoint : HttpEndpointBase
|
||||
{
|
||||
protected override HttpEndpointOptions GetOptions()
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Path = "my-path",
|
||||
Methods = [HttpMethods.Get],
|
||||
};
|
||||
}
|
||||
|
||||
protected override async ValueTask OnHttpRequestReceivedAsync(ActivityExecutionContext context, HttpContext httpContext)
|
||||
{
|
||||
httpContext.Response.StatusCode = 200;
|
||||
await httpContext.Response.WriteAsync("Hello World", context.CancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Elsa.Expressions.Models;
|
||||
using Elsa.Scheduling.Activities;
|
||||
using Elsa.Workflows;
|
||||
|
||||
namespace Elsa.ServerAndStudio.Web.Activities;
|
||||
|
||||
public class CustomTimer : TimerBase
|
||||
{
|
||||
protected override TimeSpan GetInterval(ExpressionExecutionContext context)
|
||||
{
|
||||
return TimeSpan.FromSeconds(5);
|
||||
}
|
||||
|
||||
protected override void OnTimerElapsed(ActivityExecutionContext context)
|
||||
{
|
||||
Console.WriteLine("Timer elapsed");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Agents.Persistence.EntityFrameworkCore.MySql\Elsa.Agents.Persistence.EntityFrameworkCore.MySql.csproj" Condition=" '$(TargetFramework)' != 'net9.0' " />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Connections.Api\Elsa.Connections.Api.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Connections.Core\Elsa.Connections.Core.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Connections.Persistence.EntityFrameworkCore.Sqlite\Elsa.Connections.Persistence.EntityFrameworkCore.Sqlite.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Connections.Persistence.EntityFrameworkCore\Elsa.Connections.Persistence.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore.PostgreSql\Elsa.EntityFrameworkCore.PostgreSql.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore.SqlServer\Elsa.EntityFrameworkCore.SqlServer.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.IO.Http\Elsa.IO.Http.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.JavaScript.Libraries\Elsa.JavaScript.Libraries.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Quartz.EntityFrameworkCore.PostgreSql\Elsa.Quartz.EntityFrameworkCore.PostgreSql.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Quartz.EntityFrameworkCore.SqlServer\Elsa.Quartz.EntityFrameworkCore.SqlServer.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Secrets.Persistence.EntityFrameworkCore.PostgreSql\Elsa.Secrets.Persistence.EntityFrameworkCore.PostgreSql.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa\Elsa.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Caching.Distributed.MassTransit\Elsa.Caching.Distributed.MassTransit.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Caching.Distributed\Elsa.Caching.Distributed.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.CSharp\Elsa.CSharp.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Email\Elsa.Email.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore.MySql\Elsa.EntityFrameworkCore.MySql.csproj" Condition=" '$(TargetFramework)' != 'net9.0' " />
|
||||
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore.Sqlite\Elsa.EntityFrameworkCore.Sqlite.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Hangfire\Elsa.Hangfire.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Http\Elsa.Http.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Identity\Elsa.Identity.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.IO.Compression\Elsa.IO.Compression.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Liquid\Elsa.Liquid.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.MassTransit.AzureServiceBus\Elsa.MassTransit.AzureServiceBus.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.MassTransit.RabbitMq\Elsa.MassTransit.RabbitMq.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.MassTransit\Elsa.MassTransit.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Workflows.Runtime.ProtoActor\Elsa.Workflows.Runtime.ProtoActor.csproj" />
|
||||
<ProjectReference Include="..\..\modules\Elsa.Python\Elsa.Python.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Quartz\Elsa.Quartz.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Webhooks\Elsa.Webhooks.csproj"/>
|
||||
<ProjectReference Include="..\..\modules\Elsa.Workflows.Api\Elsa.Workflows.Api.csproj"/>
|
||||
<ProjectReference Include="..\ElsaStudioWebAssembly\ElsaStudioWebAssembly.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server"/>
|
||||
<PackageReference Include="Proto.Persistence.Sqlite"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Elsa.Studio"/>
|
||||
<PackageReference Include="Elsa.Studio.Login.BlazorWasm"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Elsa.ServerAndStudio.Web.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the transport options for distributed caching.
|
||||
/// </summary>
|
||||
public enum DistributedCachingTransport
|
||||
{
|
||||
None,
|
||||
Memory,
|
||||
MassTransit
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Elsa.ServerAndStudio.Web.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the type of messaging broker used in MassTransit.
|
||||
/// </summary>
|
||||
public enum MassTransitBroker
|
||||
{
|
||||
Memory,
|
||||
AzureServiceBus,
|
||||
RabbitMq
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Elsa.ServerAndStudio.Web.Enums;
|
||||
|
||||
public enum SqlDatabaseProvider
|
||||
{
|
||||
SqlServer,
|
||||
Sqlite,
|
||||
MySql,
|
||||
PostgreSql,
|
||||
CockroachDb
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Cors.Infrastructure;
|
||||
|
||||
namespace Elsa.ServerAndStudio.Web.Extensions;
|
||||
|
||||
public static class CorsOptionsExtensions
|
||||
{
|
||||
private static bool AllowAny(IList<string> values) => values.Count == 0 || values[0] == "*";
|
||||
|
||||
public static void Configure(this CorsOptions options, IConfigurationSection section)
|
||||
{
|
||||
var corsPolicy = section.Get<CorsPolicy>() ?? new CorsPolicy();
|
||||
options.AddDefaultPolicy(policy => {
|
||||
var headers = corsPolicy.Headers;
|
||||
var origins = corsPolicy.Origins;
|
||||
var methods = corsPolicy.Methods;
|
||||
|
||||
if (AllowAny(headers))
|
||||
policy.AllowAnyHeader();
|
||||
else
|
||||
policy.WithHeaders(headers.ToArray());
|
||||
|
||||
if (AllowAny(origins))
|
||||
policy.AllowAnyOrigin();
|
||||
else
|
||||
policy.WithOrigins(origins.ToArray());
|
||||
|
||||
if (AllowAny(methods))
|
||||
policy.AllowAnyMethod();
|
||||
else
|
||||
policy.WithMethods(methods.ToArray());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<ConfigureAwait />
|
||||
</Weavers>
|
||||
@@ -0,0 +1,61 @@
|
||||
@page "/"
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@inject IConfiguration Configuration;
|
||||
@{
|
||||
var baseUrl = Configuration["Hosting:BaseUrl"] ?? Configuration["Http:BaseUrl"]!; // HttpBaseUrl is for backward compatibility.
|
||||
var apiUrl = $"{baseUrl.TrimEnd('/')}/{(Configuration["Hosting:ApiPrefix"] ?? "elsa/api").TrimStart('/')}";
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<title>Elsa Studio 3.5</title>
|
||||
<base href="/"/>
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="@baseUrl/_content/Elsa.Studio.Shell/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="@baseUrl/_content/Elsa.Studio.Shell/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="@baseUrl/_content/Elsa.Studio.Shell/favicon-16x16.png">
|
||||
<link rel="manifest" href="@baseUrl/_content/Elsa.Studio.Shell/site.webmanifest">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet"/>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@300;400;500;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Grandstander:wght@100&display=swap" rel="stylesheet">
|
||||
<link href="@baseUrl/_content/MudBlazor/MudBlazor.min.css" rel="stylesheet"/>
|
||||
<link href="@baseUrl/_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.css" rel="stylesheet"/>
|
||||
<link href="@baseUrl/_content/Radzen.Blazor/css/material-base.css" rel="stylesheet">
|
||||
<link href="@baseUrl/_content/Elsa.Studio.Shell/css/shell.css" rel="stylesheet">
|
||||
<link href="@baseUrl/_content/Elsa.Studio.Workflows.Designer/designer.css" rel="stylesheet">
|
||||
<link href="ElsaStudioWebAssembly.styles.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="loading-splash mud-container mud-container-maxwidth-false">
|
||||
<h5 class="mud-typography mud-typography-h5 mud-primary-text my-6">Loading...</h5>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="blazor-error-ui">
|
||||
An unhandled error has occurred.
|
||||
<a href="" class="reload">Reload</a>
|
||||
<a class="dismiss">🗙</a>
|
||||
</div>
|
||||
<script src="@baseUrl/_content/BlazorMonaco/jsInterop.js"></script>
|
||||
<script src="@baseUrl/_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"></script>
|
||||
<script src="@baseUrl/_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js"></script>
|
||||
<script src="@baseUrl/_content/MudBlazor/MudBlazor.min.js"></script>
|
||||
<script src="@baseUrl/_content/CodeBeam.MudBlazor.Extensions/MudExtensions.min.js"></script>
|
||||
<script src="@baseUrl/_content/Radzen.Blazor/Radzen.Blazor.js"></script>
|
||||
<script>
|
||||
window.getClientConfig = function() { return {
|
||||
"apiUrl": "@apiUrl"
|
||||
} };
|
||||
</script>
|
||||
<script src="@baseUrl/_framework/blazor.webassembly.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,223 @@
|
||||
using Elsa.Agents;
|
||||
using Elsa.EntityFrameworkCore.Extensions;
|
||||
using Elsa.EntityFrameworkCore.Modules.Management;
|
||||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.MassTransit.Options;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.JavaScript.Libraries.Extensions;
|
||||
using Elsa.ServerAndStudio.Web.Extensions;
|
||||
using Elsa.MassTransit.Extensions;
|
||||
using Elsa.ServerAndStudio.Web.Enums;
|
||||
using Medallion.Threading.FileSystem;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using WebhooksCore.Options;
|
||||
using Elsa.Connections.Middleware;
|
||||
using Elsa.IO.Http.Features;
|
||||
using Proto.Persistence.Sqlite;
|
||||
|
||||
const bool useMassTransit = true;
|
||||
const bool useProtoActor = true;
|
||||
const bool useCaching = true;
|
||||
const DistributedCachingTransport distributedCachingTransport = DistributedCachingTransport.MassTransit;
|
||||
const MassTransitBroker useMassTransitBroker = MassTransitBroker.Memory;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.UseStaticWebAssets();
|
||||
var services = builder.Services;
|
||||
var configuration = builder.Configuration;
|
||||
var sqliteConnectionString = configuration.GetConnectionString("Sqlite")!;
|
||||
var mySqlConnectionString = configuration.GetConnectionString("MySql")!;
|
||||
var sqlServerConnectionString = configuration.GetConnectionString("SqlServer")!;
|
||||
var postgreSqlConnectionString = configuration.GetConnectionString("PostgreSql")!;
|
||||
var rabbitMqConnectionString = configuration.GetConnectionString("RabbitMq")!;
|
||||
var azureServiceBusConnectionString = configuration.GetConnectionString("AzureServiceBus")!;
|
||||
var identitySection = configuration.GetSection("Identity");
|
||||
var identityTokenSection = identitySection.GetSection("Tokens");
|
||||
var massTransitSection = configuration.GetSection("MassTransit");
|
||||
var massTransitDispatcherSection = configuration.GetSection("MassTransit.Dispatcher");
|
||||
var heartbeatSection = configuration.GetSection("Heartbeat");
|
||||
var sqlDatabaseProvider = Enum.Parse<SqlDatabaseProvider>(configuration["DatabaseProvider"] ?? "Sqlite");
|
||||
|
||||
services.Configure<MassTransitOptions>(massTransitSection);
|
||||
services.Configure<MassTransitWorkflowDispatcherOptions>(massTransitDispatcherSection);
|
||||
|
||||
// Add Elsa services.
|
||||
services
|
||||
.AddElsa(elsa =>
|
||||
{
|
||||
elsa
|
||||
.UseSasTokens()
|
||||
.UseIdentity(identity =>
|
||||
{
|
||||
identity.TokenOptions = options => identityTokenSection.Bind(options);
|
||||
identity.UseConfigurationBasedUserProvider(options => identitySection.Bind(options));
|
||||
identity.UseConfigurationBasedApplicationProvider(options => identitySection.Bind(options));
|
||||
identity.UseConfigurationBasedRoleProvider(options => identitySection.Bind(options));
|
||||
})
|
||||
.UseDefaultAuthentication()
|
||||
.UseApplicationCluster(x => x.HeartbeatOptions = settings => heartbeatSection.Bind(settings))
|
||||
.UseWorkflowManagement(management =>
|
||||
{
|
||||
if (useMassTransit)
|
||||
{
|
||||
management.UseMassTransitDispatcher();
|
||||
}
|
||||
|
||||
if (useCaching)
|
||||
management.UseCache();
|
||||
|
||||
if (sqlDatabaseProvider == SqlDatabaseProvider.SqlServer)
|
||||
management.UseEntityFrameworkCore(ef => ef.UseSqlServer(sqlServerConnectionString));
|
||||
else if (sqlDatabaseProvider == SqlDatabaseProvider.PostgreSql)
|
||||
management.UseEntityFrameworkCore(ef => ef.UsePostgreSql(postgreSqlConnectionString));
|
||||
else if (sqlDatabaseProvider == SqlDatabaseProvider.Sqlite)
|
||||
management.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString));
|
||||
#if !NET9_0
|
||||
else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
|
||||
management.UseEntityFrameworkCore(ef => ef.UseMySql(mySqlConnectionString));
|
||||
#endif
|
||||
})
|
||||
.UseWorkflowRuntime(runtime =>
|
||||
{
|
||||
if (sqlDatabaseProvider == SqlDatabaseProvider.SqlServer)
|
||||
runtime.UseEntityFrameworkCore(ef => ef.UseSqlServer(sqlServerConnectionString));
|
||||
else if (sqlDatabaseProvider == SqlDatabaseProvider.PostgreSql)
|
||||
runtime.UseEntityFrameworkCore(ef => ef.UsePostgreSql(postgreSqlConnectionString));
|
||||
else if (sqlDatabaseProvider == SqlDatabaseProvider.Sqlite)
|
||||
runtime.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString));
|
||||
#if !NET9_0
|
||||
else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql)
|
||||
runtime.UseEntityFrameworkCore(ef => ef.UseMySql(mySqlConnectionString));
|
||||
#endif
|
||||
|
||||
if (useMassTransit)
|
||||
{
|
||||
runtime.UseMassTransitDispatcher();
|
||||
}
|
||||
|
||||
if (useProtoActor)
|
||||
{
|
||||
runtime.UseProtoActor();
|
||||
}
|
||||
|
||||
if (useCaching)
|
||||
runtime.UseCache();
|
||||
|
||||
runtime.DistributedLockProvider = _ => new FileDistributedSynchronizationProvider(new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "App_Data", "locks")));
|
||||
runtime.WorkflowInboxCleanupOptions = options => configuration.GetSection("Runtime:WorkflowInboxCleanup").Bind(options);
|
||||
runtime.WorkflowDispatcherOptions = options => configuration.GetSection("Runtime:WorkflowDispatcher").Bind(options);
|
||||
})
|
||||
.UseScheduling()
|
||||
.UseJavaScript(javaScriptFeature =>
|
||||
{
|
||||
javaScriptFeature
|
||||
.ConfigureJintOptions(jintOptions => jintOptions.AllowClrAccess = true)
|
||||
.UseLodashFp()
|
||||
.UseMoment();
|
||||
})
|
||||
.UseLiquid()
|
||||
.UseCSharp()
|
||||
.UsePython(python =>
|
||||
{
|
||||
python.PythonOptions += options =>
|
||||
{
|
||||
// Make sure to configure the path to the python DLL. E.g. /opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/bin/python3.11
|
||||
// alternatively, you can set the PYTHONNET_PYDLL environment variable.
|
||||
configuration.GetSection("Scripting:Python").Bind(options);
|
||||
};
|
||||
})
|
||||
.UseHttp(http =>
|
||||
{
|
||||
if (useCaching)
|
||||
http.UseCache();
|
||||
|
||||
http.ConfigureHttpOptions = options =>
|
||||
{
|
||||
options.BaseUrl = new Uri(configuration["Hosting:BaseUrl"] ?? configuration["Http:BaseUrl"]!); // HttpBaseUrl is for backward compatibility.
|
||||
options.BasePath = configuration["Http:BasePath"];
|
||||
};
|
||||
})
|
||||
.UseEmail(email => email.ConfigureOptions = options => configuration.GetSection("Smtp").Bind(options))
|
||||
.UseWebhooks(webhooks => webhooks.ConfigureSinks = options => builder.Configuration.GetSection("Webhooks:Sinks").Bind(options))
|
||||
.UseWorkflowsApi()
|
||||
.UseCompression()
|
||||
.Use<IOHttpFeature>()
|
||||
.AddActivitiesFrom<Program>()
|
||||
.AddWorkflowsFrom<Program>();
|
||||
|
||||
if (useProtoActor)
|
||||
{
|
||||
elsa.UseProtoActor(proto => proto.PersistenceProvider = _ =>
|
||||
{
|
||||
return new SqliteProvider(new SqliteConnectionStringBuilder(sqliteConnectionString));
|
||||
});
|
||||
}
|
||||
|
||||
if (useMassTransit)
|
||||
{
|
||||
elsa.UseMassTransit(massTransit =>
|
||||
{
|
||||
switch (useMassTransitBroker)
|
||||
{
|
||||
case MassTransitBroker.AzureServiceBus:
|
||||
massTransit.UseAzureServiceBus(azureServiceBusConnectionString, asb =>
|
||||
{
|
||||
asb.SubscriptionCleanupOptions = options => options.Interval = TimeSpan.FromMinutes(5);
|
||||
asb.EnableAutomatedSubscriptionCleanup = true;
|
||||
});
|
||||
break;
|
||||
case MassTransitBroker.RabbitMq:
|
||||
massTransit.UseRabbitMq(rabbitMqConnectionString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (distributedCachingTransport != DistributedCachingTransport.None)
|
||||
{
|
||||
elsa.UseDistributedCache(distributedCaching =>
|
||||
{
|
||||
if (distributedCachingTransport == DistributedCachingTransport.MassTransit) distributedCaching.UseMassTransit();
|
||||
});
|
||||
}
|
||||
|
||||
elsa.UseConnections(
|
||||
configure=> configure.AddConnectionsFrom<Program>());
|
||||
elsa.UseConnectionPersistence(ef=> ef.UseEntityFrameworkCore(f=>f.UseSqlite()));
|
||||
elsa.UseConnectionsApi();
|
||||
});
|
||||
|
||||
services.Configure<WebhookSinksOptions>(options => configuration.GetSection("Webhooks").Bind(options));
|
||||
|
||||
services.AddHealthChecks();
|
||||
|
||||
services.AddCors(cors => cors.Configure(configuration.GetSection("CorsPolicy")));
|
||||
|
||||
// Razor Pages.
|
||||
services.AddRazorPages(options => options.Conventions.ConfigureFilter(new IgnoreAntiforgeryTokenAttribute()));
|
||||
|
||||
// Configure middleware pipeline.
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseBlazorFrameworkFiles();
|
||||
app.MapHealthChecks("/health");
|
||||
app.UseRouting();
|
||||
app.UseCors();
|
||||
app.UseStaticFiles();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.UseWorkflowsApi();
|
||||
app.UseWorkflows();
|
||||
app.MapFallbackToPage("/_Host");
|
||||
await app.RunAsync();
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:8080",
|
||||
"sslPort": 44363
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"Elsa.AllInOne.Web": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:8080",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# Server
|
||||
|
||||
This project represents an Elsa application that hosts workflows and exposes API endpoints to manage & execute workflows.
|
||||
It also hosts the Elsa Studio Web Assembly project, which replaces the Stencil implementation.
|
||||
|
||||
## Secrets
|
||||
The following are the secrets stored in hashed form in appsettings.json:
|
||||
|
||||
**API key**: `48587230567A646D394B435A6277734A-4802fa49-e91e-45e8-b00f-b5492377e20b`
|
||||
**Admin user**: `admin`
|
||||
**Admin password**: `password`
|
||||
@@ -0,0 +1,135 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information",
|
||||
"OpenTelemetry": "Debug"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"Sqlite": "Data Source=elsa.sqlite.db;Cache=Shared;",
|
||||
"RabbitMq": "rabbitmq://guest:guest@localhost:5672",
|
||||
"MySql": "Server=localhost;Database=elsa;Uid=user;Pwd=password;",
|
||||
"SqlServer": "Server=.;Database=WorkflowDb;User Id=sa;Password=123456;TrustServerCertificate=True;",
|
||||
"PostgreSql": "Server=localhost;Username=elsa;Database=elsa;Port=5432;Password=elsa;SSLMode=Prefer;MaxPoolSize=2000;Timeout=60"
|
||||
},
|
||||
"DatabaseProvider": "Sqlite",
|
||||
"Hosting": {
|
||||
"BaseUrl": "https://localhost:8080",
|
||||
"ApiPrefix": "/elsa/api"
|
||||
},
|
||||
"Identity": {
|
||||
"Tokens": {
|
||||
"SigningKey": "c7dc81876a782d502084763fa322429fca015941eac90ce8ca7ad95fc8752035",
|
||||
"AccessTokenLifetime": "1:00:00:00",
|
||||
"RefreshTokenLifetime": "1:00:10:00"
|
||||
},
|
||||
"Roles": [
|
||||
{
|
||||
"Id": "admin",
|
||||
"Name": "Administrator",
|
||||
"Permissions": [
|
||||
"*"
|
||||
]
|
||||
}
|
||||
],
|
||||
"Users": [
|
||||
{
|
||||
"Id": "a2323f46-42db-4e15-af8b-94238717d817",
|
||||
"Name": "admin",
|
||||
"HashedPassword": "TfKzh9RLix6FPcCNeHLkGrysFu3bYxqzGqduNdi8v1U=",
|
||||
"HashedPasswordSalt": "JEy9kBlhHCNsencitRHlGxmErmSgY+FVyMJulCH27Ds=",
|
||||
"Roles": [
|
||||
"admin"
|
||||
]
|
||||
}
|
||||
],
|
||||
"Applications": [
|
||||
{
|
||||
"id": "d57030226341448daff5a2935aba2d3f",
|
||||
"name": "Postman",
|
||||
"roles": [
|
||||
"admin"
|
||||
],
|
||||
"clientId": "HXr0Vzdm9KCZbwsJ",
|
||||
"clientSecret": "a<~QGGHTEA%u4;CU&'Wga5ED:_&Gd1C)",
|
||||
"hashedApiKey": "Z5ClHs3mbzx8Pnw3+PxbMq8A/Y+VKMCCDTGYtax8JFM=",
|
||||
"hashedApiKeySalt": "kBisa1X8FwBfN2zmyGMFRgIVVBleghhQAJ4WGyTkaD0=",
|
||||
"hashedClientSecret": "jEv58d0SVbGQ3nBZM0lkzHghG4Y+lMKW80wipz+9vHk=",
|
||||
"hashedClientSecretSalt": "xRKy14Ok1/tU3kLf/8V1fcbLIegy9vcM90Peu2tzohU="
|
||||
}
|
||||
]
|
||||
},
|
||||
"Heartbeat": {
|
||||
"Interval": "00:00:01:00",
|
||||
"Timeout": "00:00:05:00"
|
||||
},
|
||||
"MassTransit": {
|
||||
"TemporaryQueueTtl": "00:00:05:00",
|
||||
"ConcurrentMessageLimit": 4,
|
||||
"PrefetchCount": 4,
|
||||
"MaxAutoRenewDuration": "00:00:00:30",
|
||||
"Dispatcher": {
|
||||
"ConcurrentMessageLimit": 4
|
||||
}
|
||||
},
|
||||
"Smtp": {
|
||||
"Host": "localhost",
|
||||
"Port": 2525,
|
||||
"DefaultSender": "noreply@crmservices.com"
|
||||
},
|
||||
"Http": {
|
||||
"BasePath": "/api/workflows"
|
||||
},
|
||||
"Webhooks": {
|
||||
"Sinks": []
|
||||
},
|
||||
"CorsPolicy": {
|
||||
"Origins": ["*"],
|
||||
"Methods": ["*"],
|
||||
"Headers": ["*"]
|
||||
},
|
||||
"Runtime": {
|
||||
"WorkflowInboxCleanup": {
|
||||
"SweepInterval": "00:00:10:00",
|
||||
"BatchSize": 1000
|
||||
},
|
||||
"WorkflowDispatcher": {
|
||||
"Channels": [
|
||||
{
|
||||
"Name": "Low"
|
||||
},
|
||||
{
|
||||
"Name": "Medium"
|
||||
},
|
||||
{
|
||||
"Name": "High"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Scripting": {
|
||||
"Python": {
|
||||
"PythonDllPath": "",
|
||||
"Scripts": [
|
||||
"def greet(name): return f'Hello {name}!'",
|
||||
"def say_hello_world(): return greet('World')"
|
||||
]
|
||||
}
|
||||
},
|
||||
"AzureServiceBus": {
|
||||
"ConnectionStringOrName": "AzureServiceBus",
|
||||
"Queues": [
|
||||
{
|
||||
"name": "order-created"
|
||||
},
|
||||
{
|
||||
"name": "order-completed"
|
||||
}
|
||||
],
|
||||
"Topics": [],
|
||||
"Subscriptions": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user