2using System.Collections.Generic;
3using System.Threading.Tasks;
35 : base(
"Legal/GetContract",
36 new KeyValuePair<Type,
Expression>(typeof(Dictionary<string, object>), new
Expression(jsonPattern)),
61 string ContractId = (string)Parameters[
"PContractId"].AssociatedObjectValue;
62 string FormatStr = (string)Parameters[
"PFormat"]?.AssociatedObjectValue;
63 int i = ContractId.IndexOf(
'@');
69 if (!
string.IsNullOrEmpty(FormatStr))
77 string LegalDomain = ContractId.Substring(i + 1);
92 await Client.
SendIqGet(LegalDomain,
"<getContract id=\"" +
XML.
Encode(ContractId) +
"\" xmlns=\"" +
97 if (e.Ok && !((E = e.FirstElement) is
null) && E.LocalName ==
"contract")
101 ParsedContract ParsedContract = await Contract.Parse(E, XmppServerModule.Legal);
102 if (!(ParsedContract.Contract is null))
103 E = await FormatHumanReadableText(E, Format.Value, ParsedContract.Contract);
119 User.UserName +
"@" + (
Gateway.
Domain?.Value ??
string.Empty),
120 LegalDomain,
string.Empty,
"<getContract id=\"" +
XML.
Encode(ContractId) +
"\" xmlns=\"" +
125 if (e.Ok && !((E = e.FirstElement) is
null) && E.LocalName ==
"contract")
129 ParsedContract ParsedContract = await Contract.Parse(E, XmppServerModule.Legal);
130 if (!(ParsedContract.Contract is null))
131 E = await FormatHumanReadableText(E, Format.Value, ParsedContract.Contract);
150 if (E.LocalName ==
"description" ||
151 E.LocalName ==
"humanReadableText" ||
152 E.LocalName ==
"label")
164 E2 = E.OwnerDocument.CreateElement(E.Prefix, E.LocalName + Format.ToString(), E.NamespaceURI);
166 if (!
string.IsNullOrEmpty(Text.
Language))
167 E2.SetAttribute(
"xml:lang", Text.
Language);
184 E2.InnerText = await Doc.GenerateXAML();
188 E2.InnerText = await Doc.GenerateXamarinForms();
192 E2.InnerText = await Doc.GenerateSmartContractXml();
201 E2 = E.OwnerDocument.CreateElement(E.Prefix, E.LocalName, E.NamespaceURI);
203 foreach (XmlAttribute Attr
in E.Attributes)
204 E2.SetAttribute(Attr.Name, Attr.NamespaceURI, Attr.Value);
206 foreach (XmlNode N
in E.ChildNodes)
208 if (N is XmlElement E3)
209 E2.AppendChild(await FormatHumanReadableText(E3, Format,
Contract));
static string GetBody(string Html)
Extracts the contents of the BODY element in a HTML string.
Contains a markdown document. This markdown document class supports original markdown,...
Task< string > GenerateMarkdown()
Generates Markdown from the markdown text.
async Task< string > GeneratePlainText()
Generates Plain Text from the markdown text.
async Task< string > GenerateHTML()
Generates HTML from the markdown text.
static Task< MarkdownDocument > CreateAsync(string MarkdownText, params Type[] TransparentExceptionTypes)
Contains a markdown document. This markdown document class supports original markdown,...
A Named dictionary is a dictionary, with a local name and a namespace. Use it to return content that ...
Static class managing loading of resources stored as embedded resources or in content files.
static string LoadResourceAsText(string ResourceName)
Loads a text resource from an embedded resource.
Helps with common XML-related tasks.
static string Encode(string s)
Encodes a string for use in XML.
Static class managing the runtime environment of the IoT Gateway.
static CaseInsensitiveString Domain
Domain name.
static XmppClient XmppClient
XMPP Client connection of gateway.
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
async Task Return(object Object)
Returns an object to the client. This method can only be called once per response,...
The server is currently unable to handle the request due to a temporary overloading or maintenance of...
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
static XmppException GetExceptionObject(XmlElement StanzaElement)
Gets an XMPP Exception object corresponding to its XML definition.
Task< uint > SendIqGet(string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Sends an IQ Get request.
Static class that dynamically manages types and interfaces available in the runtime environment.
static bool TryGetModuleParameter(string Name, out object Value)
Tries to get a module parameter value.
Class managing a script expression.
Contains the definition of a contract
Class representing human-readable text.
static HumanReadableText Parse(XmlElement Xml)
Parses human readable text from a smart contract.
override void ToMarkdown(MarkdownOutput Markdown, Contract Contract, int Level, int Indentation)
Exports the human-readable text to Markdown.
string Language
Optional language
override string ToString()
Provisioning and registry service component.
static string NamespaceSmartContracts(NamespaceSet Version)
Returns the namespace for smart contracts.
Abstract base class for agent resources supporting the POST method.
static AccountUser AssertUserAuthenticated(HttpRequest Request)
Makes sure the request is made by an authenticated API user.
const string AgentNamespace
https://waher.se/Schema/BrokerAgent.xsd
static Exception ToHttpException(XmppException ex)
Tries to convert an XMPP Exception to an HTTP Exception.
GetContract()
Gets a smart contract.
override bool Synchronous
If the resource is synchronous (i.e. returns a response in the method handler), or if it is asynchron...
override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.
Service Module hosting the XMPP broker and its components.
ReportFormat
Desired report format
NamespaceSet
Namespace versions