Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NodeUpdated.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
7
9{
14 {
15 private string oldId = string.Empty;
16
20 public NodeUpdated()
21 : base()
22 {
23 }
24
31 public static Task<NodeUpdated> FromNode(INode Node, Language Language, RequestOrigin Caller)
32 {
33 return FromNode(Node, Language, Caller, string.Empty, null);
34 }
35
43 public static Task<NodeUpdated> FromNode(INode Node, Language Language, RequestOrigin Caller,
44 params Parameter[] AdditionalParameters)
45 {
46 return FromNode(Node, Language, Caller, string.Empty, AdditionalParameters);
47 }
48
56 public static Task<NodeUpdated> FromNode(INode Node, Language Language, RequestOrigin Caller, string OldId)
57 {
58 return FromNode(Node, Language, Caller, OldId, null);
59 }
60
69 public static async Task<NodeUpdated> FromNode(INode Node, Language Language, RequestOrigin Caller, string OldId,
70 params Parameter[] AdditionalParameters)
71 {
72 List<Parameter> Parameters = new List<Parameter>();
73
74 foreach (Parameter P in await Node.GetDisplayableParametersAsync(Language, Caller))
75 Parameters.Add(P);
76
77 if (!(AdditionalParameters is null))
78 {
79 foreach (Parameter P in AdditionalParameters)
80 Parameters.Add(P);
81 }
82
83 return new NodeUpdated()
84 {
85 OldId = OldId,
86 Parameters = Parameters.ToArray(),
87 HasChildren = Node.HasChildren,
88 ChildrenOrdered = Node.ChildrenOrdered,
89 IsReadable = Node.IsReadable,
90 IsControllable = Node.IsControllable,
91 HasCommands = Node.HasCommands,
92 ParentId = Node.Parent?.NodeId ?? string.Empty,
93 ParentPartition = Node.Parent?.Partition ?? string.Empty,
94 Updated = DateTime.Now,
95 State = Node.State,
96 NodeId = Node.NodeId,
97 Partition = Node.Partition,
98 LogId = NodeAdded.EmptyIfSame(Node.LogId, Node.NodeId),
99 LocalId = NodeAdded.EmptyIfSame(Node.LocalId, Node.NodeId),
100 SourceId = Node.SourceId,
101 Timestamp = DateTime.Now
102 };
103 }
104
108 [DefaultValueStringEmpty]
109 public string OldId
110 {
111 get => this.oldId;
112 set => this.oldId = value;
113 }
114
119 {
120 get { return SourceEventType.NodeUpdated; }
121 }
122 }
123}
Contains information about a language.
Definition: Language.cs:17
Base class for all node parameters.
Definition: Parameter.cs:10
Tokens available in request.
Definition: RequestOrigin.cs:9
static string EmptyIfSame(string Id1, string Id2)
Returns Id1 if different, string.Empty if the same.
Definition: NodeAdded.cs:93
string NodeId
Node identity.
Definition: NodeEvent.cs:29
string LogId
Log identity, if different from NodeId.
Definition: NodeEvent.cs:51
string Partition
Optional partition.
Definition: NodeEvent.cs:40
string LocalId
Local identity, if different from NodeId.
Definition: NodeEvent.cs:62
Abstract base class for all node events with parameters.
string ParentPartition
Partition of parent of node, at time of event.
string ParentId
Parent identity of node, at time of event.
bool HasChildren
If node had children, at time of event.
bool ChildrenOrdered
If node children was ordered, at time of event.
bool IsControllable
If node was controllable, at time of event.
Parameter[] Parameters
Displayable parameters.
DateTime Updated
When node was last updated, at time of event.
bool HasCommands
If node had commands, at time of event.
bool IsReadable
If node was readable, at time of event.
NodeState State
State of node, at time of event.
NodeUpdated()
Node updated event.
Definition: NodeUpdated.cs:20
static Task< NodeUpdated > FromNode(INode Node, Language Language, RequestOrigin Caller)
Creates an event object from a node object.
Definition: NodeUpdated.cs:31
override SourceEventType EventType
Type of data source event.
Definition: NodeUpdated.cs:119
static Task< NodeUpdated > FromNode(INode Node, Language Language, RequestOrigin Caller, string OldId)
Creates an event object from a node object.
Definition: NodeUpdated.cs:56
static Task< NodeUpdated > FromNode(INode Node, Language Language, RequestOrigin Caller, params Parameter[] AdditionalParameters)
Creates an event object from a node object.
Definition: NodeUpdated.cs:43
static async Task< NodeUpdated > FromNode(INode Node, Language Language, RequestOrigin Caller, string OldId, params Parameter[] AdditionalParameters)
Creates an event object from a node object.
Definition: NodeUpdated.cs:69
string OldId
If renamed, this property contains the node identity before the node was renamed.
Definition: NodeUpdated.cs:110
string SourceId
Data source identity.
Definition: SourceEvent.cs:40
DateTime Timestamp
Timestamp of event.
Definition: SourceEvent.cs:50
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
SourceEventType
Data Source event types