Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
CreateFolderCommand.cs
1using System;
2using System.IO;
3using System.Threading.Tasks;
5using Waher.Things;
8
10{
15 {
16 private readonly ProgramDataFolder folderNode;
17 private readonly string sortKey;
18
25 {
26 this.folderNode = FolderNode;
27 this.sortKey = SortKey;
28 }
29
30 [Page(7, "File System", 100)]
31 [Header(42, "Folder Name:")]
32 [ToolTip(43, "Local folder name.")]
33 [Required]
34 public string FolderLocalName { get; set; }
35
39 public string CommandID => "CreateFolder";
40
44 public CommandType Type => CommandType.Parametrized;
45
49 public string SortCategory => "Edit";
50
54 public string SortKey => this.sortKey;
55
60 public Task<string> GetNameAsync(Language Language) => Language.GetStringAsync(typeof(ProgramDataSource), 44, "Create Folder...");
61
66 public Task<string> GetConfirmationStringAsync(Language Language) => Task.FromResult(string.Empty);
67
72 public Task<string> GetFailureStringAsync(Language Language) => Task.FromResult(string.Empty);
73
78 public Task<string> GetSuccessStringAsync(Language Language) => Task.FromResult(string.Empty);
79
85 public Task<bool> CanExecuteAsync(RequestOrigin Caller) => XmppServerModule.IsAdmin(Caller.From);
86
90 public Task ExecuteCommandAsync()
91 {
92 string FullPath = Path.Combine(this.folderNode.FolderName, this.FolderLocalName);
93 if (!FullPath.StartsWith(this.folderNode.FolderName, StringComparison.CurrentCultureIgnoreCase))
94 throw new Exception("Invalid local folder name.");
95
96 Directory.CreateDirectory(FullPath);
97
98 return Task.CompletedTask;
99 }
100
107
112 public ICommand Copy()
113 {
114 return new CreateFolderCommand(this.folderNode, this.sortKey);
115 }
116 }
117}
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
Task StartQueryExecutionAsync(Query Query, Language Language)
Starts the execution of a query.
Task< string > GetConfirmationStringAsync(Language Language)
Gets a confirmation string, if any, of the command. If no confirmation is necessary,...
Task< string > GetNameAsync(Language Language)
Gets the name of data source.
Task< bool > CanExecuteAsync(RequestOrigin Caller)
If the command can be executed by the caller.
Task< string > GetFailureStringAsync(Language Language)
Gets a failure string, if any, of the command. If no specific failure string is available,...
ICommand Copy()
Creates a copy of the command object.
CreateFolderCommand(ProgramDataFolder FolderNode, string SortKey)
Creates a subfolder in a folder.
Task< string > GetSuccessStringAsync(Language Language)
Gets a success string, if any, of the command. If no specific success string is available,...
Reference to a folder in the ProgramData folder of the broker.
Data source mirroring the ProgramData folder for the broker.
Service Module hosting the XMPP broker and its components.
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