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;
9
11{
16 {
17 private LegalIdentity? identity;
18
23 : base()
24 {
25 }
26
32 public ContractPetitionNotificationEvent(Contract Contract, ContractPetitionEventArgs e)
33 : base(Contract, e)
34 {
35 this.Identity = e.RequestorIdentity;
36 this.RequestorFullJid = e.RequestorFullJid;
37 this.PetitionId = e.PetitionId;
38 this.Purpose = e.Purpose;
39 }
40
44 public string? RequestorFullJid { get; }
45
49 public string? PetitionId { get; set; }
50
54 public string? Purpose { get; set; }
55
59 public string? IdentityXml { get; set; }
60
66 {
67 get
68 {
69 if (this.identity is null && !string.IsNullOrEmpty(this.IdentityXml))
70 {
71 XmlDocument Doc = new()
72 {
73 PreserveWhitespace = true
74 };
75 Doc.LoadXml(this.IdentityXml);
76
77 this.identity = LegalIdentity.Parse(Doc.DocumentElement);
78 }
79
80 return this.identity;
81 }
82
83 set
84 {
85 this.identity = value;
86
87 if (value is null)
88 this.IdentityXml = null;
89 else
90 {
91 StringBuilder Xml = new();
92 value.Serialize(Xml, true, true, true, true, true, true, true);
93 this.IdentityXml = Xml.ToString();
94 }
95 }
96 }
97
101 public override async Task Open()
102 {
103 Contract? Contract = await this.GetContract();
104
105 if (Contract is not null)
106 {
107 await ServiceRef.UiService.GoToAsync(nameof(PetitionContractPage),
108 new PetitionContractNavigationArgs(this.Identity, this.RequestorFullJid, Contract, this.PetitionId, this.Purpose));
109 }
110 }
111
115 public override async Task<string> GetDescription()
116 {
117 Contract? Contract = await this.GetContract();
118 StringBuilder Result = new();
119
120 Result.Append(ServiceRef.Localizer[nameof(AppResources.RequestToAccessContract)]);
121
122 if (Contract is not null)
123 {
124 Result.Append(": ");
125 Result.Append(await ContractModel.GetCategory(Contract));
126 }
127
128 Result.Append('.');
129
130 return Result.ToString();
131 }
132
136 public override async Task Prepare()
137 {
139
140 if (Identity?.Attachments is not null)
141 {
142 foreach (Attachment Attachment in Identity.Attachments.GetImageAttachments())
143 {
144 try
145 {
146 await PhotosLoader.LoadPhoto(Attachment);
147 }
148 catch (Exception ex)
149 {
150 ServiceRef.LogService.LogException(ex);
151 }
152 }
153 }
154 }
155
156 }
157}
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:31
static ILogService LogService
Log service.
Definition: ServiceRef.cs:91
static IUiService UiService
Service serializing and managing UI-related tasks.
Definition: ServiceRef.cs:55
static IStringLocalizer Localizer
Localization service
Definition: ServiceRef.cs:235
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:9
Contains the definition of a contract
Definition: Contract.cs:22