Skip to main content

Task Metadata - C Sharp

A task object contains task and execution metadata.

info

Do not confuse with .NET C#'s System.Threading.Tasks.

Logic TypeAvailable
Generic logic
Aggregator logic

A task is a data process in execution. An execution is a collection of tasks invoked together by a trigger.

Import and Usage

public static class Logic
{

public static async Task Run(Context ctx)
{
var task = await ctx.GetTask();
}

public static async Task HandleError(Context ctx, Exception error)
{
// ... same
}
}

Class Reference

Type

  • LogicTask

Properties

PropertyTypeDescription
TaskKeyTaskKeyTask ID and execution ID
StartTimestampDateTimeTask start datetime
DataProcessVersionedIdentityContextData process identity metadata
CurrentLogicVersionedIdentityContextCurrent logic's identity metadata
ExecutedLogicsList<VersionedIdentityContext>A collection of identity metadata of executed logic. Returns an empty collection if none exists.

Sub Class Reference

TaskKey

Collection of task and execution ID.

PropertyTypeDescription
TaskIdUInt128Task ID
ExecutionIdUInt128Execution ID

Methods:

// convert task ID to string
public string.TaskIdString() {}

// convert task ID to byte array
public byte[] TaskIdBytes() {}

// convert execution ID to string
public string ExecutionIdString() {}

// convert execution ID to byte array
public byte[] ExecutionIdBytes() {}

VersionedIdentityContext

Describes the identity of a logic, data process or other assets in LOC.

PropertyTypeDescription
NamestringName
PermanentIdentityGuidPermanent identity (PID)
RevisionintRevision number

Examples

// get task
var task = await ctx.GetTask();

// get task ID
string taskId = task.TaskKey.TaskIdString();

// get execution ID
string executionId = task.TaskKey.ExecutionIdString();

// get current logic's PID
string logicPid = task.CurrentLogic.PermanentIdentity.ToString();

// get the last executed logic's name before current logic (null if none)
string? lastLogicName = task.ExecutedLogics.Count() > 0 ? task.ExecutedLogics[^1].Name : null;