Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
FtsFolder.cs
1using System.Threading.Tasks;
7
9{
14 {
23 public FtsFolder(ScriptNode IndexCollection, ScriptNode Folder,
25 : base(new ScriptNode[] { IndexCollection, Folder }, argumentTypes2Scalar,
27 {
28 }
29
39 public FtsFolder(ScriptNode IndexCollection, ScriptNode Folder, ScriptNode Recursive,
41 : base(new ScriptNode[] { IndexCollection, Folder, Recursive },
43 {
44 }
45
56 public FtsFolder(ScriptNode IndexCollection, ScriptNode Folder, ScriptNode Recursive, ScriptNode SubFoldersToExclude,
58 : base(new ScriptNode[] { IndexCollection, Folder, Recursive, SubFoldersToExclude },
59 new ArgumentType[] { ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Scalar, ArgumentType.Vector },
61 {
62 }
63
67 public override string FunctionName => nameof(FtsFolder);
68
72 public override string[] DefaultArgumentNames => new string[] { "IndexCollection", "Folder", "Recursive" };
73
78 public override bool IsAsynchronous => true;
79
87 {
88 return this.EvaluateAsync(Arguments, Variables).Result;
89 }
90
97 public override async Task<IElement> EvaluateAsync(IElement[] Arguments, Variables Variables)
98 {
99 int i = 0;
100 int c = Arguments.Length;
101 string Index = Arguments[i++].AssociatedObjectValue?.ToString() ?? string.Empty;
102 string Folder = Arguments[i++].AssociatedObjectValue?.ToString() ?? string.Empty;
103 bool? Recursive = i < c ? ToBoolean(Arguments[i++]) : false;
104
105 if (!Recursive.HasValue)
106 throw new ScriptRuntimeException("Expected Boolean Value for Recursive argument.", this);
107
108 string[] SubFoldersToExclude;
109
110 if (i < c)
111 {
112 if (Arguments[i] is IVector V)
113 {
114 int j, d = V.Dimension;
115
116 SubFoldersToExclude = new string[d];
117
118 for (j = 0; j < d; j++)
119 SubFoldersToExclude[j] = V.GetElement(j).AssociatedObjectValue?.ToString();
120 }
121 else
122 SubFoldersToExclude = new string[] { Arguments[i].AssociatedObjectValue?.ToString() };
123 }
124 else
125 SubFoldersToExclude = new string[0];
126
127 FolderIndexationStatistics Result = await Waher.Persistence.FullTextSearch.Search.IndexFolder(Index, Folder, Recursive.Value, SubFoldersToExclude);
128
129 return new ObjectValue(Result);
130 }
131 }
132}
Contains statistics about a files folder (re)indexation procedure.
Static class for access to Full-Text-Search
Definition: Search.cs:68
static Task< FolderIndexationStatistics > IndexFolder(string IndexCollection, string Folder, bool Recursive, params string[] ExcludeSubfolders)
Indexes or reindexes files in a folder.
Definition: Search.cs:326
Class managing a script expression.
Definition: Expression.cs:39
FtsFolder(ScriptNode IndexCollection, ScriptNode Folder, ScriptNode Recursive, ScriptNode SubFoldersToExclude, int Start, int Length, Expression Expression)
Indexes files in a folder.
Definition: FtsFolder.cs:56
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
Definition: FtsFolder.cs:78
override string[] DefaultArgumentNames
Default Argument names
Definition: FtsFolder.cs:72
FtsFolder(ScriptNode IndexCollection, ScriptNode Folder, ScriptNode Recursive, int Start, int Length, Expression Expression)
Indexes files in a folder.
Definition: FtsFolder.cs:39
override async Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: FtsFolder.cs:97
override string FunctionName
Name of the function
Definition: FtsFolder.cs:67
FtsFolder(ScriptNode IndexCollection, ScriptNode Folder, int Start, int Length, Expression Expression)
Indexes files in a folder.
Definition: FtsFolder.cs:23
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: FtsFolder.cs:86
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
static readonly ArgumentType[] argumentTypes2Scalar
Two scalar parameters.
static readonly ArgumentType[] argumentTypes3Scalar
Three scalar parameters.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
static ? bool ToBoolean(IElement Value)
Tries to convert an element to a boolean value.
Definition: ScriptNode.cs:375
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
override string ToString()
Definition: ScriptNode.cs:359
Expression Expression
Expression of which the node is a part.
Definition: ScriptNode.cs:177
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
Basic interface for vectors.
Definition: IVector.cs:9
ArgumentType
Type of parameter used in a function definition or a lambda definition.
Definition: IFunction.cs:9
Definition: App.xaml.cs:4