Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ContractPetitionNotificationEvent.cs
6using System.Text;
7using System.Xml;
10
12{
17 {
18 private LegalIdentity? identity;
19
24 : base()
25 {
26 }
27
34 : base(Contract, e)
35 {
36 this.Identity = e.RequestorIdentity;
37 this.RequestorFullJid = e.RequestorFullJid;
38 this.PetitionId = e.PetitionId;
39 this.Purpose = e.Purpose;
40 }
41
45 public string? RequestorFullJid { get; }
46
50 public string? PetitionId { get; set; }
51
55 public string? Purpose { get; set; }
56
60 public string? IdentityXml { get; set; }
61
67 {
68 get
69 {
70 if (this.identity is null && !string.IsNullOrEmpty(this.IdentityXml))
71 {
72 XmlDocument Doc = new()
73 {
74 PreserveWhitespace = true
75 };
76 Doc.LoadXml(this.IdentityXml);
77
78 this.identity = LegalIdentity.Parse(Doc.DocumentElement);
79 }
80
81 return this.identity;
82 }
83
84 set
85 {
86 this.identity = value;
87
88 if (value is null)
89 this.IdentityXml = null;
90 else
91 {
92 StringBuilder Xml = new();
93 value.Serialize(Xml, true, true, true, true, true, true, true);
94 this.IdentityXml = Xml.ToString();
95 }
96 }
97 }
98
102 public override async Task Open()
103 {
104 Contract? Contract = await this.GetContract();
105
106 if (Contract is not null)
107 {
108 await ServiceRef.NavigationService.GoToAsync(nameof(PetitionContractPage),
109 new PetitionContractNavigationArgs(this.Identity, this.RequestorFullJid, Contract, this.PetitionId, this.Purpose));
110 }
111 }
112
116 public override async Task<string> GetDescription()
117 {
118 Contract? Contract = await this.GetContract();
119 StringBuilder Result = new();
120
122
123 if (Contract is not null)
124 {
125 Result.Append(": ");
126 Result.Append(await ContractModel.GetCategory(Contract));
127 }
128
129 Result.Append('.');
130
131 return Result.ToString();
132 }
133
137 public override async Task Prepare()
138 {
140
141 if (Identity?.Attachments is not null)
142 {
143 foreach (Attachment Attachment in Identity.Attachments.GetImageAttachments())
144 {
145 try
146 {
147 await PhotosLoader.LoadPhoto(Attachment);
148 }
149 catch (Exception ex)
150 {
151 ServiceRef.LogService.LogException(ex);
152 }
153 }
154 }
155 }
156
157 }
158}
A strongly-typed resource class, for looking up localized strings, etc.
static string RequestToAccessContract
Looks up a localized string similar to Request to access contract.
override async Task Prepare()
Performs perparatory tasks, that will simplify opening the notification.
override async Task< string > GetDescription()
Gets a descriptive text for the category of event.
ContractPetitionNotificationEvent(Contract Contract, ContractPetitionEventArgs e)
Notification event for contract petitions.
Base class that references services in the app.
Definition: ServiceRef.cs:43
static ILogService LogService
Log service.
Definition: ServiceRef.cs:214
static INavigationService NavigationService
The navigation service for navigating between pages.
Definition: ServiceRef.cs:178
static IReportingStringLocalizer Localizer
Localization service
Definition: ServiceRef.cs:370
static async Task< string?> GetCategory(Contract Contract)
Gets the category of a contract
Holds navigation parameters specific to views displaying a contract petition request.
A page to display when the user is asked to petition a contract.
Contains a reference to an attachment assigned to a legal object.
Definition: Attachment.cs:10
Contains the definition of a contract
Definition: Contract.cs:22
LegalIdentity RequestorIdentity
Legal Identity of requesting entity.