4using System.Threading.Tasks;
6using System.Xml.Schema;
24 private const string ReportFileLocalName =
"Report";
25 private const string ReportFileNamespace =
"http://waher.se/Schema/ReportFile.xsd";
29 private readonly
string fileName;
30 private readonly
string title;
31 private readonly
string @
namespace;
32 private readonly
string origin;
33 private readonly
string[] privileges;
47 XSL.
Validate(Path.GetFileName(
FileName), Doc, ReportFileLocalName, ReportFileNamespace, schema);
49 List<ReportParameter>
Parameters =
new List<ReportParameter>();
51 List<ReportAction>
Content =
new List<ReportAction>();
52 this.title =
string.Empty;
53 this.@
namespace = XML.Attribute(Doc.DocumentElement,
"namespace");
54 this.origin =
XML.
Attribute(Doc.DocumentElement,
"originVariable",
"origin");
56 foreach (XmlNode N
in Doc.DocumentElement.ChildNodes)
58 if (!(N is XmlElement E))
64 this.title = E.InnerText;
68 Privileges.Add(E.InnerText);
72 foreach (XmlNode N2
in E.ChildNodes)
74 if (!(N2 is XmlElement E2))
152 throw new NotSupportedException(
"Unrecognized parameter type: " + N2.LocalName);
158 this.ParseActions(Content, N);
162 throw new NotSupportedException(
"Unrecognized report element: " + E.LocalName);
166 this.privileges = Privileges.ToArray();
168 this.content = Content.ToArray();
173 List<ReportAction> Actions =
new List<ReportAction>();
174 this.ParseActions(Actions, Container, out
_, out
_);
175 return Actions.ToArray();
181 List<ReportAction> Actions =
new List<ReportAction>();
182 this.ParseActions(Actions, Container, out Catch, out Finally);
183 return Actions.ToArray();
186 private void ParseActions(List<ReportAction> Actions, XmlNode Container)
188 this.ParseActions(Actions, Container, out
_, out
_);
191 private void ParseActions(List<ReportAction> Actions, XmlNode Container,
194 List<ReportAction> Catch2 =
null;
195 List<ReportAction> Finally2 =
null;
197 foreach (XmlNode N
in Container.ChildNodes)
199 if (!(N is XmlElement E))
212 case "TableComplete":
225 Actions.Add(
new Message(E,
this));
229 Actions.Add(
new Status(E,
this));
233 Actions.Add(
new Section(E,
this));
241 Actions.Add(
new While(E,
this));
245 Actions.Add(
new Do(E,
this));
249 Actions.Add(
new ForEach(E,
this));
253 Actions.Add(
new Try(E,
this));
257 Catch2 ??=
new List<ReportAction>();
258 this.ParseActions(Catch2, N);
262 Finally2 ??=
new List<ReportAction>();
263 this.ParseActions(Finally2, N);
267 throw new NotSupportedException(
"Unrecognized report action: " + E.LocalName);
271 Catch = Catch2?.ToArray();
272 Finally = Finally2?.ToArray();
310 if (!
string.IsNullOrEmpty(this.origin))
331 if (!
string.IsNullOrEmpty(this.origin))
347 if (!
string.IsNullOrEmpty(this.@
namespace))
350 if (!
string.IsNullOrEmpty(this.origin))
353 if (!
string.IsNullOrEmpty(this.title))
354 await State.
Query.SetTitle(this.title);
357 await Action.Execute(State);
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
static XmlDocument LoadFromFile(string FileName)
Loads an XML document from a file.
Static class managing loading of XSL resources stored as embedded resources or in content files.
static XmlSchema LoadSchema(string ResourceName)
Loads an XML schema from an embedded resource.
static void Validate(string ObjectID, XmlDocument Xml, params XmlSchema[] Schemas)
Validates an XML document given a set of XML schemas.
Static class managing editable parameters in objects. Editable parameters are defined by using the at...
Defines conditional execution in a report.
Creates a table in the report
Defines a do-loop in a report.
Defines a for each-loop in a report.
Includes an object into the report.
Executes script when report is being executed.
Defines a section in the report.
Reports a status message.
Reports a table to be complete.
Reports records to a table.
Defines a TRY...CATCH...FINALLY statement in a report.
Defines a while-loop in a report.
Represents a Boolean-valued parameter.
Represents a color-valued parameter.
Represents a Date-valued parameter.
Represents a DateTime-valued parameter.
Represents a Double-valued parameter.
Represents a fixed-valued parameter.
Represents a Int16-valued parameter.
Represents a Int32-valued parameter.
Represents a Int64-valued parameter.
Represents a Int8-valued parameter.
Represents a Jid-valued parameter.
Represents a multiple JIDs-valued parameter.
Represents a password-valued parameter.
Represents a String-valued parameter.
Represents a text-valued parameter.
Represents a Time-valued parameter.
Represents a Uri-valued parameter.
Abstract base class for report actions.
Contains a parsed report, as defined in a report file.
ReportFile(string FileName)
Contains a parsed report, as defined in a report file.
async Task< SetEditableFormResult > SetParameters(DataForm Parameters, Language Language, bool OnlySetChanged, Variables Variables, IRequestOrigin Origin)
Sets the parameters of the object, based on contents in the data form.
string FileName
File name of report.
string[] Privileges
Privileges required to execute the report.
async Task PopulateForm(DataForm Parameters, Language Language, Variables Variables, IRequestOrigin Origin)
Populates a data form with parameters for the object.
ReportAction[] Content
Content of report.
async Task< bool > Execute(ReportState State)
Executes the report action.
string Title
Title of report.
Abstract base class for report parameters.
abstract Task SetParameter(DataForm Parameters, Language Language, bool OnlySetChanged, Variables Variables, SetEditableFormResult Result)
Sets the parameters of the object, based on contents in the data form.
abstract Task PopulateForm(DataForm Parameters, Language Language, Variables Variables)
Populates a data form with parameters for the object.
Class containing the state of a report.
Variables Variables
Current set of variables.
Query Query
Current query object reference.
RequestOrigin Origin
Origin of request to generate report.
Language Language
Preferred language.
Report node based on the contents of a report file.
Contains information about a language.
async Task< Namespace > GetNamespaceAsync(string Name)
Gets the namespace object, given its name, if available.
Contains information about a namespace in a language.
Interface for requestors that can act as an origin for distributed requests.