Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MailMessage.cs
1using System.Threading.Tasks;
2using System.Xml;
6
8{
12 public class MailMessage : ActionNode
13 {
14 private To to;
15 private Subject subject;
16 private Notes.Content content;
17
21 public MailMessage()
22 : base()
23 {
24 }
25
29 public To To => this.to;
30
34 public Subject Subject => this.subject;
35
39 public Notes.Content Content => this.content;
40
44 public override string LocalName => nameof(MailMessage);
45
50 public override IStateMachineNode Create()
51 {
52 return new MailMessage();
53 }
54
59 public override async Task Parse(XmlElement Xml)
60 {
61 await base.Parse(Xml);
62
64 new System.Type[]
65 {
66 typeof(To),
67 typeof(Subject),
68 typeof(Notes.Content)
69 },
70 new bool[]
71 {
72 true,
73 true,
74 true
75 });
76 }
77
81 protected override void OnChildNodesUpdated()
82 {
83 base.OnChildNodesUpdated();
84
85 this.to = this.GetValueElement<To>();
86 this.subject = this.GetValueElement<Subject>();
87 this.content = this.GetValueElement<Notes.Content>();
88 }
89
94 public override async Task Execute(EvaluationArguments Arguments)
95 {
96 string To = (await this.to.Evaluate(Arguments))?.ToString();
97 string Subject = ((await this.subject.Evaluate(Arguments))?.ToString()) ?? "N/A";
98 object Content = await this.content.Evaluate(Arguments);
99 MarkdownSettings Settings = null;
100
101 if (!(Content is string Markdown))
102 {
103 if (Content is null)
104 Markdown = "N/A";
106 {
107 Markdown = MarkdownContent.Markdown;
108 Settings = MarkdownContent.Settings;
109 }
110 else
111 Markdown = Content.ToString();
112 }
113
114 int? HeaderEndPos = MarkdownDocument.HeaderEndPosition(Markdown);
115 bool HasHeader = HeaderEndPos.HasValue && HeaderEndPos.Value > 0;
116
117 Settings ??= new MarkdownSettings(Gateway.Emoji1_24x24, HasHeader, Arguments.Variables);
118 Markdown = await MarkdownDocument.Preprocess(Markdown, Settings);
119
120 await XmppServerModule.SendMailMessage(To, Subject, Markdown);
121 }
122 }
123}
Class that can be used to encapsulate Markdown to be returned from a Web Service, bypassing any encod...
MarkdownSettings Settings
Markdown settings, if provided.
Contains a markdown document. This markdown document class supports original markdown,...
static ? int HeaderEndPosition(string Markdown)
Gets the end position of the header, if one is found, null otherwise.
static async Task< string > Preprocess(string Markdown, MarkdownSettings Settings, params Type[] TransparentExceptionTypes)
Preprocesses markdown text.
Contains settings that the Markdown parser uses to customize its behavior.
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:147
static Emoji1LocalFiles Emoji1_24x24
Emojis.
Definition: Gateway.cs:3166
Abstract base class for State-Machine action nodes.
Definition: ActionNode.cs:9
override async Task Parse(XmlElement Xml)
Parses the State-machine node.
Definition: MailMessage.cs:59
override void OnChildNodesUpdated()
Method called whenever ChildNodes is updated.
Definition: MailMessage.cs:81
override IStateMachineNode Create()
Creates a new node of the corresponding type.
Definition: MailMessage.cs:50
override async Task Execute(EvaluationArguments Arguments)
Evaluates the action node
Definition: MailMessage.cs:94
Defines to whom a payment (or message) is sent.
Definition: To.cs:9
Contains information required for evaluating script in a state-machine.
void ConvertValueAttributesToElements(XmlElement Xml, Type[] ValueTypes, bool[] Required)
Converts value attributes to parsed elements. The XML definition has to be parsed before,...
Task< object > Evaluate(EvaluationArguments Arguments)
Evaluates the value node.
Definition: Value.cs:147
Service Module hosting the XMPP broker and its components.
static Task< bool > SendMailMessage(string To, string Subject, string Markdown)
Sends a mail message