Documentation
Core API
Embedding and controlling Aurora Workflows from .NET code
Installation: all libraries are available on nuget.org – start with
dotnet add package Aurora.Workflows. See the package overview for which package to reference in which scenario.Key Types
| Type | Assembly | Description |
|---|---|---|
Workflow | Aurora.Workflows | The concrete workflow implementation. Manages the task tree, triggers, and lifecycle. |
IWorkflow | Aurora.Workflows.Contracts | Interface for the workflow. Use this for dependency injection and testing. |
ManagedWorkflow | Aurora.Workflows.Extensions | High-level host: loads .awfc bundles, manages assembly loading, and wraps IWorkflow. |
WorkflowDataContext | Aurora.Workflows | The concrete data context. Created via WorkflowDataContext.Create(workflow). |
IWorkflowDataContext | Aurora.Workflows.Contracts | Interface for the data context passed to every task. |
IWorkflow
The primary workflow contract. Key members:
| Member | Description |
|---|---|
Guid Id | Persistent identity of the workflow definition. |
Guid InstanceId | Unique identity of this runtime instance. Changes on every instantiation. |
string Name | Display name (also the name of the root task). |
int Version | Serialization version. Migrated automatically on load. |
bool HasStarted | true after StartAsync has been called at least once. |
bool IsRunning | true while the workflow is actively executing. |
IList<string> Tags | Optional classification tags. |
IWorkflowTaskBase Task | The root task of the workflow tree. |
Task<IWorkflowDataContext> StartAsync(context, overrideGlobal) | Starts the workflow. Returns the final data context when the workflow finishes. |
Task StopAsync() | Signals all tasks to stop and waits for them to finish. |
Task<string> PauseAsync() | ⚠️ Experimental. Pauses execution and returns a JSON snapshot string. May not work correctly in all scenarios. |
Task ResumeAsync(string json) | ⚠️ Experimental. Resumes from a previously captured snapshot. May not work correctly in all scenarios. |
string Save(bool isSnapShot) | Serializes the workflow to a JSON string (.awf format). |
Task<IWorkflowTaskBase> AddTaskAsync(task) | Adds a task to the workflow at runtime. |
Task<IWorkflowTaskBase> RemoveTaskAsync(task) | Removes a task at runtime. |
Task<IWorkflowTaskTriggerBase> AddTriggerAsync(trigger) | Adds a trigger. |
Task<IWorkflowTaskTriggerBase> RemoveTriggerAsync(trigger) | Removes a trigger. |
bool CheckHasCompleted() | Returns true when all tasks have fully completed. |
void SetTriggerStrategy(WorkflowTriggerStrategy) | Sets sequential or parallel trigger strategy. |
Creating and Running a Workflow Programmatically
using Aurora.Workflows;
using Aurora.Workflows.Tasks;
using Microsoft.Extensions.Logging;
var loggerFactory = LoggerFactory.Create(b => b.AddConsole());
// Build the workflow
var workflow = new Workflow(loggerFactory)
{
Name = "My Workflow"
};
var setVar = new SetVariableTask
{
Name = "Set answer",
Value = "=42",
CustomOutputVariableName = "answer"
};
await workflow.AddTaskAsync(setVar);
// Run it
var context = WorkflowDataContext.Create(workflow);
await workflow.StartAsync(context);
Console.WriteLine(context["answer"]); // 42
Loading a .awfc Bundle with ManagedWorkflow
using Aurora.Workflows.Extensions.Services;
using Microsoft.Extensions.Logging;
var loggerFactory = LoggerFactory.Create(b => b.AddConsole());
var loaderService = new DotNetAssemblyLoaderProxyService(loggerFactory);
using var managed = new ManagedWorkflow(loggerFactory, loaderService);
byte[] bundle = File.ReadAllBytes("my-workflow.awfc");
managed.Load(bundle, resolvePackages: true, packageFolder: ".packages");
Console.WriteLine(managed.Name);
var context = WorkflowDataContext.Create(managed.GetWorkflow());
context["inputPath"] = @"C:\data\input.csv";
await managed.StartAsync(context);
Serializing and Loading .awf JSON
// Save to .awf
string json = workflow.Save();
File.WriteAllText("workflow.awf", json);
// Load from .awf
var loaded = Workflow.Load(File.ReadAllText("workflow.awf"));
loaded.UseLoggerFactory(loggerFactory);
IWorkflowTaskBase Common Properties
All tasks implement IWorkflowTaskBase and share these common properties:
| Property | Type | Description |
|---|---|---|
Name | string | Display name shown in the designer and logs. |
ContinueOnError | bool | If true, workflow execution continues even when this task throws. |
RetryEnabled | bool | Enables automatic retry on failure. |
MaxRetries | int | Maximum number of retry attempts. |
RetryInterval | TimeSpan | Delay between retries. |
PreActionInterval | int (ms) | Wait before executing the task. |
PostActionInterval | int (ms) | Wait after executing the task. |
CustomInputVariableName | string | Override the default input variable key. |
CustomOutputVariableName | string | Override the default output variable key. |
UseGlobalScopeForInput | bool | Read input from the global (workflow-level) scope instead of the local scope. |
UseGlobalScopeForOutput | bool | Write output to the global scope. |
UseParentScopeForInput | bool | Read input from the direct parent scope. |
UseParentScopeForOutput | bool | Write output to the direct parent scope. |
Status | WorkflowTaskStatus | Aggregated status: Idle, Running, Completed, Cancelled, Error. |
HasError | bool | true if the task ended with an exception. |
LastErrorMessage | string | The message of the last exception. |
ElapsedTicks | long | Execution duration in CPU ticks. |