Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LogMessage.cs
1using System;
2using System.Threading.Tasks;
7
9{
13 public class LogMessage : ICommand
14 {
15 private readonly MeteringNode node;
16 private MessageType messageType = MessageType.Information;
17 private string messageBody = string.Empty;
18
24 {
25 this.node = Node;
26 }
27
31 [Page(100, "Message")]
32 [Header(101, "Type:")]
33 [ToolTip(102, "Type of message to log.")]
34 [Required]
36 {
37 get => this.messageType;
38 set => this.messageType = value;
39 }
40
44 [Page(100, "Message")]
45 [Header(103, "Body:")]
46 [ToolTip(104, "Text of the message to log.")]
47 [Required]
48 public string MessageBody
49 {
50 get => this.messageBody;
51 set => this.messageBody = value;
52 }
53
57 public string CommandID => nameof(LogMessage);
58
62 public CommandType Type => CommandType.Parametrized;
63
67 public string SortCategory => "Node";
68
72 public string SortKey => "LogMessage";
73
79 public Task<bool> CanExecuteAsync(RequestOrigin Caller)
80 {
81 return this.node.CanEditAsync(Caller);
82 }
83
88 public ICommand Copy()
89 {
90 return new LogMessage(this.node);
91 }
92
96 public Task ExecuteCommandAsync()
97 {
98 return this.node.LogMessageAsync(this.messageType, this.messageBody);
99 }
100
105 public Task<string> GetNameAsync(Language Language)
106 {
107 return Language.GetStringAsync(typeof(MeteringTopology), 105, "Log message...");
108 }
109
115 {
116 return Language.GetStringAsync(typeof(MeteringTopology), 106, "Message successfully logged.");
117 }
118
124 {
125 return Task.FromResult(string.Empty);
126 }
127
133 {
134 return Language.GetStringAsync(typeof(MeteringTopology), 107, "Unable to log message.");
135 }
136
143 {
144 return Task.CompletedTask;
145 }
146 }
147}
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
LogMessage(MeteringNode Node)
Logs a message on a node.
Definition: LogMessage.cs:23
Task< string > GetSuccessStringAsync(Language Language)
Gets a success string, if any, of the command. If no specific success string is available,...
Definition: LogMessage.cs:114
Task< string > GetFailureStringAsync(Language Language)
Gets a failure string, if any, of the command. If no specific failure string is available,...
Definition: LogMessage.cs:132
string SortCategory
Sort Category, if available.
Definition: LogMessage.cs:67
Task< string > GetNameAsync(Language Language)
Gets the name of data source.
Definition: LogMessage.cs:105
string SortKey
Sort Key, if available.
Definition: LogMessage.cs:72
Task StartQueryExecutionAsync(Query Query, Language Language)
Starts the execution of a query.
Definition: LogMessage.cs:142
Task ExecuteCommandAsync()
Executes the command.
Definition: LogMessage.cs:96
CommandType Type
Type of command.
Definition: LogMessage.cs:62
Task< bool > CanExecuteAsync(RequestOrigin Caller)
If the command can be executed by the caller.
Definition: LogMessage.cs:79
Task< string > GetConfirmationStringAsync(Language Language)
Gets a confirmation string, if any, of the command. If no confirmation is necessary,...
Definition: LogMessage.cs:123
ICommand Copy()
Creates a copy of the command object.
Definition: LogMessage.cs:88
Base class for all metering nodes.
Definition: MeteringNode.cs:28
Defines the Metering Topology data source. This data source contains a tree structure of persistent r...
Class handling the reception of data from a query.
Definition: Query.cs:12
Tokens available in request.
Definition: RequestOrigin.cs:9
Interface for commands.
Definition: ICommand.cs:32
CommandType
Command type.
Definition: ICommand.cs:11