Class BaseTriggerTask
The base task for implementing any type of custom action that runs as a task against a IActionTrigger task
Inherited Members
Namespace: LemonEdge.API.Core.Tasks.Processors.Triggers
Assembly: LemonEdge.API.dll
Syntax
public abstract class BaseTriggerTask : ITaskProcessor, IProcessor, IDisposable
Constructors
BaseTriggerTask()
Declaration
protected BaseTriggerTask()
Properties
Action
A custom action string for matching against a TriggeredActionParameter
Declaration
protected abstract string Action { get; }
Property Value
Type | Description |
---|---|
string |
Cache
A local cache for performance
Declaration
public IReadOnlyCache Cache { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCache |
ForID
The list of entitiy ids this action is triggered against
Declaration
protected abstract Guid? ForID { get; }
Property Value
Type | Description |
---|---|
Guid? |
ForTypes
The types of entities this action is triggered against
Declaration
protected abstract Guid[] ForTypes { get; }
Property Value
Type | Description |
---|---|
Guid[] |
Param
The trigger action parameters inheriting from BaseTriggerParameter
Declaration
protected ServerTaskParameter Param { get; }
Property Value
Type | Description |
---|---|
ServerTaskParameter |
Reporter
A reporter to provide feedback to a log, or client depending on the context the process is running under
Declaration
public BusyProgressReporter Reporter { get; set; }
Property Value
Type | Description |
---|---|
BusyProgressReporter |
Runner
The host that is running this action trigger task
Declaration
public ITaskRunner Runner { get; }
Property Value
Type | Description |
---|---|
ITaskRunner |
TimeStamp
The timestamp of the changes that occured that triggered this action
Declaration
protected abstract DateTimeOffset? TimeStamp { get; }
Property Value
Type | Description |
---|---|
DateTimeOffset? |
TriggerID
The IActionTrigger that triggered this action
Declaration
protected abstract Guid? TriggerID { get; }
Property Value
Type | Description |
---|---|
Guid? |
TriggeredContexts
A list of the contexts that triggered this action
Declaration
protected abstract IDictionary<IActionTrigger, List<TriggerContext>> TriggeredContexts { get; }
Property Value
Type | Description |
---|---|
IDictionary<IActionTrigger, List<TriggerContext>> |
Updater
A context to ensure the process can query, load and modify all LemonEdge data
Declaration
public IEntityUpdater Updater { get; }
Property Value
Type | Description |
---|---|
IEntityUpdater |
User
The current logged in user the process is running under
Declaration
public UserInfo User { get; }
Property Value
Type | Description |
---|---|
UserInfo |
Methods
Dispose()
Declaration
public void Dispose()
Dispose(bool)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
Init(ITaskRunner, ServerTaskParameter)
Initializes the task processor with the trigger action parameters for processing the task
Declaration
public Task Init(ITaskRunner runner, ServerTaskParameter ProcessTaskParameter)
Parameters
Type | Name | Description |
---|---|---|
ITaskRunner | runner | The context within which the task is being processed |
ServerTaskParameter | ProcessTaskParameter | The trigger action parameters inheriting from BaseTriggerParameter |
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |
ProcessTask(CancellationToken)
If TriggeredContexts is null then this is the IActionTrigger task that determines which, if any, actions should be triggered.
It then populates TriggeredContexts for every matching action, and creates the appropriate triggered action task to process the action. These tasks inherit from BaseTriggerTask too, and are marked with TriggerTask
Each triggered action task has its TriggeredContexts set to the contexts that created the action, passes the parameters from TriggeredActionParameter and executes the action.Both then call ProcessTriggers(IDictionary<IActionTrigger, List<TriggerContext>>, CancellationToken) with the TriggeredContexts values (either calculated or passed)
All implementations simply have to implement ProcessTriggers to perform the custom action required now IActionTrigger has triggered themDeclaration
public Task<object> ProcessTask(CancellationToken cancel)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancel |
Returns
Type | Description |
---|---|
Task<object> |
ProcessTriggers(IDictionary<IActionTrigger, List<TriggerContext>>, CancellationToken)
Processes the items that have been triggered by the IActionTrigger
Declaration
protected abstract Task ProcessTriggers(IDictionary<IActionTrigger, List<TriggerContext>> triggeredItem, CancellationToken cancel)
Parameters
Type | Name | Description |
---|---|---|
IDictionary<IActionTrigger, List<TriggerContext>> | triggeredItem | A dictionary of each triggered item and the contexts that triggered it |
CancellationToken | cancel | A cancellation token for cancelling the task process |
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the operation |