2using System.Threading.Tasks;
65 public override Task
Parse(XmlElement Xml)
70 return base.Parse(Xml);
80 if (this.value is
null)
81 return DateTime.UtcNow;
85 string TimeCoordinates = await this.timeCoordinates.
Evaluate(Arguments.
Variables);
87 if (!
string.IsNullOrEmpty(TimeCoordinates))
89 if (
string.Equals(TimeCoordinates,
"Local", StringComparison.OrdinalIgnoreCase))
91 if (Value.Kind == DateTimeKind.Unspecified)
92 Value =
new DateTime(Value.Ticks, DateTimeKind.Local);
94 else if (
string.Equals(TimeCoordinates,
"UTC", StringComparison.OrdinalIgnoreCase))
96 if (Value.Kind == DateTimeKind.Unspecified)
97 Value =
new DateTime(Value.Ticks, DateTimeKind.Utc);
99 else if (TimeCoordinates.StartsWith(
'-') &&
100 TimeSpan.TryParse(TimeCoordinates[1..], out TimeSpan TS))
102 if (Value.Kind == DateTimeKind.Unspecified)
104 Value =
new DateTime(Value.Ticks, DateTimeKind.Utc);
105 Value = Value.Add(TS);
108 else if ((TimeCoordinates.StartsWith(
'+') &&
109 TimeSpan.TryParse(TimeCoordinates[1..], out TS)) ||
110 TimeSpan.TryParse(TimeCoordinates, out TS))
112 if (Value.Kind == DateTimeKind.Unspecified)
114 Value =
new DateTime(Value.Ticks, DateTimeKind.Utc);
115 Value = Value.Subtract(TS);
120 Log.
Error(
"Invalid Time Coordinates in State Machine When definition: " + TimeCoordinates,
125 return Value.ToUniversalTime();
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Static class managing the application event log. Applications and services log events on this static ...
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an error event.
CaseInsensitiveString StateMachineId
ID of State-Machine.
Defines when an action is to be executed.
string ValueDefinition
Value definition.
async Task< DateTime > CalcWhenUtc(EvaluationArguments Arguments)
Calculates the point in time when an action is to be executed.
override Task Parse(XmlElement Xml)
Parses the State-machine node.
When()
Defines when an action is to be executed.
string TimeCoordinatesDefinition
Time Coordinates definition.
override string LocalName
Local name
override IStateMachineNode Create()
Creates a new node of the corresponding type.
async Task< T > Evaluate(Variables Variables)
Evaluates the attribute
string Definition
Attribute definition
Scriptable DateTime attribute.
Scriptable string attribute.
Contains information required for evaluating script in a state-machine.
CurrentState CurrentState
Current persisted state.
Variables Variables
Current set of variables.
Abstract base class for State-Machine nodes.
Interface for State-Machine nodes