Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ExecuteJob.cs
1using System;
2using System.Threading.Tasks;
3using Waher.Events;
6using Waher.Things;
9
10namespace Waher.Jobs.Commands
11{
15 public class ExecuteJob : ICommand
16 {
17 private readonly Job node;
18
23 public ExecuteJob(Job Node)
24 {
25 this.node = Node;
26 }
27
31 public string CommandID => nameof(ExecuteJob);
32
36 public CommandType Type => CommandType.Query;
37
41 public string SortCategory => "Execution";
42
46 public string SortKey => nameof(ExecuteJob);
47
51 [Page(16, "Job", 0)]
52 [Header(17, "Report Detail:")]
53 [ToolTip(18, "How much detail to include in job reports.")]
54 [Option(JobReportDetail.Summary, 19, "Return summary information only.")]
55 [Option(JobReportDetail.Details, 20, "Return detailed information.")]
56 public JobReportDetail ReportDetail { get; set; } = JobReportDetail.Details;
57
63 public Task<bool> CanExecuteAsync(RequestOrigin Caller)
64 {
65 return this.node.CanEditAsync(Caller);
66 }
67
72 public ICommand Copy()
73 {
74 return new ExecuteJob(this.node);
75 }
76
80 public Task ExecuteCommandAsync()
81 {
82 return Task.CompletedTask;
83 }
84
89 public Task<string> GetNameAsync(Language Language)
90 {
91 return Language.GetStringAsync(typeof(ExecuteJob), 13, "Execute Job once...");
92 }
93
99 {
100 return Task.FromResult(string.Empty);
101 }
102
108 {
109 return Task.FromResult(string.Empty);
110 }
111
117 {
118 return Language.GetStringAsync(typeof(ExecuteJob), 15, "Unable to start the execution of the job.");
119 }
120
127 {
128 Task.Run(async () =>
129 {
130 try
131 {
132 try
133 {
134 await this.node.ExecuteJob(Query, Language, this.ReportDetail);
135 await this.node.RemoveErrorAsync("ExecutionError");
136 }
137 catch (Exception ex)
138 {
139 await this.node.LogErrorAsync("ExecutionError", ex.Message);
140 }
141 }
142 catch (Exception ex)
143 {
144 Log.Exception(ex);
145 }
146 });
147
148 return Task.CompletedTask;
149 }
150 }
151}
Static class managing the application event log. Applications and services log events on this static ...
Definition: Log.cs:14
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Definition: Log.cs:1657
ExecuteJob(Job Node)
Executes a job.
Definition: ExecuteJob.cs:23
Task< string > GetSuccessStringAsync(Language Language)
Gets a success string, if any, of the command. If no specific success string is available,...
Definition: ExecuteJob.cs:98
JobReportDetail ReportDetail
How much detail to include in job reports.
Definition: ExecuteJob.cs:56
string CommandID
ID of command.
Definition: ExecuteJob.cs:31
Task StartQueryExecutionAsync(Query Query, Language Language)
Starts the execution of a query.
Definition: ExecuteJob.cs:126
CommandType Type
Type of command.
Definition: ExecuteJob.cs:36
ICommand Copy()
Creates a copy of the command object.
Definition: ExecuteJob.cs:72
string SortCategory
Sort Category, if available.
Definition: ExecuteJob.cs:41
Task< string > GetFailureStringAsync(Language Language)
Gets a failure string, if any, of the command. If no specific failure string is available,...
Definition: ExecuteJob.cs:116
Task< bool > CanExecuteAsync(RequestOrigin Caller)
If the command can be executed by the caller.
Definition: ExecuteJob.cs:63
Task ExecuteCommandAsync()
Executes the command.
Definition: ExecuteJob.cs:80
Task< string > GetNameAsync(Language Language)
Gets the displayable name of the command.
Definition: ExecuteJob.cs:89
Task< string > GetConfirmationStringAsync(Language Language)
Gets a confirmation string, if any, of the command. If no confirmation is necessary,...
Definition: ExecuteJob.cs:107
string SortKey
Sort Key, if available.
Definition: ExecuteJob.cs:46
Represents a job.
Definition: Job.cs:21
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
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
JobReportDetail
How much detail to include in job reports.
CommandType
Command type.
Definition: ICommand.cs:11