Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ScheduleAction.cs
1using System;
2using System.Threading.Tasks;
3
5{
10 {
11 private When when;
12
17 : base()
18 {
19 }
20
24 public When When => this.when;
25
29 public override string LocalName => nameof(ScheduleAction);
30
35 public override IStateMachineNode Create()
36 {
37 return new ScheduleAction();
38 }
39
43 protected override void OnChildNodesUpdated()
44 {
45 base.OnChildNodesUpdated();
46
47 this.when = this.GetChildElement<When>(true);
48 }
49
54 public async Task Execute(EvaluationArguments Arguments)
55 {
56 DateTime Timepoint = await this.when.CalcWhenUtc(Arguments);
57
58 if (Timepoint <= DateTime.UtcNow)
59 await this.ExecuteNoLog(Arguments, false);
60 else
61 {
62 string ActionId = await this.GetReference(Arguments);
63 await ScheduledAction.Schedule(Arguments.Machine.StateMachineId, Timepoint,
64 ActionId, this.BeforeActionScript);
65 }
66 }
67 }
68}
Abstract base class for nodes referencing an action.
async Task ExecuteNoLog(EvaluationArguments Arguments, bool SuppressProfiling)
Evaluates an action, without logging the time the action took as a sample value.
Task< string > GetReference(EvaluationArguments Arguments)
Evaluates the reference.
override void OnChildNodesUpdated()
Method called whenever ChildNodes is updated.
override IStateMachineNode Create()
Creates a new node of the corresponding type.
async Task Execute(EvaluationArguments Arguments)
Evaluates the action node
Defines when an action is to be executed.
Definition: When.cs:15
async Task< DateTime > CalcWhenUtc(EvaluationArguments Arguments)
Calculates the point in time when an action is to be executed.
Definition: When.cs:78
Contains information required for evaluating script in a state-machine.
StateMachine Machine
Reference to state-machine definition.
CaseInsensitiveString StateMachineId
ID of State Machine.
Definition: StateMachine.cs:57