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;
11
13{
18 {
19 private LegalIdentity? identity;
20
25 : base()
26 {
27 }
28
34 public ContractSignedNotificationEvent(Contract Contract, ContractSignedEventArgs e)
35 : base(Contract, e)
36 {
37 this.LegalId = e.LegalId;
38 this.Role = e.Role;
39 }
40
44 public string? LegalId { get; set; }
45
49 public string? Role { get; set; }
50
54 public override async Task Open()
55 {
56 Contract? Contract = await this.GetContract();
57 ViewContractNavigationArgs Args = new(Contract, false);
58
60 }
61
65 public override async Task<string> GetDescription()
66 {
67 Contract? Contract = await this.GetContract();
68 StringBuilder Result = new();
69
70 if (Contract is not null)
71 {
72 Result.Append(await ContractModel.GetCategory(Contract));
73 Result.Append(": ");
74 }
75
76 if (this.identity is null)
77 Result.Append(ServiceRef.Localizer[nameof(AppResources.ContractSignatureReceived)]);
78 else
79 {
80 string FriendlyName = ContactInfo.GetFriendlyName(this.identity);
81 Result.Append(ServiceRef.Localizer[nameof(AppResources.UserSignedAs), FriendlyName, this.Role ?? string.Empty]);
82 }
83
84 Result.Append('.');
85
86 return Result.ToString();
87 }
88
92 public string? IdentityXml { get; set; }
93
99 {
100 get
101 {
102 if (this.identity is null && !string.IsNullOrEmpty(this.IdentityXml))
103 {
104 XmlDocument Doc = new()
105 {
106 PreserveWhitespace = true
107 };
108 Doc.LoadXml(this.IdentityXml);
109
110 this.identity = LegalIdentity.Parse(Doc.DocumentElement);
111 }
112
113 return this.identity;
114 }
115
116 set
117 {
118 this.identity = value;
119
120 if (value is null)
121 this.IdentityXml = null;
122 else
123 {
124 StringBuilder Xml = new();
125 value.Serialize(Xml, true, true, true, true, true, true, true);
126 this.IdentityXml = Xml.ToString();
127 }
128 }
129 }
130
134 public override async Task Prepare()
135 {
136 if (this.identity is null && !string.IsNullOrEmpty(this.LegalId))
137 {
138 try
139 {
140 this.Identity = await ServiceRef.XmppService.GetLegalIdentity(this.LegalId);
141 }
142 catch (Exception ex)
143 {
144 ServiceRef.LogService.LogException(ex,
145 new KeyValuePair<string, object?>("ContractId", this.ContractId),
146 new KeyValuePair<string, object?>("LegalId", this.LegalId),
147 new KeyValuePair<string, object?>("Role", this.Role),
148 new KeyValuePair<string, object?>(Constants.XmppProperties.Jid, ServiceRef.XmppService.BareJid));
149 }
150 }
151
153
154 if (Identity?.Attachments is not null)
155 {
156 foreach (Attachment Attachment in Identity.Attachments.GetImageAttachments())
157 {
158 try
159 {
160 await PhotosLoader.LoadPhoto(Attachment);
161 }
162 catch (Exception ex)
163 {
164 ServiceRef.LogService.LogException(ex);
165 }
166 }
167 }
168 }
169
170 }
171}
A set of never changing property constants and helpful values.
Definition: Constants.cs:7
Contains information about a contact.
Definition: ContactInfo.cs:21
static async Task< string > GetFriendlyName(CaseInsensitiveString RemoteId)
Gets the friendly name of a remote identity (Legal ID or Bare JID).
Definition: ContactInfo.cs:257
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: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 IXmppService XmppService
The XMPP service for XMPP communication.
Definition: ServiceRef.cs:67
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:9
Contains the definition of a contract
Definition: Contract.cs:22
Class defining a role
Definition: Role.cs:7
Task GoToAsync(string Route, BackMethod BackMethod=BackMethod.Inherited, string? UniqueId=null)
Navigates the AppShell to the specified route, with page arguments to match.
BackMethod
Navigation Back Method
Definition: BackMethod.cs:7