Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ContractNotificationEvent.cs
1using Microsoft.Maui.Controls.Shapes;
4using System.Text;
5using System.Xml;
8
10{
15 {
16 private Contract? contract;
17
22 : base()
23 {
24 }
25
31 : base()
32 {
33 this.ContractId = e.ContractId;
34 this.Category = e.ContractId;
35 this.Type = NotificationEventType.Contracts;
36 this.Received = DateTime.UtcNow;
37 }
38
44 : base()
45 {
46 this.ContractId = e.RequestedContract?.ContractId ?? string.Empty;
47 this.Category = this.ContractId;
48 this.Type = NotificationEventType.Contracts;
49 this.Received = DateTime.UtcNow;
50
52 }
53
60 : base()
61 {
62 this.ContractId = Contract.ContractId;
63 this.Category = e.RequestedContractId;
64 this.Type = NotificationEventType.Contracts;
65 this.Received = DateTime.UtcNow;
66
67 this.SetContract(Contract);
68 }
69
76 : base()
77 {
78 this.ContractId = Contract.ContractId;
79 this.Category = e.ContractId;
80 this.Type = NotificationEventType.Contracts;
81 this.Received = DateTime.UtcNow;
82
83 this.SetContract(Contract);
84 }
85
89 public string? ContractId { get; set; }
90
94 public string? ContractXml { get; set; }
95
100 public async Task<Contract?> GetContract()
101 {
102 if (this.contract is null && !string.IsNullOrEmpty(this.ContractXml))
103 {
104 XmlDocument Doc = new()
105 {
106 PreserveWhitespace = true
107 };
108 Doc.LoadXml(this.ContractXml);
109
110 ParsedContract Parsed = await Contract.Parse(Doc.DocumentElement, ServiceRef.XmppService.ContractsClient, false);
111
112 this.contract = Parsed?.Contract;
113 }
114
115 return this.contract;
116 }
117
123 {
124 this.contract = Contract;
125
126 if (Contract is null)
127 this.ContractXml = null;
128 else
129 {
130 StringBuilder Xml = new();
131 Contract.Serialize(Xml, true, true, true, true, true, true, true);
132 this.ContractXml = Xml.ToString();
133 }
134 }
135
140 public override Task<Geometry> GetCategoryIcon()
141 {
142 return Task.FromResult(Geometries.ContractPath);
143 }
144
148 public override async Task<string> GetDescription()
149 {
150 Contract? Contract = await this.GetContract();
151
152 if (Contract is null)
153 return this.ContractId ?? string.Empty;
154 else
155 return await ContractModel.GetCategory(Contract) ?? string.Empty;
156 }
157
158 }
159}
override Task< Geometry > GetCategoryIcon()
Gets an icon for the category of event.
ContractNotificationEvent(ContractPetitionResponseEventArgs e)
Abstract base class of Contract notification events.
override async Task< string > GetDescription()
Gets a descriptive text for the category of event.
ContractNotificationEvent(Contract Contract, ContractPetitionEventArgs e)
Abstract base class of Contract notification events.
ContractNotificationEvent(Contract Contract, ContractReferenceEventArgs e)
Abstract base class of Contract notification events.
ContractNotificationEvent(ContractProposalEventArgs e)
Abstract base class of Contract notification events.
ContractNotificationEvent()
Abstract base class of Contract notification events.
Base class that references services in the app.
Definition: ServiceRef.cs:43
static IXmppService XmppService
The XMPP service for XMPP communication.
Definition: ServiceRef.cs:190
Static class containing SVG Paths for symbols used in the app.
Definition: Geometries.cs:11
static readonly Geometry ContractPath
Contract button glyph
Definition: Geometries.cs:548
static async Task< string?> GetCategory(Contract Contract)
Gets the category of a contract
Contains the definition of a contract
Definition: Contract.cs:22
static Task< ParsedContract > Parse(XmlDocument Xml)
Validates a contract XML Document, and returns the contract definition in it.
Definition: Contract.cs:441
void Serialize(StringBuilder Xml, bool IncludeNamespace, bool IncludeIdAttribute, bool IncludeClientSignatures, bool IncludeAttachments, bool IncludeStatus, bool IncludeServerSignature, bool IncludeAttachmentReferences)
Serializes the Contract, in normalized form.
Definition: Contract.cs:1621
string ContractId
Contract identity
Definition: Contract.cs:65
Contains information about a parsed contract.
abstract class NotificationEvent()
Abstract base class of notification events.
NotificationEventType
Button on which event is to be displayed.