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;
7
9{
13 [CollectionName("SignatureRequests")]
14 [TypeName(TypeNameSerialization.FullName)]
15 [Index("Signed", "Received")]
16 [Index("ContractId", "Role", "Received")]
18 {
19 private string objectId = null;
20 private Contract contract = null;
21 private DateTime received = DateTime.MinValue;
22 private DateTime? signed = null;
23 private string contractXml = string.Empty;
24 private string contractId = string.Empty;
25 private string role = string.Empty;
26 private string module = string.Empty;
27 private string provider = string.Empty;
28 private string purpose = string.Empty;
29
34 {
35 }
36
40 [ObjectId]
41 public string ObjectId
42 {
43 get => this.objectId;
44 set => this.objectId = value;
45 }
46
51 public async Task<Contract> GetContract()
52 {
53 if (this.contract is null)
54 {
55 XmlDocument Doc = new XmlDocument()
56 {
57 PreserveWhitespace = true
58 };
59 Doc.LoadXml(this.contractXml);
60 ParsedContract Parsed = await Contract.Parse(Doc.DocumentElement, Gateway.ContractsClient, true);
61 this.contract = Parsed.Contract;
62 }
63
64 return this.contract;
65 }
66
72 {
73 this.contract = Contract;
74 StringBuilder Xml = new StringBuilder();
75 this.contract.Serialize(Xml, true, true, true, true, true, true, true);
76 this.contractXml = Xml.ToString();
77 }
78
82 [DefaultValueStringEmpty]
83 public string ContractXml
84 {
85 get => this.contractXml;
86 set
87 {
88 this.contractXml = value;
89 this.contract = null;
90 }
91 }
92
96 public DateTime Received
97 {
98 get => this.received;
99 set => this.received = value;
100 }
101
105 public DateTime? Signed
106 {
107 get => this.signed;
108 set => this.signed = value;
109 }
110
114 public string ContractId
115 {
116 get => this.contractId;
117 set => this.contractId = value;
118 }
119
123 public string Role
124 {
125 get => this.role;
126 set => this.role = value;
127 }
128
132 [DefaultValueStringEmpty]
133 public string Module
134 {
135 get => this.module;
136 set => this.module = value;
137 }
138
142 [DefaultValueStringEmpty]
143 public string Provider
144 {
145 get => this.provider;
146 set => this.provider = value;
147 }
148
152 [DefaultValueStringEmpty]
153 public string Purpose
154 {
155 get => this.purpose;
156 set => this.purpose = value;
157 }
158
159 }
160}
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:126
static ContractsClient ContractsClient
XMPP Contracts Client, if such a compoent is available on the XMPP broker.
Definition: Gateway.cs:4375
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:397
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:1542
Contains information about a parsed contract.
Class defining a role
Definition: Role.cs:7
TypeNameSerialization
How the type name should be serialized.