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;
7
9{
14 {
15 private Contract? contract;
16
21 : base()
22 {
23 }
24
29 public ContractNotificationEvent(ContractProposalEventArgs e)
30 : base()
31 {
32 this.ContractId = e.ContractId;
33 this.Category = e.ContractId;
34 this.Type = NotificationEventType.Contracts;
35 this.Received = DateTime.UtcNow;
36 }
37
42 public ContractNotificationEvent(ContractPetitionResponseEventArgs e)
43 : base()
44 {
45 this.ContractId = e.RequestedContract?.ContractId ?? string.Empty;
46 this.Category = this.ContractId;
47 this.Type = NotificationEventType.Contracts;
48 this.Received = DateTime.UtcNow;
49
50 this.SetContract(e.RequestedContract);
51 }
52
58 public ContractNotificationEvent(Contract Contract, ContractPetitionEventArgs e)
59 : base()
60 {
61 this.ContractId = Contract.ContractId;
62 this.Category = e.RequestedContractId;
63 this.Type = NotificationEventType.Contracts;
64 this.Received = DateTime.UtcNow;
65
66 this.SetContract(Contract);
67 }
68
74 public ContractNotificationEvent(Contract Contract, ContractReferenceEventArgs e)
75 : base()
76 {
77 this.ContractId = Contract.ContractId;
78 this.Category = e.ContractId;
79 this.Type = NotificationEventType.Contracts;
80 this.Received = DateTime.UtcNow;
81
82 this.SetContract(Contract);
83 }
84
88 public string? ContractId { get; set; }
89
93 public string? ContractXml { get; set; }
94
99 public async Task<Contract?> GetContract()
100 {
101 if (this.contract is null && !string.IsNullOrEmpty(this.ContractXml))
102 {
103 XmlDocument Doc = new()
104 {
105 PreserveWhitespace = true
106 };
107 Doc.LoadXml(this.ContractXml);
108
109 ParsedContract Parsed = await Contract.Parse(Doc.DocumentElement, ServiceRef.XmppService.ContractsClient, false);
110
111 this.contract = Parsed?.Contract;
112 }
113
114 return this.contract;
115 }
116
122 {
123 this.contract = Contract;
124
125 if (Contract is null)
126 this.ContractXml = null;
127 else
128 {
129 StringBuilder Xml = new();
130 Contract.Serialize(Xml, true, true, true, true, true, true, true);
131 this.ContractXml = Xml.ToString();
132 }
133 }
134
139 public override Task<Geometry> GetCategoryIcon()
140 {
141 return Task.FromResult(Geometries.ContractPath);
142 }
143
147 public override async Task<string> GetDescription()
148 {
149 Contract? Contract = await this.GetContract();
150
151 if (Contract is null)
152 return this.ContractId ?? string.Empty;
153 else
154 return await ContractModel.GetCategory(Contract) ?? string.Empty;
155 }
156
157 }
158}
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:31
static IXmppService XmppService
The XMPP service for XMPP communication.
Definition: ServiceRef.cs:67
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:449
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:397
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:1542
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.