SolTechnology.Core.Flow
0.5.0
See the version list below for details.
dotnet add package SolTechnology.Core.Flow --version 0.5.0
NuGet\Install-Package SolTechnology.Core.Flow -Version 0.5.0
<PackageReference Include="SolTechnology.Core.Flow" Version="0.5.0" />
<PackageVersion Include="SolTechnology.Core.Flow" Version="0.5.0" />
<PackageReference Include="SolTechnology.Core.Flow" />
paket add SolTechnology.Core.Flow --version 0.5.0
#r "nuget: SolTechnology.Core.Flow, 0.5.0"
#:package SolTechnology.Core.Flow@0.5.0
#addin nuget:?package=SolTechnology.Core.Flow&version=0.5.0
#tool nuget:?package=SolTechnology.Core.Flow&version=0.5.0
Overview
The SolTechnology.Core.Flow library provides a workflow and chain framework with support for pausable flows. It enables building complex, multi-step workflows that can be paused and resumed, with state persistence using either in-memory or SQLite storage.
Registration
For installing the library, reference SolTechnology.Core.Flow nuget package and invoke AddFlowFramework() service collection extension method:
services.AddFlowFramework();
Configuration
By default, the library uses SQLite for persistence. You can customize the repository implementation:
// Use in-memory storage (for testing)
services.AddScoped<IFlowInstanceRepository, InMemoryFlowInstanceRepository>();
// Or use SQLite (default)
services.AddScoped<IFlowInstanceRepository, SqliteFlowInstanceRepository>();
Usage
- Define Flow Context
public class MyFlowContext : FlowContext<MyInput, MyOutput>
{
public string CurrentStepData { get; set; }
}
- Define Flow Steps
Automated steps run without user interaction:
public class ProcessDataStep : AutomatedFlowStep<MyFlowContext>
{
public override async Task Execute(MyFlowContext context)
{
// Automated processing logic
context.CurrentStepData = "processed";
}
}
Interactive steps pause and wait for user input:
public class AwaitUserApprovalStep : InteractiveFlowStep<MyFlowContext>
{
public override async Task Execute(MyFlowContext context)
{
// Logic before pausing
context.CurrentStepData = "awaiting approval";
// Flow pauses here, waiting for resume
}
public override async Task Resume(MyFlowContext context)
{
// Logic after user provides input
// Access user input from context
}
}
- Define Flow Handler
public class MyFlowHandler : PausableChainHandler<MyInput, MyFlowContext, MyOutput>
{
protected override async Task HandleChain()
{
await Invoke<ProcessDataStep>();
await Invoke<AwaitUserApprovalStep>(); // Flow pauses here
await Invoke<FinalizeStep>();
}
}
- Start a Flow
var flowManager = serviceProvider.GetRequiredService<FlowManager>();
var input = new MyInput { Data = "initial data" };
var flowInstance = await flowManager.StartFlow<MyFlowHandler>(input);
- Resume a Paused Flow
// Get the flow instance ID from the initial start
var flowInstanceId = flowInstance.Id;
// Provide user input
var userInput = new Dictionary<string, object>
{
{ "approved", true },
{ "comment", "Looks good!" }
};
await flowManager.ResumeFlow(flowInstanceId, userInput);
- Check Flow Status
var status = await flowManager.GetFlowStatus(flowInstanceId);
switch (status)
{
case FlowStatus.Running:
// Flow is currently executing
break;
case FlowStatus.Paused:
// Flow is paused, waiting for input
break;
case FlowStatus.Completed:
// Flow has finished successfully
break;
case FlowStatus.Failed:
// Flow encountered an error
break;
}
- Use Flow Controller (Optional)
The library includes a FlowController for HTTP API integration:
// Start flow via HTTP POST
POST /api/flow/start
{
"flowType": "MyFlowHandler",
"input": { "data": "initial data" }
}
// Resume flow via HTTP POST
POST /api/flow/resume/{flowInstanceId}
{
"approved": true,
"comment": "Looks good!"
}
// Get flow status via HTTP GET
GET /api/flow/status/{flowInstanceId}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.Data.Sqlite.Core (>= 9.0.5)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Newtonsoft.Json (>= 13.0.3)
- SolTechnology.Core.CQRS (>= 0.5.0)
- SQLitePCLRaw.bundle_green (>= 2.1.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.