2using System.Threading.Tasks;
66 public override Task
Parse(XmlElement Xml)
71 return base.Parse(Xml);
81 if (this.value is
null)
86 string TimeCoordinates = await this.timeCoordinates.
Evaluate(Arguments.
Variables);
87 DateTime UtcNow = DateTime.UtcNow;
90 if (
string.IsNullOrEmpty(TimeCoordinates) ||
91 string.Equals(TimeCoordinates,
"Local", StringComparison.OrdinalIgnoreCase))
93 Value = DateTime.Today.Add(TS);
95 else if (
string.Equals(TimeCoordinates,
"UTC", StringComparison.OrdinalIgnoreCase))
97 Value = UtcNow.Date.Add(TS);
99 else if (TimeCoordinates.StartsWith(
'-') &&
100 TimeSpan.TryParse(TimeCoordinates[1..], out TimeSpan TS2))
102 Value = UtcNow.Date.Add(TS).Add(TS2);
104 else if ((TimeCoordinates.StartsWith(
'+') &&
105 TimeSpan.TryParse(TimeCoordinates[1..], out TS2)) ||
106 TimeSpan.TryParse(TimeCoordinates, out TS2))
108 Value = UtcNow.Date.Add(TS).Subtract(TS2);
112 Value = DateTime.Today.Add(TS);
114 Log.
Error(
"Invalid Time Coordinates in State Machine OnTime event definition: " + TimeCoordinates,
118 Value = Value.ToUniversalTime();
121 Value = Value.AddDays(Math.Ceiling(UtcNow.Subtract(Value).TotalDays));
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 string attribute.
Scriptable TimeSpan attribute.
Contains information required for evaluating script in a state-machine.
CurrentState CurrentState
Current persisted state.
Variables Variables
Current set of variables.
Event raised at a certain time.
override string Label
UML Label for event.
override async Task< EventTimepointUtc > GetEventTimepointUtc(EvaluationArguments Arguments)
Gets the timepoint for when the event elapses.
string TimeCoordinatesDefinition
Time Coordinates definition.
override IStateMachineNode Create()
Creates a new node of the corresponding type.
override Task Parse(XmlElement Xml)
Parses the State-machine node.
string ValueDefinition
Value definition.
override string LocalName
Local name
OnTime()
Event raised at a certain 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
Represents a duration value, as defined by the xsd:duration data type: http://www....
static Duration FromDays(int Days)
Creates a Duration object from a given number of days.