2using System.Collections.Generic;
4using System.Threading.Tasks;
19 : base(
"/SendOperatorMessage")
23 public override bool HandlesSubPaths =>
false;
24 public override bool UserSessions =>
true;
35 if (!(Obj is Dictionary<string, object> Form))
38 if (!Form.TryGetValue(
"message", out Obj) || !(Obj is
string Message) ||
39 !Form.TryGetValue(
"from", out Obj) || !(Obj is
string From) ||
40 !Form.TryGetValue(
"to", out Obj) || !(Obj is
string To) ||
41 !Form.TryGetValue(
"logObject", out Obj) || !(Obj is
string LogObject))
63 StringBuilder Content =
new StringBuilder();
65 Content.Append(
"<subject>Message from operator.</subject>");
66 Content.Append(
"<body>");
68 Content.Append(
"</body>");
73 DateTime Now = DateTime.Now;
76 new KeyValuePair<string, object>(
"From", From),
77 new KeyValuePair<string, object>(
"To", To));
79 Response.StatusCode = 200;
83 {
"date", Now.ToShortDateString() },
84 {
"time", Now.ToLongTimeString() },
85 {
"type", EventType.Informational },
86 {
"object", LogObject },
87 {
"actor", User.UserName },
88 {
"message", XML.HtmlValueEncode(Message).Replace(
"\r\n",
"\n").Replace(
"\n",
"<br/>") }
Helps with common JSON-related tasks.
static string Encode(string s)
Encodes a string for inclusion in JSON.
const string DefaultContentType
application/json
Helps with common XML-related tasks.
static string Encode(string s)
Encodes a string for use in XML.
Static class managing the application event log. Applications and services log events on this static ...
static void Informational(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an informational event.
Base class for objects that can log events.
Static class managing the runtime environment of the IoT Gateway.
static IUser AssertUserAuthenticated(HttpRequest Request, string Privilege)
Makes sure a request is being made from a session with a successful user login.
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
bool HasData
If the request has data.
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Represets a response of an HTTP client request.
async Task Write(byte[] Data)
Returns binary data in the response.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
Base class for components.
bool IsComponentDomain(CaseInsensitiveString Domain, bool IncludeAlternativeDomains)
Checks if a domain is the component domain, or optionally, an alternative component domain.
Contains information about one XMPP address.
override string ToString()
object.ToString()
Task< bool > SendMessage(string Type, string Id, string From, string To, string Language, string ContentXml)
Sends a Message stanza to a recipient.
bool IsServerDomain(CaseInsensitiveString Domain, bool IncludeAlternativeDomains)
Checks if a domain is the server domain, or optionally, an alternative domain.
IComponent[] Components
Registered components
bool AllowsPOST
If the POST method is allowed.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
Service Module hosting the XMPP broker and its components.
POST Interface for HTTP resources.
Interface for components.
Basic interface for a user.
string UserName
User Name.