Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ContractSignatureRequest.cs
1using System;
2using System.Text;
3using System.Threading.Tasks;
4using System.Xml;
8
10{
14 [CollectionName("SignatureRequests")]
15 [TypeName(TypeNameSerialization.FullName)]
16 [Index("Signed", "Received")]
17 [Index("ContractId", "Role", "Received")]
19 {
20 private string objectId = null;
21 private Contract contract = null;
22 private DateTime received = DateTime.MinValue;
23 private DateTime? signed = null;
24 private string contractXml = string.Empty;
25 private string contractId = string.Empty;
26 private string role = string.Empty;
27 private string module = string.Empty;
28 private string provider = string.Empty;
29 private string purpose = string.Empty;
30
35 {
36 }
37
41 [ObjectId]
42 public string ObjectId
43 {
44 get => this.objectId;
45 set => this.objectId = value;
46 }
47
52 public async Task<Contract> GetContract()
53 {
54 if (this.contract is null)
55 {
56 XmlDocument Doc = XML.ParseXml(this.contractXml, true);
57 ParsedContract Parsed = await Contract.Parse(Doc.DocumentElement, Gateway.ContractsClient, true);
58 this.contract = Parsed.Contract;
59 }
60
61 return this.contract;
62 }
63
69 {
70 this.contract = Contract;
71 StringBuilder Xml = new StringBuilder();
72 this.contract.Serialize(Xml, true, true, true, true, true, true, true);
73 this.contractXml = Xml.ToString();
74 }
75
79 [DefaultValueStringEmpty]
80 public string ContractXml
81 {
82 get => this.contractXml;
83 set
84 {
85 this.contractXml = value;
86 this.contract = null;
87 }
88 }
89
93 public DateTime Received
94 {
95 get => this.received;
96 set => this.received = value;
97 }
98
102 public DateTime? Signed
103 {
104 get => this.signed;
105 set => this.signed = value;
106 }
107
111 public string ContractId
112 {
113 get => this.contractId;
114 set => this.contractId = value;
115 }
116
120 public string Role
121 {
122 get => this.role;
123 set => this.role = value;
124 }
125
129 [DefaultValueStringEmpty]
130 public string Module
131 {
132 get => this.module;
133 set => this.module = value;
134 }
135
139 [DefaultValueStringEmpty]
140 public string Provider
141 {
142 get => this.provider;
143 set => this.provider = value;
144 }
145
149 [DefaultValueStringEmpty]
150 public string Purpose
151 {
152 get => this.purpose;
153 set => this.purpose = value;
154 }
155
156 }
157}
Helps with common XML-related tasks.
Definition: XML.cs:21
static XmlDocument ParseXml(string Xml)
Parses an XML Document from its string representation.
Definition: XML.cs:713
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:147
static ContractsClient ContractsClient
XMPP Contracts Client, if such a compoent is available on the XMPP broker.
Definition: Gateway.cs:5299
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:441
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:1621
Contains information about a parsed contract.
Class defining a role
Definition: Role.cs:7
TypeNameSerialization
How the type name should be serialized.