Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ContractSignedNotificationEvent.cs
8using System.Text;
9using System.Xml;
12
14{
19 {
20 private LegalIdentity? identity;
21
26 : base()
27 {
28 }
29
36 : base(Contract, e)
37 {
38 this.LegalId = e.LegalId;
39 this.Role = e.Role;
40 this.Contract = e.Contract;
41 }
42
46 public string? LegalId { get; set; }
47
51 public string? Role { get; set; }
52
56 public Contract? Contract { get; set; }
57
61 public override async Task Open()
62 {
63 this.Contract ??= await this.GetContract();
64 ViewContractNavigationArgs Args = new(this.Contract, false);
65
67 }
68
72 public override async Task<string> GetDescription()
73 {
74 this.Contract ??= await this.GetContract();
75 StringBuilder Result = new();
76
77 if (this.Contract is not null)
78 {
79 Result.Append(await ContractModel.GetCategory(this.Contract));
80 Result.Append(": ");
81 }
82
83 if (this.identity is null)
85 else
86 {
87 string FriendlyName = ContactInfo.GetFriendlyName(this.identity);
88 Result.Append(ServiceRef.Localizer[nameof(AppResources.UserSignedAs), FriendlyName, this.Role ?? string.Empty]);
89 }
90
91 Result.Append('.');
92
93 return Result.ToString();
94 }
95
99 public string? IdentityXml { get; set; }
100
106 {
107 get
108 {
109 if (this.identity is null && !string.IsNullOrEmpty(this.IdentityXml))
110 {
111 XmlDocument Doc = new()
112 {
113 PreserveWhitespace = true
114 };
115 Doc.LoadXml(this.IdentityXml);
116
117 this.identity = LegalIdentity.Parse(Doc.DocumentElement);
118 }
119
120 return this.identity;
121 }
122
123 set
124 {
125 this.identity = value;
126
127 if (value is null)
128 this.IdentityXml = null;
129 else
130 {
131 StringBuilder Xml = new();
132 value.Serialize(Xml, true, true, true, true, true, true, true);
133 this.IdentityXml = Xml.ToString();
134 }
135 }
136 }
137
141 public override async Task Prepare()
142 {
143 if (this.identity is null && !string.IsNullOrEmpty(this.LegalId))
144 {
145 try
146 {
147 this.Identity = await ServiceRef.XmppService.GetLegalIdentity(this.LegalId);
148 }
149 catch (Exception ex)
150 {
151 ServiceRef.LogService.LogException(ex,
152 new KeyValuePair<string, object?>("ContractId", this.ContractId),
153 new KeyValuePair<string, object?>("LegalId", this.LegalId),
154 new KeyValuePair<string, object?>("Role", this.Role),
155 new KeyValuePair<string, object?>(Constants.XmppProperties.Jid, ServiceRef.XmppService.BareJid));
156 }
157 }
158
160
161 if (Identity?.Attachments is not null)
162 {
163 foreach (Attachment Attachment in Identity.Attachments.GetImageAttachments())
164 {
165 try
166 {
167 await PhotosLoader.LoadPhoto(Attachment);
168 }
169 catch (Exception ex)
170 {
171 ServiceRef.LogService.LogException(ex);
172 }
173 }
174 }
175 }
176
177 }
178}
A set of never changing property constants and helpful values.
Definition: Constants.cs:24
A strongly-typed resource class, for looking up localized strings, etc.
static string UserSignedAs
Looks up a localized string similar to {0} signed as {1}..
static string ContractSignatureReceived
Looks up a localized string similar to Contract signature received.
Contains information about a contact.
Definition: ContactInfo.cs:22
static async Task< string > GetFriendlyName(CaseInsensitiveString RemoteId)
Gets the friendly name of a remote identity (Legal ID or Bare JID).
Definition: ContactInfo.cs:258
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.
ContractSignedNotificationEvent(Contract Contract, ContractSignedEventArgs e)
Notification event for when a contract has been signed.
ContractSignedNotificationEvent()
Notification event for when a contract has been signed.
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 IXmppService XmppService
The XMPP service for XMPP communication.
Definition: ServiceRef.cs:190
static async Task< string?> GetCategory(Contract Contract)
Gets the category of 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
Class defining a role
Definition: Role.cs:7
Task GoToAsync(string Route)
Navigates to the specified route and pushes the page onto the navigation stack.
BackMethod
Navigation Back Method
Definition: BackMethod.cs:7