2using System.Threading.Tasks;
65 public override Task
Parse(XmlElement Xml)
70 return base.Parse(Xml);
80 if (this.value is
null)
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 OnDateTime event definition: " + TimeCoordinates,
125 Value = 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.
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.
Event raised after a certain date and time.
string ValueDefinition
Value definition.
string TimeCoordinatesDefinition
Time Coordinates definition.
override string Label
UML Label for event.
override async Task< EventTimepointUtc > GetEventTimepointUtc(EvaluationArguments Arguments)
Gets the timepoint for when the event elapses.
override string LocalName
Local name
override Task Parse(XmlElement Xml)
Parses the State-machine node.
override IStateMachineNode Create()
Creates a new node of the corresponding type.
OnDateTime()
Event raised after a certain date and time.
Contains information about when a timed event elapses, in UTC time coordinates.
Abstract base class for timed State-Machine event nodes.
Interface for State-Machine nodes