Add MongoDB sample project

This commit is contained in:
Sipke Schoorstra 2023-06-29 12:27:21 +02:00
parent a1ce26a35c
commit 816a6f3f8e
6 changed files with 133 additions and 2 deletions

View file

@ -226,6 +226,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.ConsoleApp.Act
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.MongoDb", "src\modules\Elsa.MongoDb\Elsa.MongoDb.csproj", "{3A377A6A-F735-4010-9E00-72E8BEB8F1F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.AspNet.MongoDbPersistence", "src\samples\aspnet\Elsa.Samples.AspNet.MongoDbPersistence\Elsa.Samples.AspNet.MongoDbPersistence.csproj", "{DAACE93A-866E-428E-B2A9-AFAC79F9C7A4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -564,6 +566,10 @@ Global
{3A377A6A-F735-4010-9E00-72E8BEB8F1F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A377A6A-F735-4010-9E00-72E8BEB8F1F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A377A6A-F735-4010-9E00-72E8BEB8F1F2}.Release|Any CPU.Build.0 = Release|Any CPU
{DAACE93A-866E-428E-B2A9-AFAC79F9C7A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DAACE93A-866E-428E-B2A9-AFAC79F9C7A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAACE93A-866E-428E-B2A9-AFAC79F9C7A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAACE93A-866E-428E-B2A9-AFAC79F9C7A4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{155227F0-A33B-40AA-A4B4-06F813EB921B} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
@ -666,5 +672,6 @@ Global
{A702DD84-B55C-4807-9C28-D8F5AC3CCA78} = {B08B4E00-C2AB-48F3-8389-449F42AEF179}
{9C9FEB8E-A253-4705-A344-49BFEFC9A516} = {873BFC3E-63C2-4495-A503-5EC05DCD84E4}
{3A377A6A-F735-4010-9E00-72E8BEB8F1F2} = {9B4F139F-7D26-435C-A561-89E65A67A8E5}
{DAACE93A-866E-428E-B2A9-AFAC79F9C7A4} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
EndGlobalSection
EndGlobal

View file

@ -7,7 +7,7 @@ import {getRequest, persistRequest} from '../services/lookup-persistence';
import {WorkflowDefinition, WorkflowDefinitionSummary} from "../../workflow-definitions/models/entities";
import {OrderBy, OrderDirection, PagedList, VersionOptions, WorkflowInstanceSummary, WorkflowStatus, WorkflowSubStatus} from "../../../models";
import {Container} from "typedi";
import {WorkflowDefinitionsApi} from "../../workflow-definitions/services/api";
import {WorkflowDefinitionsApi} from "../../workflow-definitions";
import {getSubStatusColor, updateSelectedWorkflowInstances} from "../services/utils";
import {formatTimestamp} from "../../../utils";
import {DeleteIcon, EditIcon} from "../../../components/icons/tooling";
@ -68,7 +68,7 @@ export class WorkflowInstanceBrowser {
if(this.workflowDefinition != null)
this.selectedWorkflowDefinitionId = this.workflowDefinition.definitionId;
await this.loadWorkflowDefinitions();
await this.loadWorkflowInstances();
}

View file

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\bundles\Elsa\Elsa.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.EntityFrameworkCore.Sqlite\Elsa.EntityFrameworkCore.Sqlite.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.Http\Elsa.Http.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.Identity\Elsa.Identity.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.MongoDb\Elsa.MongoDb.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.Scheduling\Elsa.Scheduling.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.Workflows.Api\Elsa.Workflows.Api.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,56 @@
using Elsa.Extensions;
using Elsa.MongoDb.Extensions;
using Elsa.MongoDb.Modules.Identity;
using Elsa.MongoDb.Modules.Management;
using Elsa.MongoDb.Modules.Runtime;
var builder = WebApplication.CreateBuilder(args);
var mongoDbConnectionString = builder.Configuration.GetConnectionString("MongoDb") ?? "mongodb://localhost:27017/elsa";
// Add services to the container.
builder.Services.AddElsa(elsa =>
{
elsa.UseMongoDb(mongoDbConnectionString);
elsa.UseWorkflowManagement(management =>
{
management.UseMongoDb();
});
elsa.UseWorkflowRuntime(runtime =>
{
runtime.UseMongoDb();
runtime.UseDefaultRuntime(dr => dr.UseMongoDb());
runtime.UseExecutionLogRecords(e => e.UseMongoDb());
runtime.UseAsyncWorkflowStateExporter();
});
elsa.UseWorkflowsApi();
elsa.UseHttp();
elsa.UseScheduling();
elsa.UseIdentity(identity =>
{
identity.UseMongoDb();
identity.TokenOptions = options =>
{
options.SigningKey = "secret-token-signing-key";
options.AccessTokenLifetime = TimeSpan.FromDays(1);
};
});
elsa.UseDefaultAuthentication();
elsa.AddActivitiesFrom<Program>();
});
builder.Services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()));
var app = builder.Build();
app.UseHttpsRedirection();
app.UseCors();
app.UseAuthentication();
app.UseAuthorization();
app.UseWorkflowsApi();
app.UseWorkflows();
app.Run();

View file

@ -0,0 +1,37 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:56165",
"sslPort": 44320
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5104",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7146;http://localhost:5104",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View file

@ -0,0 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"MongoDb": "mongodb://localhost:27017/elsa"
}
}