AAurora Workflows
Get started
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

TypeAssemblyDescription
WorkflowAurora.WorkflowsThe concrete workflow implementation. Manages the task tree, triggers, and lifecycle.
IWorkflowAurora.Workflows.ContractsInterface for the workflow. Use this for dependency injection and testing.
ManagedWorkflowAurora.Workflows.ExtensionsHigh-level host: loads .awfc bundles, manages assembly loading, and wraps IWorkflow.
WorkflowDataContextAurora.WorkflowsThe concrete data context. Created via WorkflowDataContext.Create(workflow).
IWorkflowDataContextAurora.Workflows.ContractsInterface for the data context passed to every task.

IWorkflow

The primary workflow contract. Key members:

MemberDescription
Guid IdPersistent identity of the workflow definition.
Guid InstanceIdUnique identity of this runtime instance. Changes on every instantiation.
string NameDisplay name (also the name of the root task).
int VersionSerialization version. Migrated automatically on load.
bool HasStartedtrue after StartAsync has been called at least once.
bool IsRunningtrue while the workflow is actively executing.
IList<string> TagsOptional classification tags.
IWorkflowTaskBase TaskThe 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:

PropertyTypeDescription
NamestringDisplay name shown in the designer and logs.
ContinueOnErrorboolIf true, workflow execution continues even when this task throws.
RetryEnabledboolEnables automatic retry on failure.
MaxRetriesintMaximum number of retry attempts.
RetryIntervalTimeSpanDelay between retries.
PreActionIntervalint (ms)Wait before executing the task.
PostActionIntervalint (ms)Wait after executing the task.
CustomInputVariableNamestringOverride the default input variable key.
CustomOutputVariableNamestringOverride the default output variable key.
UseGlobalScopeForInputboolRead input from the global (workflow-level) scope instead of the local scope.
UseGlobalScopeForOutputboolWrite output to the global scope.
UseParentScopeForInputboolRead input from the direct parent scope.
UseParentScopeForOutputboolWrite output to the direct parent scope.
StatusWorkflowTaskStatusAggregated status: Idle, Running, Completed, Cancelled, Error.
HasErrorbooltrue if the task ended with an exception.
LastErrorMessagestringThe message of the last exception.
ElapsedTickslongExecution duration in CPU ticks.