3using System.Threading.Tasks;
36 : base(
"Legal/GetContract",
37 new KeyValuePair<Type,
Expression>(typeof(Dictionary<string, object>), new
Expression(jsonPattern)),
62 string ContractId = (string)Parameters[
"PContractId"].AssociatedObjectValue;
63 string FormatStr = (string)Parameters[
"PFormat"]?.AssociatedObjectValue;
64 int i = ContractId.IndexOf(
'@');
70 if (!
string.IsNullOrEmpty(FormatStr))
78 string LegalDomain = ContractId[(i + 1)..];
93 await Client.
SendIqGet(LegalDomain,
"<getContract id=\"" +
XML.
Encode(ContractId) +
"\" xmlns=\"" +
98 if (e.Ok && !((E = e.FirstElement) is
null) && E.LocalName ==
"contract")
102 ParsedContract ParsedContract = await Contract.Parse(E, XmppServerModule.Legal);
103 if (!(ParsedContract.Contract is null))
104 E = await FormatHumanReadableText(E, Format.Value, ParsedContract.Contract);
120 User.UserName +
"@" + (
Gateway.
Domain?.Value ??
string.Empty),
121 LegalDomain,
string.Empty,
"<getContract id=\"" +
XML.
Encode(ContractId) +
"\" xmlns=\"" +
126 if (e.Ok && !((E = e.FirstElement) is
null) && E.LocalName ==
"contract")
130 ParsedContract ParsedContract = await Contract.Parse(E, XmppServerModule.Legal);
131 if (!(ParsedContract.Contract is null))
132 E = await FormatHumanReadableText(E, Format.Value, ParsedContract.Contract);
151 if (E.LocalName ==
"description" ||
152 E.LocalName ==
"humanReadableText" ||
153 E.LocalName ==
"label")
173 E2 = E.OwnerDocument.CreateElement(E.Prefix, E.LocalName + Format.ToString(), E.NamespaceURI);
175 if (!
string.IsNullOrEmpty(Text.
Language))
176 E2.SetAttribute(
"xml:lang", Text.
Language);
193 E2.InnerText = await Doc.GenerateXAML();
197 E2.InnerText = await Doc.GenerateXamarinForms();
201 E2.InnerText = await Doc.GenerateSmartContractXml();
210 E2 = E.OwnerDocument.CreateElement(E.Prefix, E.LocalName, E.NamespaceURI);
212 foreach (XmlAttribute Attr
in E.Attributes)
213 E2.SetAttribute(Attr.Name, Attr.NamespaceURI, Attr.Value);
215 foreach (XmlNode N
in E.ChildNodes)
217 if (N is XmlElement E3)
218 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 ...
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...
Task Return(Exception ex)
Returns an error to the client.
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 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.
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
State of the Markdown output generator.
Class representing human-readable text.
static HumanReadableText Parse(XmlElement Xml)
Parses human readable text from a smart contract.
override async Task ToMarkdown(MarkdownOutput Markdown, MarkdownOutputState State)
Exports the human-readable text to Markdown.
string Language
Optional language
override string ToString()
Legal (digital identities, smart contracts) 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(HttpRequest Request, 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