Wiki source code of Setting up API communication by REST services with TerraIndex for laboratories
Last modified by Nico Lemaire on 2025/05/06 15:49
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{toc/}} | ||
2 | |||
3 | |||
4 | = Digital Lab Exchange process = | ||
5 | |||
6 | The flow diagram gives a small overview of what the data flow of a lab assignment is. | ||
7 | Every block shows a step of the lab assignment process. From top to bottom these steps are: | ||
8 | |||
9 | 1. Showing the laboratory and all the analyses that can be requested as an option to the user. | ||
10 | 1. The user creating a lab assignment and sending it to the lab trough TerraIndex. | ||
11 | 1. The lab delivering the analysis results back to the TerraIndex. | ||
12 | |||
13 | [[attach:Lab exchange.svg||rel="noopener noreferrer" target="_blank"]] [[attach:Lab exchange.txt||rel="noopener noreferrer" target="_blank"]] | ||
14 | |||
15 | [[image:1712326465681-980.png||height="315" width="630"]] | ||
16 | |||
17 | |||
18 | [[image:1712326492306-381.png||height="781" width="635"]] | ||
19 | |||
20 | ~==> TODO; add option to confirm order based on the Order price PDF | ||
21 | |||
22 | |||
23 | [[image:1712326520488-924.png||height="312" width="632"]] | ||
24 | |||
25 | ~==> TODO; add option download labcertificate | ||
26 | |||
27 | (% element-id="1884" %) | ||
28 | = = | ||
29 | |||
30 | (% element-id="1884" %) | ||
31 | = (% element-id="1883" %)Firewall IP-Addresses of TerraIndex(%%) = | ||
32 | |||
33 | (% element-id="1882" %) | ||
34 | Our IP-addresses: | ||
35 | |||
36 | (% element-id="1881" %) | ||
37 | __**inbound [[Web.terraindex.com>>url:http://Web.terraindex.com||element-id="1880"]]**__ | ||
38 | 137.116.199.164 | ||
39 | |||
40 | (% element-id="1878" %) | ||
41 | __**outbound [[Test.terraindex.com>>url:http://Test.terraindex.com||element-id="1877"]]**__ | ||
42 | 104.45.9.128 | ||
43 | |||
44 | (% element-id="1875" %) | ||
45 | __**Production outbound (http)**__ | ||
46 | 40.115.34.64 | ||
47 | |||
48 | __**Production outbound (ftp):**__ | ||
49 | |||
50 | 13.93.123.234 | ||
51 | |||
52 | (% element-id="1873" %) | ||
53 | __**Test outbound (http, ftp)**__ | ||
54 | 13.73.138.173 | ||
55 | |||
56 | __**Test outbound (ftp: eurofins, eurofins spain):**__ | ||
57 | |||
58 | 51.145.244.12 | ||
59 | |||
60 | (% element-id="1871" %) | ||
61 | __**CD/CI outbound**__ | ||
62 | 40.114.238.16 | ||
63 | |||
64 | (% element-id="1869" %) | ||
65 | __**Office outbound**__ | ||
66 | 213.124.115.132 | ||
67 | |||
68 | (% element-id="1869" %) | ||
69 | __**Deliveryservice**__ | ||
70 | Production: 13.93.123.234 | ||
71 | Test: 51.145.244.12 | ||
72 | |||
73 | (% element-id="1864" %) | ||
74 | = (% element-id="1863" %)Labdelivery (menu-card) files Exchange(%%) = | ||
75 | |||
76 | (% element-id="1862" %) | ||
77 | == (% element-id="1861" %)Solution/Design(%%) == | ||
78 | |||
79 | |||
80 | (% class="table-hover" element-id="1858" %) | ||
81 | (% element-id="1856" %)|(% element-id="1855" %)(% element-id="1854" %)**Action**|(% element-id="1853" %)(% element-id="1852" %)**TerraIndex**|(% element-id="1851" %) |(% element-id="1849" %)(% element-id="1848" %)**Laboratorium**|(% element-id="1847" %)(% element-id="1846" %)**Parameters/Message**|(% element-id="1845" %)(% element-id="1844" %)**Remarks**|(% element-id="1843" %)(% element-id="1842" %)**ResultCodes** | ||
82 | (% element-id="1841" %)|(% element-id="1840" %)1|(% element-id="1839" %)Sends a request to the function: GetCustomers().|=(% element-id="1838" %)>|(% element-id="1837" %) |(% element-id="1835" %)(% element-id="1834" %)**WebserviceUsername (string), **(%%) | ||
83 | (% element-id="1832" %)**WebservicePassword (string),**(%%) | ||
84 | (% element-id="1830" %)**CustomerUsername (string)**|(% element-id="1829" %) |(% element-id="1827" %) | ||
85 | (% element-id="1825" %)|(% element-id="1824" %)2|(% element-id="1823" %) |(% element-id="1821" %) |(% element-id="1819" %)Receives the request and check the customers this username and searches the dateLastChanged for this Customer.|(% element-id="1818" %) |(% element-id="1816" %) |(% element-id="1814" %) | ||
86 | (% element-id="1812" %)|(% element-id="1811" %)3|(% element-id="1810" %) |(% element-id="1808" %)<=|(% element-id="1807" %)Sends back the list of customers with the lastChangedTimestamp|(% element-id="1806" %)ResultCode (), | ||
87 | ErrorMessage (string), | ||
88 | List<customer> , Customer: | ||
89 | CustomerCode (string), | ||
90 | CustomerName (string), | ||
91 | LabID (int), | ||
92 | LabName (string), | ||
93 | ChangedTimeStamp (DateTime)|(% element-id="1798" %)We receive the dateTimestamp instead of sending it, so we always get the full list and we are also able to delete customercodes.|(% element-id="1797" %)1 = Success, | ||
94 | 2 = GeneralError, | ||
95 | 3 = WrongSIKBVersion, | ||
96 | 4 = InvalidCredentials, | ||
97 | 5 = CustomerUsernameInvalid, | ||
98 | 6 = CustomerUsernameNotValidForCustomerCode | ||
99 | 7 = FileContentProblem, | ||
100 | 8 = InvalidOrderId, | ||
101 | 9 = OrderIdAlreadyApproved | ||
102 | 10 = PDFNotAvailable | ||
103 | (% element-id="1787" %)|(% element-id="1786" %)4|(% element-id="1785" %)Receives the list of Customers, and will check for each customer it needs to request a new/changed labdelivery file based on the ChangedTimestamp.|(% element-id="1784" %) |(% element-id="1782" %) |(% element-id="1780" %) |(% element-id="1778" %)If a customer is not longer in this list, TerraIndex can remove this customercode from the customer database.|(% element-id="1777" %) | ||
104 | (% element-id="1775" %)|(% element-id="1774" %)5|(% element-id="1773" %)Sends a request to the function: GetProductList() if it has changed.|=(% element-id="1772" %)>|(% element-id="1771" %) |(% element-id="1769" %)(% element-id="1768" %)**WebserviceUsername (string), **(%%) | ||
105 | (% element-id="1766" %)**WebservicePassword (string),**(%%) | ||
106 | (% element-id="1764" %)**CustomerUsername (string),**(%%) | ||
107 | LabID (int), | ||
108 | CustomerCode (string), | ||
109 | LanguageCode (string, default 'nld' volgens ISO 639-3-codes), | ||
110 | SIKBVersion (string, default: '13.4.0'), | ||
111 | UseZipStream/UseZip (bool, default: 'false')|(% element-id="1758" %)(% element-id="1757" %) | ||
112 | ((( | ||
113 | (% element-id="1756" %) | ||
114 | We start with dutch, then extend with multiple languages, TerraIndex is in the lead to request multiple languages. | ||
115 | TerraIndex uses: 'fra', 'nld', 'eng', 'spa', 'deu', 'ita', 'por', 'dan' | ||
116 | |||
117 | |||
118 | (% element-id="1752" %) | ||
119 | Besides SIKB 13.4.0, TerraIndex also supports 9.0.0/8.0.0 etc. | ||
120 | |||
121 | (% element-id="1752" %) | ||
122 | ~==> nle Do you want to mention these old versions? | ||
123 | )))|(% element-id="1751" %) | ||
124 | (% element-id="1749" %)|(% element-id="1748" %)6|(% element-id="1747" %) |(% element-id="1745" %) |(% element-id="1743" %)Reveives a request to create a labdelivery file in a certain version of SIKB. It will generate the file.|(% element-id="1742" %) |(% element-id="1740" %) |(% element-id="1738" %) | ||
125 | (% element-id="1736" %)|(% element-id="1735" %)7|(% element-id="1734" %) |(% element-id="1732" %)<=|(% element-id="1731" %)Sends back the SIKB file, as a Base64 encoded string, with or without using a zipstream.|(% element-id="1730" %)ResultCode (), | ||
126 | ErrorMessage (string), | ||
127 | FileContent_Base64 (string), | ||
128 | UseZipStream/UseZip (bool, default: 'false')|(% element-id="1726" %) |(% element-id="1724" %)1 = Success, | ||
129 | 2 = GeneralError, | ||
130 | 3 = WrongSIKBVersion, | ||
131 | 4 = InvalidCredentials, | ||
132 | 5 = CustomerUsernameInvalid, | ||
133 | 6 = CustomerUsernameNotValidForCustomerCode | ||
134 | 7 = FileContentProblem, | ||
135 | 8 = InvalidOrderId, | ||
136 | 9 = OrderIdAlreadyApproved | ||
137 | 10 = PDFNotAvailable | ||
138 | (% element-id="1714" %)|(% element-id="1713" %)8|(% element-id="1712" %)Receives the DeliveryFile and saves the file for import into customer database.|(% element-id="1711" %) |(% element-id="1709" %) |(% element-id="1707" %) |(% element-id="1705" %) |(% element-id="1703" %) | ||
139 | (% element-id="1701" %)|(% element-id="1700" %)9|(% element-id="1699" %)Go back to step 5, for every Customer code, every language.|(% element-id="1698" %) |(% element-id="1696" %) |(% element-id="1694" %) |(% element-id="1692" %) |(% element-id="1690" %) | ||
140 | (% element-id="1688" %)|(% element-id="1687" %)10|(% element-id="1686" %)Process the LabDeliveryFiles|(% element-id="1685" %) |(% element-id="1683" %) |(% element-id="1681" %) |(% element-id="1679" %) |(% element-id="1677" %) | ||
141 | |||
142 | (% element-id="1675" %) | ||
143 | == (% element-id="1674" %)Get Customers (POST)(%%) == | ||
144 | |||
145 | (% element-id="1673" %) | ||
146 | === (% element-id="1672" %)Request example(%%) === | ||
147 | |||
148 | (% element-id="1671" %) | ||
149 | (% element-id="1669" %)|(% element-id="1668" %)(% element-id="1667" %) | ||
150 | ((( | ||
151 | {{code language="C#"}} | ||
152 | public GetCustomersCall.Response GetCustomers(string WebserviceUsername, string WebservicePassword, string CustomerUsername) | ||
153 | { | ||
154 | GetCustomersCall.Response set = new GetCustomersCall.Response(); | ||
155 | |||
156 | try | ||
157 | { | ||
158 | var content = new FormUrlEncodedContent(new[] | ||
159 | { | ||
160 | new KeyValuePair<string, string>("userName", WebserviceUsername), | ||
161 | new KeyValuePair<string, string>("password", WebservicePassword), | ||
162 | new KeyValuePair<string, string>("customerUsername", CustomerUsername), | ||
163 | }); | ||
164 | |||
165 | HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/GetCustomers", content).Result; | ||
166 | response.EnsureSuccessStatusCode(); | ||
167 | string responseMessage = response.Content.ReadAsStringAsync().Result; | ||
168 | |||
169 | if (string.IsNullOrEmpty(responseMessage)) | ||
170 | { | ||
171 | throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " / GetCustomers" + "]"); | ||
172 | } | ||
173 | using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage))) | ||
174 | { | ||
175 | XmlSerializer serializer = new XmlSerializer(typeof(GetCustomersCall.Response)); | ||
176 | set = (GetCustomersCall.Response)serializer.Deserialize(ms); | ||
177 | } | ||
178 | } | ||
179 | catch (Exception ex) | ||
180 | { | ||
181 | #region handle exception | ||
182 | set.Status = new BusinessEntities.LabRestService.GetCustomersCall.ResponseStatus(); | ||
183 | set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString(); | ||
184 | set.Status.ErrorMessage = "Exception occurred in GetCustomers (username: " + WebserviceUsername + ", password: " + WebservicePassword + ") with message: " + ex.Message; | ||
185 | ex.Data.Add("WebserviceUsername", WebserviceUsername); | ||
186 | ex.Data.Add("WebservicePassword", WebservicePassword); | ||
187 | ex.Data.Add("CustomerUsername", CustomerUsername); | ||
188 | ExceptionHandler.HandleException(ex); | ||
189 | #endregion | ||
190 | } | ||
191 | return set; | ||
192 | } | ||
193 | {{/code}} | ||
194 | |||
195 | (% element-id="1566" %) | ||
196 | |||
197 | ))) | ||
198 | |||
199 | (% element-id="1564" %) | ||
200 | (% element-id="1562" %)|(% element-id="1561" %)(% element-id="1560" %) | ||
201 | ((( | ||
202 | (% element-id="1559" %) | ||
203 | POST https:~/~/<URL>/GetCustomers HTTP/1.1 | ||
204 | |||
205 | (% element-id="1558" %) | ||
206 | Content-Type: application/x-www-form-urlencoded | ||
207 | |||
208 | (% element-id="1557" %) | ||
209 | Host: 81.175.89.24 | ||
210 | |||
211 | (% element-id="1556" %) | ||
212 | Content-Length: 115 | ||
213 | |||
214 | (% element-id="1555" %) | ||
215 | Expect: 100-continue | ||
216 | |||
217 | |||
218 | (% element-id="1552" %) | ||
219 | userName=<webservice_username>&password=<Webservice_password>&customerUsername=<customer_username or token> | ||
220 | ))) | ||
221 | |||
222 | (% element-id="1551" %) | ||
223 | === (% element-id="1550" %)Response example(%%) === | ||
224 | |||
225 | (% element-id="1549" %) | ||
226 | (% element-id="1547" %)|(% element-id="1546" %)(% element-id="1545" %) | ||
227 | ((( | ||
228 | {{code language="XML"}} | ||
229 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
230 | <Response><Customers> | ||
231 | <Customer LabId="1" LabName="Example Laboratorium" CustomerId="300" CustomerName="Adviesbureau De bodemkoning - Rotterdam" LastModifiedOnClient="2019-05-08T11:05:14.17+02:00" ></Customer> | ||
232 | <Customer LabId="1" LabName="Example Laboratorium" CustomerId="656" CustomerName="Adviesbureau De bodemkoning - Delft" LastModifiedOnClient="2019-04-19T13:20:10.123+02:00" ></Customer> | ||
233 | </Customers> | ||
234 | <Status> | ||
235 | <StatusCode>1</StatusCode> | ||
236 | <StatusCodeDescription>OK</StatusCodeDescription> | ||
237 | <ErrorMessage></ErrorMessage> | ||
238 | </Status> | ||
239 | </Response> | ||
240 | {{/code}} | ||
241 | |||
242 | (% element-id="1492" %) | ||
243 | |||
244 | ))) | ||
245 | |||
246 | (% element-id="1490" %) | ||
247 | == (% element-id="1489" %)Get Products (POST)(%%) == | ||
248 | |||
249 | (% element-id="1488" %) | ||
250 | === (% element-id="1487" %)Request example(%%) === | ||
251 | |||
252 | (% element-id="1486" %) | ||
253 | (% element-id="1484" %)|(% element-id="1483" %)(% element-id="1482" %) | ||
254 | ((( | ||
255 | (% element-id="1481" %) | ||
256 | public GetProductsCall.Response GetProductList(string WebserviceUsername, string WebservicePassword, string CustomerUsername, string customerid, int labid, string sikbVersion, string languageCode) | ||
257 | |||
258 | (% element-id="1480" %) | ||
259 | { | ||
260 | |||
261 | |||
262 | (% element-id="1477" %) | ||
263 | GetProductsCall.Response set = new GetProductsCall.Response(); | ||
264 | |||
265 | |||
266 | (% element-id="1474" %) | ||
267 | try | ||
268 | |||
269 | (% element-id="1473" %) | ||
270 | { | ||
271 | |||
272 | (% element-id="1472" %) | ||
273 | bool useZipstream = true; | ||
274 | |||
275 | (% element-id="1471" %) | ||
276 | var content = new FormUrlEncodedContent(new[] | ||
277 | |||
278 | (% element-id="1470" %) | ||
279 | { | ||
280 | |||
281 | (% element-id="1469" %) | ||
282 | new KeyValuePair<string, string>("userName", WebserviceUsername), | ||
283 | |||
284 | (% element-id="1468" %) | ||
285 | new KeyValuePair<string, string>("password", WebservicePassword), | ||
286 | |||
287 | (% element-id="1467" %) | ||
288 | new KeyValuePair<string, string>("customerUsername", CustomerUsername), | ||
289 | |||
290 | (% element-id="1466" %) | ||
291 | new KeyValuePair<string, string>("languageCode", languageCode), | ||
292 | |||
293 | (% element-id="1465" %) | ||
294 | new KeyValuePair<string, string>("clientId", customerid), | ||
295 | |||
296 | (% element-id="1464" %) | ||
297 | new KeyValuePair<string, string>("sikbVersion", sikbVersion), | ||
298 | |||
299 | (% element-id="1463" %) | ||
300 | new KeyValuePair<string, string>("useZip", useZipstream.ToString() ), | ||
301 | |||
302 | (% element-id="1462" %) | ||
303 | }); | ||
304 | |||
305 | |||
306 | (% element-id="1459" %) | ||
307 | HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/GetProducts", content).Result; | ||
308 | |||
309 | (% element-id="1458" %) | ||
310 | response.EnsureSuccessStatusCode(); | ||
311 | |||
312 | (% element-id="1457" %) | ||
313 | string responseMessage = response.Content.ReadAsStringAsync().Result; | ||
314 | |||
315 | |||
316 | (% element-id="1454" %) | ||
317 | if (string.IsNullOrEmpty(responseMessage)) | ||
318 | |||
319 | (% element-id="1453" %) | ||
320 | { | ||
321 | |||
322 | (% element-id="1452" %) | ||
323 | throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " /GetProducts" + "]"); | ||
324 | |||
325 | (% element-id="1451" %) | ||
326 | } | ||
327 | |||
328 | (% element-id="1450" %) | ||
329 | using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage~)~)~) | ||
330 | |||
331 | (% element-id="1449" %) | ||
332 | { | ||
333 | |||
334 | (% element-id="1448" %) | ||
335 | XmlSerializer serializer = new XmlSerializer(typeof(GetProductsCall.Response)); | ||
336 | |||
337 | (% element-id="1447" %) | ||
338 | set = (GetProductsCall.Response)serializer.Deserialize(ms); | ||
339 | |||
340 | (% element-id="1446" %) | ||
341 | } | ||
342 | |||
343 | |||
344 | (% element-id="1443" %) | ||
345 | if (useZipstream && !string.IsNullOrEmpty(set.FileContent)) | ||
346 | |||
347 | (% element-id="1442" %) | ||
348 | { | ||
349 | |||
350 | (% element-id="1441" %) | ||
351 | ~/~/convert from base64 string back to normal | ||
352 | |||
353 | (% element-id="1440" %) | ||
354 | ~/~/first check for real Base64, by checking there is no 'xml' in it | ||
355 | |||
356 | (% element-id="1439" %) | ||
357 | if (!set.FileContent.Contains("<labaanlevering")) | ||
358 | |||
359 | (% element-id="1438" %) | ||
360 | { | ||
361 | |||
362 | (% element-id="1437" %) | ||
363 | set.FileContent = ZipStreamHelper.DecompressBase64StringToString(set.FileContent); | ||
364 | |||
365 | (% element-id="1436" %) | ||
366 | } | ||
367 | |||
368 | (% element-id="1435" %) | ||
369 | } | ||
370 | |||
371 | |||
372 | (% element-id="1432" %) | ||
373 | } | ||
374 | |||
375 | (% element-id="1431" %) | ||
376 | catch (Exception ex) | ||
377 | |||
378 | (% element-id="1430" %) | ||
379 | { | ||
380 | |||
381 | (% element-id="1429" %) | ||
382 | #region handle exception | ||
383 | |||
384 | |||
385 | (% element-id="1426" %) | ||
386 | set.Status = new BusinessEntities.LabRestService.GetProductsCall.ResponseStatus(); | ||
387 | |||
388 | (% element-id="1425" %) | ||
389 | set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString(); | ||
390 | |||
391 | (% element-id="1424" %) | ||
392 | set.Status.ErrorMessage = "Exception occurred in GetProducts (username: " + WebserviceUsername + ", password: " + WebservicePassword + ") with message: " + ex.Message; | ||
393 | |||
394 | |||
395 | (% element-id="1421" %) | ||
396 | ex.Data.Add("WebserviceUsername", WebserviceUsername); | ||
397 | |||
398 | (% element-id="1420" %) | ||
399 | ex.Data.Add("WebservicePassword", WebservicePassword); | ||
400 | |||
401 | (% element-id="1419" %) | ||
402 | ex.Data.Add("CustomerUsername", CustomerUsername); | ||
403 | |||
404 | (% element-id="1418" %) | ||
405 | ex.Data.Add("sikbVersion", sikbVersion); | ||
406 | |||
407 | (% element-id="1417" %) | ||
408 | ex.Data.Add("customerid", customerid); | ||
409 | |||
410 | (% element-id="1416" %) | ||
411 | ex.Data.Add("languageCode", languageCode); | ||
412 | |||
413 | |||
414 | (% element-id="1413" %) | ||
415 | ExceptionHandler.HandleException(ex); | ||
416 | |||
417 | (% element-id="1412" %) | ||
418 | #endregion | ||
419 | |||
420 | (% element-id="1411" %) | ||
421 | } | ||
422 | |||
423 | |||
424 | (% element-id="1408" %) | ||
425 | return set; | ||
426 | |||
427 | (% element-id="1407" %) | ||
428 | } | ||
429 | ))) | ||
430 | |||
431 | (% element-id="1406" %) | ||
432 | (% element-id="1404" %)|(% element-id="1403" %)(% element-id="1402" %) | ||
433 | ((( | ||
434 | (% element-id="1401" %) | ||
435 | POST https:~/~/<URL>/GetProducts HTTP/1.1 | ||
436 | |||
437 | (% element-id="1400" %) | ||
438 | Content-Type: application/x-www-form-urlencoded | ||
439 | |||
440 | (% element-id="1399" %) | ||
441 | Host: 81.175.89.24 | ||
442 | |||
443 | (% element-id="1398" %) | ||
444 | Content-Length: 179 | ||
445 | |||
446 | (% element-id="1397" %) | ||
447 | Expect: 100-continue | ||
448 | |||
449 | |||
450 | (% element-id="1394" %) | ||
451 | userName=<webservice_username>&password=<Webservice_password>&customerUsername=<customer_username or token>&languageCode=nld&clientId=300&sikbVersion=13.5.0&useZip=True | ||
452 | ))) | ||
453 | |||
454 | (% element-id="1393" %) | ||
455 | === (% element-id="1392" %)Response example(%%) === | ||
456 | |||
457 | (% element-id="1391" %) | ||
458 | (% element-id="1389" %)|(% element-id="1388" %)(% element-id="1387" %) | ||
459 | ((( | ||
460 | (% element-id="1386" %) | ||
461 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
462 | |||
463 | (% element-id="1385" %) | ||
464 | <Response> | ||
465 | |||
466 | (% element-id="1384" %) | ||
467 | <FileContent> {SIKB FILE in ZIPSTREAM BASE64 format}</FileContent> | ||
468 | |||
469 | (% element-id="1383" %) | ||
470 | <Status> | ||
471 | |||
472 | (% element-id="1382" %) | ||
473 | <StatusCode>1</StatusCode> | ||
474 | |||
475 | (% element-id="1381" %) | ||
476 | <StatusCodeDescription>OK</StatusCodeDescription> | ||
477 | |||
478 | (% element-id="1380" %) | ||
479 | <ErrorMessage></ErrorMessage> | ||
480 | |||
481 | (% element-id="1379" %) | ||
482 | </Status></Response> | ||
483 | ))) | ||
484 | |||
485 | (% element-id="1378" %) | ||
486 | = (% element-id="1377" %)Useraccount Checkup.(%%) = | ||
487 | |||
488 | (% element-id="1374" %) | ||
489 | == (% element-id="1373" %)Solution/Design(%%) == | ||
490 | |||
491 | (% element-id="1372" %) | ||
492 | With every call we will no longer send customer usernames and customer passwords. We want to use a fixed Machine 2 Machine username and password for TerraIndex. So we need to be able to quickly check whether the Customer username we want to use exists, and is bound to our TerraIndex fixed Machine 2 machine account. | ||
493 | |||
494 | (% element-id="1371" %) | ||
495 | WebserviceUsername (string), | ||
496 | WebservicePassword (string), | ||
497 | CustomerUsername (string) | ||
498 | |||
499 | |||
500 | (% element-id="1366" %) | ||
501 | Therefore we call a Webserice for ValidCredentials Check: | ||
502 | |||
503 | |||
504 | (% class="table-hover" element-id="1363" %) | ||
505 | (% element-id="1361" %)|(% element-id="1360" %)(% element-id="1359" %)**Action**|(% element-id="1358" %)(% element-id="1357" %)**TerraIndex**|(% element-id="1356" %) |(% element-id="1354" %)(% element-id="1353" %)**Laboratorium**|(% element-id="1352" %)(% element-id="1351" %)**Parameters/Message**|(% element-id="1350" %)(% element-id="1349" %)**Remarks**|(% element-id="1348" %)(% element-id="1347" %)**ResultCodes** | ||
506 | (% element-id="1346" %)|(% element-id="1345" %)1|(% element-id="1344" %)Sends a request to the function: ValidCredentials().|=(% element-id="1343" %)>|(% element-id="1342" %) |(% element-id="1340" %)WebserviceUsername (string), | ||
507 | WebservicePassword (string), | ||
508 | CustomerUsername (string)|(% element-id="1337" %)We want to skip the Password of the customer, and we use the WebserviceUsername + WebservicePassword for real authentication.|(% element-id="1336" %) | ||
509 | (% element-id="1334" %)|(% element-id="1333" %)2|(% element-id="1332" %) |(% element-id="1330" %) |(% element-id="1328" %)Receives the request and checks the combination of WebserviceUsername and WebservicePassword is Ok. Then checks the CustomerUsername is valid.|(% element-id="1327" %) |(% element-id="1325" %) |(% element-id="1323" %) | ||
510 | (% element-id="1321" %)|(% element-id="1320" %)3|(% element-id="1319" %) |(% element-id="1317" %)<=|(% element-id="1316" %)Sends back a Success of InvalidCredentials|(% element-id="1315" %)ResultCode (), | ||
511 | ErrorMessage (string),|(% element-id="1313" %) |(% element-id="1311" %)1 = Success, | ||
512 | 2 = GeneralError, | ||
513 | 3 = WrongSIKBVersion, | ||
514 | 4 = InvalidCredentials, | ||
515 | 5 = CustomerUsernameInvalid, | ||
516 | 6 = CustomerUsernameNotValidForCustomerCode | ||
517 | 7 = FileContentProblem, | ||
518 | 8 = InvalidOrderId, | ||
519 | 9 = OrderIdAlreadyApproved | ||
520 | 10 = PDFNotAvailable | ||
521 | |||
522 | (% element-id="1301" %) | ||
523 | == (% element-id="1300" %)Check ValidCredentials (POST)(%%) == | ||
524 | |||
525 | (% element-id="1299" %) | ||
526 | === (% element-id="1298" %)Request example(%%) === | ||
527 | |||
528 | (% element-id="1297" %) | ||
529 | (% element-id="1295" %)|(% element-id="1294" %)(% element-id="1293" %) | ||
530 | ((( | ||
531 | (% element-id="1292" %) | ||
532 | public ValidCredentialsCall.Response ValidCredentials(string WebserviceUsername, string WebservicePassword, string CustomerUsername, string customerid) | ||
533 | |||
534 | (% element-id="1291" %) | ||
535 | { | ||
536 | |||
537 | (% element-id="1290" %) | ||
538 | ValidCredentialsCall.Response set = new ValidCredentialsCall.Response(); | ||
539 | |||
540 | |||
541 | (% element-id="1287" %) | ||
542 | try | ||
543 | |||
544 | (% element-id="1286" %) | ||
545 | { | ||
546 | |||
547 | |||
548 | (% element-id="1283" %) | ||
549 | var content = new FormUrlEncodedContent(new[] | ||
550 | |||
551 | (% element-id="1282" %) | ||
552 | { | ||
553 | |||
554 | (% element-id="1281" %) | ||
555 | new KeyValuePair<string, string>("userName", WebserviceUsername), | ||
556 | |||
557 | (% element-id="1280" %) | ||
558 | new KeyValuePair<string, string>("password", WebservicePassword), | ||
559 | |||
560 | (% element-id="1279" %) | ||
561 | ~/~/new KeyValuePair<string, string>("clientId", customerid), ~/~/ Optional | ||
562 | |||
563 | (% element-id="1278" %) | ||
564 | new KeyValuePair<string, string>("customerUsername", CustomerUsername), | ||
565 | |||
566 | (% element-id="1277" %) | ||
567 | }); | ||
568 | |||
569 | |||
570 | (% element-id="1274" %) | ||
571 | HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/ValidCredentials", content).Result; | ||
572 | |||
573 | (% element-id="1273" %) | ||
574 | response.EnsureSuccessStatusCode(); | ||
575 | |||
576 | (% element-id="1272" %) | ||
577 | string responseMessage = response.Content.ReadAsStringAsync().Result; | ||
578 | |||
579 | |||
580 | (% element-id="1269" %) | ||
581 | if (string.IsNullOrEmpty(responseMessage)) | ||
582 | |||
583 | (% element-id="1268" %) | ||
584 | { | ||
585 | |||
586 | (% element-id="1267" %) | ||
587 | throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " / ValidCredentials" + "]"); | ||
588 | |||
589 | (% element-id="1266" %) | ||
590 | } | ||
591 | |||
592 | (% element-id="1265" %) | ||
593 | using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage~)~)~) | ||
594 | |||
595 | (% element-id="1264" %) | ||
596 | { | ||
597 | |||
598 | (% element-id="1263" %) | ||
599 | XmlSerializer serializer = new XmlSerializer(typeof(ValidCredentialsCall.Response)); | ||
600 | |||
601 | (% element-id="1262" %) | ||
602 | set = (ValidCredentialsCall.Response)serializer.Deserialize(ms); | ||
603 | |||
604 | |||
605 | (% element-id="1259" %) | ||
606 | return set; | ||
607 | |||
608 | (% element-id="1258" %) | ||
609 | } | ||
610 | |||
611 | |||
612 | (% element-id="1255" %) | ||
613 | } | ||
614 | |||
615 | (% element-id="1254" %) | ||
616 | catch (Exception ex) | ||
617 | |||
618 | (% element-id="1253" %) | ||
619 | { | ||
620 | |||
621 | (% element-id="1252" %) | ||
622 | #region handle exception | ||
623 | |||
624 | |||
625 | (% element-id="1249" %) | ||
626 | set.Status = new BusinessEntities.LabRestService.ValidCredentialsCall.ResponseStatus(); | ||
627 | |||
628 | (% element-id="1248" %) | ||
629 | set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString(); | ||
630 | |||
631 | (% element-id="1247" %) | ||
632 | set.Status.ErrorMessage = "Exception occurred in GetValidCredentials (username: " + WebserviceUsername + ", with message: " + ex.Message; | ||
633 | |||
634 | |||
635 | (% element-id="1244" %) | ||
636 | ex.Data.Add("WebserviceUsername", WebserviceUsername); | ||
637 | |||
638 | (% element-id="1243" %) | ||
639 | ex.Data.Add("WebservicePassword", WebservicePassword); | ||
640 | |||
641 | (% element-id="1242" %) | ||
642 | ex.Data.Add("CustomerUsername", CustomerUsername); | ||
643 | |||
644 | |||
645 | (% element-id="1239" %) | ||
646 | ExceptionHandler.HandleException(ex); | ||
647 | |||
648 | (% element-id="1238" %) | ||
649 | #endregion | ||
650 | |||
651 | (% element-id="1237" %) | ||
652 | } | ||
653 | |||
654 | |||
655 | (% element-id="1234" %) | ||
656 | return set; | ||
657 | |||
658 | (% element-id="1233" %) | ||
659 | } | ||
660 | ))) | ||
661 | |||
662 | (% element-id="1232" %) | ||
663 | (% element-id="1230" %)|(% element-id="1229" %)(% element-id="1228" %) | ||
664 | ((( | ||
665 | (% element-id="1227" %) | ||
666 | POST https:~/~/<URL>/ValidCredentials HTTP/1.1 | ||
667 | |||
668 | (% element-id="1226" %) | ||
669 | Content-Type: application/x-www-form-urlencoded | ||
670 | |||
671 | (% element-id="1225" %) | ||
672 | Host: 81.175.89.24 | ||
673 | |||
674 | (% element-id="1224" %) | ||
675 | Content-Length: 125 | ||
676 | |||
677 | (% element-id="1223" %) | ||
678 | Expect: 100-continue | ||
679 | |||
680 | |||
681 | (% element-id="1220" %) | ||
682 | userName=<webservice_username>&password=<Webservice_password>&clientId=<optional otherwise empty>&customerUsername=<customer_username or token> | ||
683 | ))) | ||
684 | |||
685 | (% element-id="1219" %) | ||
686 | === (% element-id="1218" %)Response example(%%) === | ||
687 | |||
688 | (% element-id="1217" %) | ||
689 | (% element-id="1215" %)|(% element-id="1214" %)(% element-id="1213" %) | ||
690 | ((( | ||
691 | (% element-id="1212" %) | ||
692 | <?xml version="1.0" encoding="UTF-8" standalone="no"?><Response> | ||
693 | |||
694 | (% element-id="1211" %) | ||
695 | <Status> | ||
696 | |||
697 | (% element-id="1210" %) | ||
698 | <StatusCode>1</StatusCode> | ||
699 | |||
700 | (% element-id="1209" %) | ||
701 | <StatusCodeDescription>OK</StatusCodeDescription> | ||
702 | |||
703 | (% element-id="1208" %) | ||
704 | <ErrorMessage></ErrorMessage> | ||
705 | |||
706 | (% element-id="1207" %) | ||
707 | </Status> | ||
708 | |||
709 | (% element-id="1206" %) | ||
710 | </Response> | ||
711 | ))) | ||
712 | |||
713 | (% element-id="1205" %) | ||
714 | = (% element-id="1204" %)Labassignment request delivery(POST)(%%) = | ||
715 | |||
716 | (% element-id="1203" %) | ||
717 | == (% element-id="1202" %)Solution/Design(%%) == | ||
718 | |||
719 | (% element-id="1201" %) | ||
720 | For this we create a Webservice for CreateOrder to create the order in the lab system. | ||
721 | After the creation, we would like to show an order overview of the laboratory in the future in PDF. The user can see the prices and can confirm or cancel. | ||
722 | Depending on the user's choice at the laboratory, to support this or not, TerraIndex calls the ApproveOrder or the CancelOrder. | ||
723 | |||
724 | (% element-id="0" %) | ||
725 | For default we assume that we cannot do this yet, and TerraIndex sends needsApprovaIsSupported = false. If this becomes true in the future, the Lab can indicate whether or not it is necessary in the NeedsApprove field. | ||
726 | |||
727 | |||
728 | (% class="table-hover" element-id="1195" %) | ||
729 | (% element-id="1193" %)|(% element-id="1192" %)(% element-id="1191" %)**Action**|(% element-id="1190" %)(% element-id="1189" %)**TerraIndex**|(% element-id="1188" %) |(% element-id="1186" %)(% element-id="1185" %)**Laboratorium**|(% element-id="1184" %)(% element-id="1183" %)**Parameters/Message**|(% element-id="1182" %)(% element-id="1181" %)**Remarks**|(% element-id="1180" %)(% element-id="1179" %)**ResultCodes** | ||
730 | (% element-id="1178" %)|(% element-id="1177" %)1|(% element-id="1176" %)Sends a request to the function: CreateOrder().|=(% element-id="1175" %)>|(% element-id="1174" %) |(% element-id="1172" %)WebserviceUsername (string), | ||
731 | WebservicePassword (string), | ||
732 | CustomerUsername (string), | ||
733 | FileContent_Base64 (string), | ||
734 | UseZipStream/UseZip (bool, default: 'false'), | ||
735 | CustomerCode (string), | ||
736 | SIKBVersion (string, default: '13.4.0'), | ||
737 | needsApprovalIsSupported (bool)|(% element-id="1164" %)SIKB Version included, so labs can quickly check the version. | ||
738 | Besides SIKB 13.4.0, TerraIndex also supports 9.0.0. | ||
739 | \\Before sending the SIKB, validate to the XSD! | ||
740 | And to the XSLT? | ||
741 | \\needsApprovalIsSupported = false; means we dont get PDF with offerte. This will make is faster. | ||
742 | needsApprovalIsSupported = true; means lab will check the user setting to send a PDF Offerte back or not. (If the lab can support this.)|(% element-id="1156" %) | ||
743 | (% element-id="1154" %)|(% element-id="1153" %)2|(% element-id="1152" %) |(% element-id="1150" %) |(% element-id="1148" %)Receives the request and checks the credentials.|(% element-id="1147" %) |(% element-id="1145" %) |(% element-id="1143" %) | ||
744 | (% element-id="1141" %)|(% colspan="1" element-id="1140" %)3|(% colspan="1" element-id="1139" %) |(% colspan="1" element-id="1137" %) |(% colspan="1" element-id="1135" %)Credentials are valid, the Filecontent is checked on a valid Labassignment. When valid it will be processed and a OrderId is given.|(% colspan="1" element-id="1134" %) |(% colspan="1" element-id="1132" %)Laboratorium saves the Sample GUIDs if it's SIKB 13 or higher. | ||
745 | Otherwise we use the idanlmons unique ID.|(% colspan="1" element-id="1130" %) | ||
746 | (% element-id="1128" %)|(% colspan="1" element-id="1127" %) |(% colspan="1" element-id="1125" %) |(% colspan="1" element-id="1123" %) |(% colspan="1" element-id="1121" %)Based on what customer, the order will be approved or the approve needs to be done in laboratorium system.|(% colspan="1" element-id="1120" %) |(% colspan="1" element-id="1118" %) |(% colspan="1" element-id="1116" %) | ||
747 | (% element-id="1114" %)|(% element-id="1113" %)4|(% element-id="1112" %) |(% element-id="1110" %)<=|(% element-id="1109" %)Sends back a Success with the new OrderId|(% element-id="1108" %)ResultCode (), | ||
748 | ErrorMessage (string), | ||
749 | OrderId (string), | ||
750 | NeedsApprove (bool), | ||
751 | FileContent_Base64 (string), | ||
752 | UseZipStream/UseZip (bool, default: 'false'),|(% element-id="1102" %)In the future labs will send back the PDF with the prices and some checks. To approve or cancel. For the first version this is not required yet and the fileContent remains empty.|(% element-id="1101" %)1 = Success, | ||
753 | 2 = GeneralError, | ||
754 | 3 = WrongSIKBVersion, | ||
755 | 4 = InvalidCredentials, | ||
756 | 5 = CustomerUsernameInvalid, | ||
757 | 6 = CustomerUsernameNotValidForCustomerCode | ||
758 | 7 = FileContentProblem, | ||
759 | 8 = InvalidOrderId, | ||
760 | 9 = OrderIdAlreadyApproved | ||
761 | 10 = PDFNotAvailable | ||
762 | (% element-id="1091" %)|(% colspan="1" element-id="1090" %)6|(% colspan="1" element-id="1089" %)Receives the OrderId, and saves it. | ||
763 | |(% colspan="1" element-id="1086" %) |(% colspan="1" element-id="1084" %) |(% colspan="1" element-id="1082" %) |(% colspan="1" element-id="1080" %)(% element-id="1079" %) | ||
764 | ((( | ||
765 | (% element-id="1078" %) | ||
766 | Default for now laboratorium will send: | ||
767 | NeedsApprove = False, | ||
768 | PDF = Empty, | ||
769 | Zipstream = False, | ||
770 | |||
771 | |||
772 | (% element-id="1072" %) | ||
773 | In the future, do something with the PDF and show the PDF to users to Approve or Cancel. | ||
774 | This will be done by; NeedsApprove = true. | ||
775 | \\If NeedsApprove is False, the order is Processed and can't be changed in TI. Like it is now. | ||
776 | |||
777 | (% element-id="1068" %) | ||
778 | |||
779 | )))|(% colspan="1" element-id="1066" %) | ||
780 | (% element-id="1064" %)|(% colspan="1" element-id="1063" %) |(% colspan="1" element-id="1061" %) |(% colspan="1" element-id="1059" %) |(% colspan="1" element-id="1057" %) |(% colspan="1" element-id="1055" %) |(% colspan="1" element-id="1053" %) |(% colspan="1" element-id="1051" %) | ||
781 | (% element-id="1049" %)|(% colspan="1" element-id="1048" %) |(% colspan="1" element-id="1046" %) |(% colspan="1" element-id="1044" %) |(% colspan="1" element-id="1042" %) |(% colspan="1" element-id="1040" %) |(% colspan="1" element-id="1038" %) |(% colspan="1" element-id="1036" %) | ||
782 | (% element-id="1034" %)|(% colspan="1" element-id="1033" %) |(% colspan="1" element-id="1031" %)(% element-id="1030" %)**IN THE FUTURE: APPROVEORDER**|(% colspan="1" element-id="1029" %) |(% colspan="1" element-id="1027" %) |(% colspan="1" element-id="1025" %) |(% colspan="1" element-id="1023" %) |(% colspan="1" element-id="1021" %) | ||
783 | (% element-id="1019" %)|(% colspan="1" element-id="1018" %)7|(% colspan="1" element-id="1017" %)Sends a request to the function: ApproveOrder().|(% colspan="1" element-id="1016" %)=>|(% colspan="1" element-id="1015" %) |(% colspan="1" element-id="1013" %)WebserviceUsername (string), | ||
784 | WebservicePassword (string), | ||
785 | CustomerUsername (string), | ||
786 | OrderId (string)|(% colspan="1" element-id="1009" %) |(% colspan="1" element-id="1007" %) | ||
787 | (% element-id="1005" %)|(% colspan="1" element-id="1004" %)8|(% colspan="1" element-id="1003" %) |(% colspan="1" element-id="1001" %) |(% colspan="1" element-id="999" %)Receives the approve and checks the credentials and the OrderId.|(% colspan="1" element-id="998" %) |(% colspan="1" element-id="996" %) |(% colspan="1" element-id="994" %) | ||
788 | (% element-id="992" %)|(% colspan="1" element-id="991" %)9|(% colspan="1" element-id="990" %) |(% colspan="1" element-id="988" %)<=|(% colspan="1" element-id="987" %)Sends back a Success with the new CertificateNr|(% colspan="1" element-id="986" %)ResultCode (), | ||
789 | ErrorMessage (string), | ||
790 | CertificateNr (string)|(% colspan="1" element-id="983" %)This process takes too long at some labs. Maybe this won't be workable...so maybe the CertificateNr return won't be possible. In this case, leave the CertificateNr empty. TerraIndex will read it from GetOrderStatus calls.|(% colspan="1" element-id="982" %)1 = Success, | ||
791 | 2 = GeneralError, | ||
792 | 3 = WrongSIKBVersion, | ||
793 | 4 = InvalidCredentials, | ||
794 | 5 = CustomerUsernameInvalid, | ||
795 | 6 = CustomerUsernameNotValidForCustomerCode | ||
796 | 7 = FileContentProblem, | ||
797 | 8 = InvalidOrderId, | ||
798 | 9 = OrderIdAlreadyApproved | ||
799 | 10 = PDFNotAvailable | ||
800 | (% element-id="972" %)|(% colspan="1" element-id="971" %)10|(% colspan="1" element-id="970" %)Receives the CerificateNr and saves it.|(% colspan="1" element-id="969" %) |(% colspan="1" element-id="967" %) |(% colspan="1" element-id="965" %) |(% colspan="1" element-id="963" %) |(% colspan="1" element-id="961" %) | ||
801 | (% element-id="959" %)|(% colspan="1" element-id="958" %) |(% colspan="1" element-id="956" %) |(% colspan="1" element-id="954" %) |(% colspan="1" element-id="952" %) |(% colspan="1" element-id="950" %) |(% colspan="1" element-id="948" %) |(% colspan="1" element-id="946" %) | ||
802 | (% element-id="944" %)|(% colspan="1" element-id="943" %) |(% colspan="1" element-id="941" %)(% element-id="940" %)**IN THE FUTURE: CANCELORDER**|(% colspan="1" element-id="939" %) |(% colspan="1" element-id="937" %) |(% colspan="1" element-id="935" %) |(% colspan="1" element-id="933" %) |(% colspan="1" element-id="931" %) | ||
803 | (% element-id="929" %)|(% element-id="928" %)7|(% element-id="927" %)Sends a request to the function: CancelOrder().|=(% element-id="926" %)>|(% element-id="925" %) |(% element-id="923" %)WebserviceUsername (string), | ||
804 | WebservicePassword (string), | ||
805 | CustomerUsername (string), | ||
806 | OrderId (string)|(% element-id="919" %) |(% element-id="917" %) | ||
807 | (% element-id="915" %)|(% element-id="914" %)8|(% element-id="913" %) |(% element-id="911" %) |(% element-id="909" %)Receives the cancel and checks the credentials and the OrderId.|(% element-id="908" %) |(% element-id="906" %) |(% element-id="904" %) | ||
808 | (% element-id="902" %)|(% element-id="901" %)9|(% element-id="900" %) |(% element-id="898" %)<=|(% element-id="897" %)Sends back a Success |(% element-id="896" %)ResultCode (), | ||
809 | ErrorMessage (string)|(% element-id="894" %) |(% element-id="892" %)1 = Success, | ||
810 | 2 = GeneralError, | ||
811 | 3 = WrongSIKBVersion, | ||
812 | 4 = InvalidCredentials, | ||
813 | 5 = CustomerUsernameInvalid, | ||
814 | 6 = CustomerUsernameNotValidForCustomerCode | ||
815 | 7 = FileContentProblem, | ||
816 | 8 = InvalidOrderId, | ||
817 | 9 = OrderIdAlreadyApproved | ||
818 | 10 = PDFNotAvailable | ||
819 | (% element-id="882" %)|(% element-id="881" %)10|(% element-id="880" %)Removes the OrderId and the IsSend to False|(% element-id="879" %) |(% element-id="877" %) |(% element-id="875" %) |(% element-id="873" %)If OrderIsAleadyApproved, set the values to Approved and keep the OrderId and IsSend.|(% element-id="872" %) | ||
820 | (% element-id="870" %)|(% colspan="1" element-id="869" %) |(% colspan="1" element-id="867" %) |(% colspan="1" element-id="865" %) |(% colspan="1" element-id="863" %) |(% colspan="1" element-id="861" %) |(% colspan="1" element-id="859" %) |(% colspan="1" element-id="857" %) | ||
821 | |||
822 | (% element-id="855" %) | ||
823 | == (% element-id="854" %)Create Order(%%) == | ||
824 | |||
825 | (% element-id="853" %) | ||
826 | === (% element-id="852" %)Request example(%%) === | ||
827 | |||
828 | (% element-id="851" %) | ||
829 | (% element-id="849" %)|(% element-id="848" %)(% element-id="847" %) | ||
830 | ((( | ||
831 | (% element-id="846" %) | ||
832 | public CreateOrderResponse.Response SendLabAssignment(string WebserviceUsername, string WebservicePassword, string CustomerUsername, string customerid, string sikbVersion, string assignmentXML, string languageCode, bool needsApprovalIsSupported = false) | ||
833 | |||
834 | (% element-id="845" %) | ||
835 | { | ||
836 | |||
837 | (% element-id="844" %) | ||
838 | CreateOrderResponse.Response set = new CreateOrderResponse.Response(); | ||
839 | |||
840 | |||
841 | (% element-id="841" %) | ||
842 | try | ||
843 | |||
844 | (% element-id="840" %) | ||
845 | { | ||
846 | |||
847 | (% element-id="839" %) | ||
848 | bool useZipstream = true; | ||
849 | |||
850 | |||
851 | (% element-id="836" %) | ||
852 | MultipartFormDataContent content = new MultipartFormDataContent(); | ||
853 | |||
854 | |||
855 | (% element-id="833" %) | ||
856 | ~/~/Add Formdata | ||
857 | |||
858 | (% element-id="832" %) | ||
859 | var formDataDictionary = new[] | ||
860 | |||
861 | (% element-id="831" %) | ||
862 | { | ||
863 | |||
864 | (% element-id="830" %) | ||
865 | new KeyValuePair<string, string>("userName", WebserviceUsername), | ||
866 | |||
867 | (% element-id="829" %) | ||
868 | new KeyValuePair<string, string>("password", WebservicePassword), | ||
869 | |||
870 | (% element-id="828" %) | ||
871 | new KeyValuePair<string, string>("customerUserName", CustomerUsername), | ||
872 | |||
873 | (% element-id="827" %) | ||
874 | new KeyValuePair<string, string>("clientId", customerid), | ||
875 | |||
876 | (% element-id="826" %) | ||
877 | new KeyValuePair<string, string>("sikbVersion", sikbVersion), | ||
878 | |||
879 | (% element-id="825" %) | ||
880 | new KeyValuePair<string, string>("languageCode", languageCode), | ||
881 | |||
882 | (% element-id="824" %) | ||
883 | new KeyValuePair<string, string>("useZip", useZipstream.ToString() ), | ||
884 | |||
885 | (% element-id="823" %) | ||
886 | new KeyValuePair<string, string>("needsApprovalIsSupported", needsApprovalIsSupported.ToString() ), | ||
887 | |||
888 | (% element-id="822" %) | ||
889 | ~/~/new KeyValuePair<string, string>("orderXml", ZipStreamHelper.CompressToBase64String(assignmentXML)), | ||
890 | |||
891 | (% element-id="821" %) | ||
892 | ~/~/new KeyValuePair<string, string>("orderXml", assignmentXML), | ||
893 | |||
894 | (% element-id="820" %) | ||
895 | }; | ||
896 | |||
897 | (% element-id="819" %) | ||
898 | foreach (var item in formDataDictionary) | ||
899 | |||
900 | (% element-id="818" %) | ||
901 | { | ||
902 | |||
903 | (% element-id="817" %) | ||
904 | content.Add(new StringContent(item.Value), $"\"{item.Key}\""); | ||
905 | |||
906 | (% element-id="816" %) | ||
907 | } | ||
908 | |||
909 | |||
910 | (% element-id="813" %) | ||
911 | string filexml = string.Empty; | ||
912 | |||
913 | (% element-id="812" %) | ||
914 | if (useZipstream) | ||
915 | |||
916 | (% element-id="811" %) | ||
917 | { | ||
918 | |||
919 | (% element-id="810" %) | ||
920 | filexml = ZipStreamHelper.CompressToBase64String(assignmentXML); | ||
921 | |||
922 | (% element-id="809" %) | ||
923 | } | ||
924 | |||
925 | (% element-id="808" %) | ||
926 | else | ||
927 | |||
928 | (% element-id="807" %) | ||
929 | { | ||
930 | |||
931 | (% element-id="806" %) | ||
932 | filexml = assignmentXML; | ||
933 | |||
934 | (% element-id="805" %) | ||
935 | } | ||
936 | |||
937 | |||
938 | (% element-id="802" %) | ||
939 | ~/~/Add filecontent | ||
940 | |||
941 | (% element-id="801" %) | ||
942 | var fileContent = new ByteArrayContent(ZipStreamHelper.stringToByteArray(filexml)); | ||
943 | |||
944 | (% element-id="800" %) | ||
945 | fileContent.Headers.ContentDisposition = | ||
946 | |||
947 | (% element-id="799" %) | ||
948 | new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") ~/~/<- 'form-data' instead of 'attachment' | ||
949 | |||
950 | (% element-id="798" %) | ||
951 | { | ||
952 | |||
953 | (% element-id="797" %) | ||
954 | Name = "\"orderXml\"", ~/~/ \" is needed so the message contains the quotes, wihtout it will fail | ||
955 | |||
956 | (% element-id="796" %) | ||
957 | FileName = "\"VivaTerraIndexAssignment.xml\"" | ||
958 | |||
959 | (% element-id="795" %) | ||
960 | }; | ||
961 | |||
962 | (% element-id="794" %) | ||
963 | fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/xml"); | ||
964 | |||
965 | (% element-id="793" %) | ||
966 | content.Add(fileContent); | ||
967 | |||
968 | |||
969 | (% element-id="790" %) | ||
970 | ~/~/Start sending | ||
971 | |||
972 | |||
973 | (% element-id="787" %) | ||
974 | HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/CreateOrder", content).Result; | ||
975 | |||
976 | (% element-id="786" %) | ||
977 | response.EnsureSuccessStatusCode(); | ||
978 | |||
979 | (% element-id="785" %) | ||
980 | string responseMessage = response.Content.ReadAsStringAsync().Result; | ||
981 | |||
982 | |||
983 | (% element-id="782" %) | ||
984 | if (string.IsNullOrEmpty(responseMessage)) | ||
985 | |||
986 | (% element-id="781" %) | ||
987 | { | ||
988 | |||
989 | (% element-id="780" %) | ||
990 | throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " /CreateOrder" + "]"); | ||
991 | |||
992 | (% element-id="779" %) | ||
993 | } | ||
994 | |||
995 | (% element-id="778" %) | ||
996 | using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage~)~)~) | ||
997 | |||
998 | (% element-id="777" %) | ||
999 | { | ||
1000 | |||
1001 | (% element-id="776" %) | ||
1002 | XmlSerializer serializer = new XmlSerializer(typeof(CreateOrderResponse.Response)); | ||
1003 | |||
1004 | (% element-id="775" %) | ||
1005 | set = (CreateOrderResponse.Response)serializer.Deserialize(ms); | ||
1006 | |||
1007 | (% element-id="774" %) | ||
1008 | } | ||
1009 | |||
1010 | |||
1011 | (% element-id="771" %) | ||
1012 | ~/~/Can contain a PDf with price information | ||
1013 | |||
1014 | (% element-id="770" %) | ||
1015 | if (set.UseZip && !string.IsNullOrEmpty(set.FileContent)) | ||
1016 | |||
1017 | (% element-id="769" %) | ||
1018 | { | ||
1019 | |||
1020 | (% element-id="768" %) | ||
1021 | ~/~/convert from base64 string back to normal | ||
1022 | |||
1023 | (% element-id="767" %) | ||
1024 | set.FileContent = ZipStreamHelper.DecompressBase64StringToString(set.FileContent); | ||
1025 | |||
1026 | (% element-id="766" %) | ||
1027 | } | ||
1028 | |||
1029 | |||
1030 | (% element-id="763" %) | ||
1031 | } | ||
1032 | |||
1033 | (% element-id="762" %) | ||
1034 | catch (Exception ex) | ||
1035 | |||
1036 | (% element-id="761" %) | ||
1037 | { | ||
1038 | |||
1039 | (% element-id="760" %) | ||
1040 | #region handle exception | ||
1041 | |||
1042 | |||
1043 | (% element-id="757" %) | ||
1044 | set.Status = new BusinessEntities.LabRestService.CreateOrderResponse.ResponseStatus(); | ||
1045 | |||
1046 | (% element-id="756" %) | ||
1047 | set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString(); | ||
1048 | |||
1049 | (% element-id="755" %) | ||
1050 | set.Status.ErrorMessage = "Exception occurred in CreateOrder (username: " + WebserviceUsername + ") with message: " + ex.Message; | ||
1051 | |||
1052 | |||
1053 | (% element-id="752" %) | ||
1054 | ex.Data.Add("WebserviceUsername", WebserviceUsername); | ||
1055 | |||
1056 | (% element-id="751" %) | ||
1057 | ex.Data.Add("WebservicePassword", WebservicePassword); | ||
1058 | |||
1059 | (% element-id="750" %) | ||
1060 | ex.Data.Add("CustomerUsername", CustomerUsername); | ||
1061 | |||
1062 | (% element-id="749" %) | ||
1063 | ex.Data.Add("sikbVersion", sikbVersion); | ||
1064 | |||
1065 | (% element-id="748" %) | ||
1066 | ex.Data.Add("customerid", customerid); | ||
1067 | |||
1068 | |||
1069 | (% element-id="745" %) | ||
1070 | ExceptionHandler.HandleException(ex); | ||
1071 | |||
1072 | (% element-id="744" %) | ||
1073 | #endregion | ||
1074 | |||
1075 | (% element-id="743" %) | ||
1076 | } | ||
1077 | |||
1078 | |||
1079 | (% element-id="740" %) | ||
1080 | return set; | ||
1081 | |||
1082 | (% element-id="739" %) | ||
1083 | } | ||
1084 | ))) | ||
1085 | |||
1086 | (% element-id="738" %) | ||
1087 | (% element-id="736" %)|(% element-id="735" %)(% element-id="734" %) | ||
1088 | ((( | ||
1089 | (% element-id="733" %) | ||
1090 | POST https:~/~/<URL>/CreateOrder HTTP/1.1 | ||
1091 | |||
1092 | (% element-id="732" %) | ||
1093 | Content-Type: multipart/form-data; boundary="28a3e130-70c9-4a1a-b544-a802a1ade6ca" | ||
1094 | |||
1095 | (% element-id="731" %) | ||
1096 | Host: 81.175.89.24 | ||
1097 | |||
1098 | (% element-id="730" %) | ||
1099 | Content-Length: 5010 | ||
1100 | |||
1101 | (% element-id="729" %) | ||
1102 | Expect: 100-continue | ||
1103 | |||
1104 | |||
1105 | (% element-id="726" %) | ||
1106 | ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca | ||
1107 | |||
1108 | (% element-id="725" %) | ||
1109 | Content-Type: text/plain; charset=utf-8 | ||
1110 | |||
1111 | (% element-id="724" %) | ||
1112 | Content-Disposition: form-data; name="userName" | ||
1113 | |||
1114 | |||
1115 | (% element-id="721" %) | ||
1116 | <Webservice_Username> | ||
1117 | |||
1118 | (% element-id="720" %) | ||
1119 | ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca | ||
1120 | |||
1121 | (% element-id="719" %) | ||
1122 | Content-Type: text/plain; charset=utf-8 | ||
1123 | |||
1124 | (% element-id="718" %) | ||
1125 | Content-Disposition: form-data; name="password" | ||
1126 | |||
1127 | |||
1128 | (% element-id="715" %) | ||
1129 | <Webservice_Password> | ||
1130 | |||
1131 | (% element-id="714" %) | ||
1132 | ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca | ||
1133 | |||
1134 | (% element-id="713" %) | ||
1135 | Content-Type: text/plain; charset=utf-8 | ||
1136 | |||
1137 | (% element-id="712" %) | ||
1138 | Content-Disposition: form-data; name="customerUserName" | ||
1139 | |||
1140 | |||
1141 | (% element-id="709" %) | ||
1142 | <Customer_Username or token> | ||
1143 | |||
1144 | (% element-id="708" %) | ||
1145 | ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca | ||
1146 | |||
1147 | (% element-id="707" %) | ||
1148 | Content-Type: text/plain; charset=utf-8 | ||
1149 | |||
1150 | (% element-id="706" %) | ||
1151 | Content-Disposition: form-data; name="clientId" | ||
1152 | |||
1153 | |||
1154 | (% element-id="703" %) | ||
1155 | 300 | ||
1156 | |||
1157 | (% element-id="702" %) | ||
1158 | ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca | ||
1159 | |||
1160 | (% element-id="701" %) | ||
1161 | Content-Type: text/plain; charset=utf-8 | ||
1162 | |||
1163 | (% element-id="700" %) | ||
1164 | Content-Disposition: form-data; name="sikbVersion" | ||
1165 | |||
1166 | |||
1167 | (% element-id="697" %) | ||
1168 | 13.4.0 | ||
1169 | |||
1170 | (% element-id="696" %) | ||
1171 | ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca | ||
1172 | |||
1173 | (% element-id="695" %) | ||
1174 | Content-Type: text/plain; charset=utf-8 | ||
1175 | |||
1176 | (% element-id="694" %) | ||
1177 | Content-Disposition: form-data; name="languageCode" | ||
1178 | |||
1179 | |||
1180 | (% element-id="691" %) | ||
1181 | nld | ||
1182 | |||
1183 | (% element-id="690" %) | ||
1184 | ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca | ||
1185 | |||
1186 | (% element-id="689" %) | ||
1187 | Content-Type: text/plain; charset=utf-8 | ||
1188 | |||
1189 | (% element-id="688" %) | ||
1190 | Content-Disposition: form-data; name="useZip" | ||
1191 | |||
1192 | |||
1193 | (% element-id="685" %) | ||
1194 | True | ||
1195 | |||
1196 | (% element-id="684" %) | ||
1197 | ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca | ||
1198 | |||
1199 | (% element-id="683" %) | ||
1200 | Content-Type: text/plain; charset=utf-8 | ||
1201 | |||
1202 | (% element-id="682" %) | ||
1203 | Content-Disposition: form-data; name="needsApprovalIsSupported" | ||
1204 | |||
1205 | |||
1206 | (% element-id="679" %) | ||
1207 | False | ||
1208 | |||
1209 | (% element-id="678" %) | ||
1210 | ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca | ||
1211 | |||
1212 | (% element-id="677" %) | ||
1213 | Content-Disposition: form-data; name="orderXml"; filename="VivaTerraIndexAssignment.xml" | ||
1214 | |||
1215 | (% element-id="676" %) | ||
1216 | Content-Type: application/xml | ||
1217 | |||
1218 | |||
1219 | (% element-id="673" %) | ||
1220 | <SIKB File in Zip stream Base64 encoding> | ||
1221 | |||
1222 | (% element-id="672" %) | ||
1223 | ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca~-~- | ||
1224 | ))) | ||
1225 | |||
1226 | (% element-id="671" %) | ||
1227 | === (% element-id="670" %)Response example(%%) === | ||
1228 | |||
1229 | (% element-id="669" %) | ||
1230 | (% element-id="667" %)|(% element-id="666" %)(% element-id="665" %) | ||
1231 | ((( | ||
1232 | (% element-id="664" %) | ||
1233 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
1234 | |||
1235 | (% element-id="663" %) | ||
1236 | <Response> | ||
1237 | |||
1238 | (% element-id="662" %) | ||
1239 | <OrderId>7113828</OrderId> | ||
1240 | |||
1241 | (% element-id="661" %) | ||
1242 | <NeedsApproval>True</NeedsApproval> | ||
1243 | |||
1244 | (% element-id="660" %) | ||
1245 | <FileContent></FileContent> | ||
1246 | |||
1247 | (% element-id="659" %) | ||
1248 | <Status> | ||
1249 | |||
1250 | (% element-id="658" %) | ||
1251 | <StatusCode>1</StatusCode> | ||
1252 | |||
1253 | (% element-id="657" %) | ||
1254 | <StatusCodeDescription>OK</StatusCodeDescription> | ||
1255 | |||
1256 | (% element-id="656" %) | ||
1257 | <ErrorMessage></ErrorMessage> | ||
1258 | |||
1259 | (% element-id="655" %) | ||
1260 | </Status></Response> | ||
1261 | ))) | ||
1262 | |||
1263 | (% element-id="654" %) | ||
1264 | = (% element-id="653" %)Get Order status and Results XML and with PDF(%%) = | ||
1265 | |||
1266 | (% element-id="652" %) | ||
1267 | == (% element-id="651" %)Solution/Design(%%) == | ||
1268 | |||
1269 | (% element-id="650" %) | ||
1270 | TerraIndex will request per license/customer which results are ready. These are queried if the latest changes are newer than the last check. This way we never download too much unnecessarily and it can always be requested again. | ||
1271 | |||
1272 | |||
1273 | (% class="box infomessage" element-id="650" %) | ||
1274 | ((( | ||
1275 | **Order status** we support as minimal: | ||
1276 | 3 = Reportnumber is known, no results yet, but it's the official report certificate number. This is optional to send. | ||
1277 | 4 = Conceptual, temporary results avaiable, but not final yet. This is optional to send. | ||
1278 | 5 = Final results are available. This is required to send. | ||
1279 | ))) | ||
1280 | |||
1281 | (% class="table-hover" element-id="647" %) | ||
1282 | (% element-id="645" %)|(% element-id="644" %)Action|(% element-id="643" %)TerraIndex|(% element-id="642" %) |(% element-id="640" %)Laboratorium|(% element-id="639" %)Parameters/Message|(% element-id="638" %)Remarks|(% element-id="637" %)ResultCodes | ||
1283 | (% element-id="636" %)|(% element-id="635" %)1|(% element-id="634" %)Sends a request to the function: GetCustomers().|=(% element-id="633" %)>|(% element-id="632" %) |(% element-id="630" %)WebserviceUsername (string), | ||
1284 | WebservicePassword (string), | ||
1285 | CustomerUsername (string)|(% element-id="627" %)We want to skip the Password of the customer, and we introduce the WebserviceUsername + WebservicePassword.|(% element-id="626" %) | ||
1286 | (% element-id="624" %)|(% element-id="623" %)2|(% element-id="622" %) |(% element-id="620" %) |(% element-id="618" %)Receives the request and check the customers this username and searches the dateLastChanged for this Customer.|(% element-id="617" %) |(% element-id="615" %) |(% element-id="613" %) | ||
1287 | (% element-id="611" %)|(% element-id="610" %)3|(% element-id="609" %) |(% element-id="607" %)<=|(% element-id="606" %)Sends back the list of customers to check for orderStatuses|(% element-id="605" %)ResultCode (), | ||
1288 | ErrorMessage (string), | ||
1289 | List<customer> , Customer: | ||
1290 | CustomerCode (string), | ||
1291 | CustomerName (string), | ||
1292 | LabID (int), | ||
1293 | LabName (string), | ||
1294 | ChangedTimeStamp (DateTime)|(% element-id="597" %)We receive the dateTimestamp instead of sending it, so we always get the full list and we are also able to delete customercodes.|(% element-id="596" %)1 = Success, | ||
1295 | 2 = GeneralError, | ||
1296 | 3 = WrongSIKBVersion, | ||
1297 | 4 = InvalidCredentials, | ||
1298 | 5 = CustomerUsernameInvalid, | ||
1299 | 6 = CustomerUsernameNotValidForCustomerCode | ||
1300 | 7 = FileContentProblem, | ||
1301 | 8 = InvalidOrderId, | ||
1302 | 9 = OrderIdAlreadyApproved | ||
1303 | 10 = PDFNotAvailable | ||
1304 | (% element-id="586" %)|(% element-id="585" %)4|(% element-id="584" %)Receives the list of Customers. Read the Timestamp this Customer is last checked for Results/Statuses.|(% element-id="583" %) |(% element-id="581" %) |(% element-id="579" %) |(% element-id="577" %) |(% element-id="575" %) | ||
1305 | (% element-id="573" %)|(% element-id="572" %)5|(% element-id="571" %)Send for each Customer a call to retreive all orders statuses changes since a certain timestamp. | ||
1306 | Function: GetOrderStatuses()|=(% element-id="569" %)>|(% element-id="568" %) |(% element-id="566" %)WebserviceUsername (string), | ||
1307 | WebservicePassword (string), | ||
1308 | CustomerUsername (string), | ||
1309 | CustomerCode (string), | ||
1310 | LastCheckedTimestamp (DateTime)|(% element-id="561" %)TerraIndex keeps track of the last check timestamp for each license.|(% element-id="560" %) | ||
1311 | (% element-id="558" %)|(% element-id="557" %)6|(% element-id="556" %) |(% element-id="554" %) |(% element-id="552" %)Receives the request and check the orders that are changed since the timestamp for this Customer.|(% element-id="551" %) |(% element-id="549" %) |(% element-id="547" %) | ||
1312 | (% element-id="545" %)|(% element-id="544" %)7|(% element-id="543" %) |(% element-id="541" %)<=|(% element-id="540" %)Sends back the list of orders with the status and lastChangedTimestamp|(% element-id="539" %)ResultCode (), | ||
1313 | ErrorMessage (string), | ||
1314 | OrderID (string), | ||
1315 | LabassignmentGUID (GUID), | ||
1316 | CertificateNumber (string) | ||
1317 | OrderStatusSIKB (int), | ||
1318 | Delayed (boolean), | ||
1319 | ExpectedTimeStamp (DateTime),|(% element-id="531" %)OrderStatusSIKB is the SIKB Labassignment status. | ||
1320 | \\Delayed is a boolean to tell the customer a order will be later ready then expected. The ExpectedTimestamp. | ||
1321 | If Delayed for the firsttime, TerraIndex can send a notification to the users and show a different layout. | ||
1322 | \\LabassignmentGUID is filled to support also Labassignments that are not from TerraIndex Ordered.|(% element-id="525" %)1 = Success, | ||
1323 | 2 = GeneralError, | ||
1324 | 3 = WrongSIKBVersion, | ||
1325 | 4 = InvalidCredentials, | ||
1326 | 5 = CustomerUsernameInvalid, | ||
1327 | 6 = CustomerUsernameNotValidForCustomerCode | ||
1328 | 7 = FileContentProblem, | ||
1329 | 8 = InvalidOrderId, | ||
1330 | 9 = OrderIdAlreadyApproved | ||
1331 | 10 = PDFNotAvailable | ||
1332 | (% element-id="515" %)|(% element-id="514" %)8|(% element-id="513" %)Receives the list of Orders with status. | ||
1333 | Update the CertificateNr if this is not already present in the labassignment. |(% element-id="511" %) |(% element-id="509" %) |(% element-id="507" %) |(% element-id="505" %)CertifcateNumber could be new here, if the lab wasn't able to fill it directly at the ApproveOrder.|(% element-id="504" %) | ||
1334 | (% element-id="502" %)|(% element-id="501" %)9|(% element-id="500" %)Send for each Order a call to retreive all results. | ||
1335 | Function: GetOrderResults()|=(% element-id="498" %)>|(% element-id="497" %) |(% element-id="495" %)WebserviceUsername (string), | ||
1336 | WebservicePassword (string), | ||
1337 | CustomerUsername (string), | ||
1338 | CustomerCode (string), | ||
1339 | OrderID (string), | ||
1340 | SIKBVersion (string, default: '13.4.0')|(% element-id="489" %)Besides SIKB 13.4.0, TerraIndex also supports 9.0.0/8.0.0 etc.|(% element-id="488" %) | ||
1341 | (% element-id="486" %)|(% element-id="485" %)10|(% element-id="484" %) |(% element-id="482" %) |(% element-id="480" %)Receives the request and creates a SIKB results file based on the version that is requested.|(% element-id="479" %) |(% element-id="477" %) |(% element-id="475" %) | ||
1342 | (% element-id="473" %)|(% element-id="472" %)11|(% element-id="471" %) |(% element-id="469" %)<=|(% element-id="468" %)Sends back the results of the orders.|(% element-id="467" %)ResultCode (), | ||
1343 | ErrorMessage (string), | ||
1344 | OrderId (string), | ||
1345 | LabassignmentGUID (GUID), | ||
1346 | FileContent_Base64 (string), | ||
1347 | UseZipStream/UseZip (bool, default: 'false'),|(% element-id="461" %) |(% element-id="459" %)1 = Success, | ||
1348 | 2 = GeneralError, | ||
1349 | 3 = WrongSIKBVersion, | ||
1350 | 4 = InvalidCredentials, | ||
1351 | 5 = CustomerUsernameInvalid, | ||
1352 | 6 = CustomerUsernameNotValidForCustomerCode | ||
1353 | 7 = FileContentProblem, | ||
1354 | 8 = InvalidOrderId, | ||
1355 | 9 = OrderIdAlreadyApproved | ||
1356 | 10 = PDFNotAvailable | ||
1357 | (% element-id="449" %)|(% element-id="448" %)12|(% element-id="447" %)Receives the results and imports all results.|(% element-id="446" %) |(% element-id="444" %) |(% element-id="442" %) |(% element-id="440" %)(% element-id="439" %) | ||
1358 | ((( | ||
1359 | (% element-id="438" %) | ||
1360 | Import will be done to corresponding samples based on: | ||
1361 | |||
1362 | (% element-id="437" %) | ||
1363 | * Find Project by ProjectGUID (as provided in the labassignment) | ||
1364 | * Find Project by ProjectCode (as provided in the Labassignment) | ||
1365 | * Find Project and Labassignment by LabassignmentGUID (as provided in the Labassignment) | ||
1366 | * Find Project (only if Project is not found yet) and Samples based on SampleGUID (as provided in the Labassignment) . | ||
1367 | Sample GUIDs that are send to the lab in the labassignment version SIKB 13 or higher are required in the results for labassignment. | ||
1368 | For lower version Labassignments the lab should return the 'old' idanlmons as SampleGUID in the XML. | ||
1369 | * Find Samples (only if Project is already found ) by SampleName | ||
1370 | |||
1371 | (% element-id="429" %) | ||
1372 | What is imported? | ||
1373 | |||
1374 | (% element-id="428" %) | ||
1375 | * If Sample is found, the results in the XML are always all updated and/or inserted. | ||
1376 | * If Project is found, but the sample is not; The Sample and the results are inserted as new Sample. (If watersample; fake filtertube and fake measurementpoints are created) | ||
1377 | )))|(% element-id="425" %) | ||
1378 | (% element-id="423" %)|(% element-id="422" %)13|(% element-id="421" %)If OrderStatus is 'Completed/Reported' (SIKBID: 5) | ||
1379 | Request the PDF certificate. | ||
1380 | Function: GetOrderPDF()|=(% element-id="418" %)>|(% element-id="417" %) |(% element-id="415" %)WebserviceUsername (string), | ||
1381 | WebservicePassword (string), | ||
1382 | CustomerUsername (string), | ||
1383 | CustomerCode (string), | ||
1384 | OrderID (string),|(% element-id="410" %) |(% element-id="408" %) | ||
1385 | (% element-id="406" %)|(% element-id="405" %)14|(% element-id="404" %) |(% element-id="402" %) |(% element-id="400" %)Receives the request and creates the PDF for the Order.|(% element-id="399" %) |(% element-id="397" %) |(% element-id="395" %) | ||
1386 | (% element-id="393" %)|(% element-id="392" %)15|(% element-id="391" %) |(% element-id="389" %)<=|(% element-id="388" %)Sends back the PDF of the order.|(% element-id="387" %)ResultCode (), | ||
1387 | ErrorMessage (string), | ||
1388 | OrderId (string), | ||
1389 | LabassignmentGUID (GUID), | ||
1390 | FileContent_Base64 (string), | ||
1391 | UseZipStream/UseZip (bool, default: 'false'),|(% element-id="381" %)If the PDF is not available yet, please give the resultcode: PDFNotAvailable.|(% element-id="380" %)1 = Success, | ||
1392 | 2 = GeneralError, | ||
1393 | 3 = WrongSIKBVersion, | ||
1394 | 4 = InvalidCredentials, | ||
1395 | 5 = CustomerUsernameInvalid, | ||
1396 | 6 = CustomerUsernameNotValidForCustomerCode | ||
1397 | 7 = FileContentProblem, | ||
1398 | 8 = InvalidOrderId, | ||
1399 | 9 = OrderIdAlreadyApproved | ||
1400 | 10 = PDFNotAvailable | ||
1401 | (% element-id="370" %)|(% element-id="369" %)12|(% element-id="368" %)Receives the PDF and stores it for reporting and downloading.|(% element-id="367" %) |(% element-id="365" %) |(% element-id="363" %) |(% element-id="361" %) |(% element-id="359" %) | ||
1402 | |||
1403 | (% element-id="357" %) | ||
1404 | == Request example Order Status == | ||
1405 | |||
1406 | public GetOrderStatusesCall.Response OrderStatuses(string WebserviceUsername, string WebservicePassword, string CustomerUsername, string customerid, DateTime? timestampSince) | ||
1407 | { | ||
1408 | GetOrderStatusesCall.Response set = new GetOrderStatusesCall.Response(); | ||
1409 | string responseMessage = null; | ||
1410 | |||
1411 | if (timestampSince == null) timestampSince = DateTime.Now.AddHours(-3); ~/~/Now, minus 3 hours | ||
1412 | var formattedTimestamp = System.Xml.XmlConvert.ToString((DateTime)timestampSince, System.Xml.XmlDateTimeSerializationMode.RoundtripKind); | ||
1413 | |||
1414 | try | ||
1415 | { | ||
1416 | var content = new FormUrlEncodedContent(new[] | ||
1417 | { | ||
1418 | new KeyValuePair<string, string>("userName", WebserviceUsername), | ||
1419 | new KeyValuePair<string, string>("password", WebservicePassword), | ||
1420 | new KeyValuePair<string, string>("customerUsername", CustomerUsername), | ||
1421 | new KeyValuePair<string, string>("clientId", customerid), | ||
1422 | new KeyValuePair<string, string>("lastModified", formattedTimestamp), | ||
1423 | }); | ||
1424 | |||
1425 | HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/GetOrderStatuses", content).GetAwaiter().GetResult(); | ||
1426 | responseMessage = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); | ||
1427 | response.EnsureSuccessStatusCode(); | ||
1428 | |||
1429 | if (string.IsNullOrEmpty(responseMessage)) | ||
1430 | { | ||
1431 | throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " /GetOrderStatuses" + "]"); | ||
1432 | } | ||
1433 | using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage~)~)~) | ||
1434 | { | ||
1435 | XmlSerializer serializer = new XmlSerializer(typeof(GetOrderStatusesCall.Response)); | ||
1436 | set = (GetOrderStatusesCall.Response)serializer.Deserialize(ms); | ||
1437 | } | ||
1438 | |||
1439 | } | ||
1440 | catch (Exception ex) | ||
1441 | { | ||
1442 | #region handle exception | ||
1443 | |||
1444 | set.Status = new BusinessEntities.LabRestService.GetOrderStatusesCall.ResponseStatus(); | ||
1445 | set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString(); | ||
1446 | set.Status.ErrorMessage = "Exception occurred in GetOrderStatuses (username: " + WebserviceUsername + ", password: " + WebservicePassword + ") with message: " + ex.ToString(); | ||
1447 | |||
1448 | ex.Data.Add("Response", responseMessage); | ||
1449 | ex.Data.Add("WebserviceUsername", WebserviceUsername); | ||
1450 | ex.Data.Add("WebservicePassword", WebservicePassword); | ||
1451 | ex.Data.Add("CustomerUsername", CustomerUsername); | ||
1452 | ex.Data.Add("customerid", customerid); | ||
1453 | ex.Data.Add("lastModified", formattedTimestamp); | ||
1454 | ex.Data.Add("Result", set); | ||
1455 | |||
1456 | throw; | ||
1457 | #endregion | ||
1458 | } | ||
1459 | |||
1460 | return set; | ||
1461 | } | ||
1462 | |||
1463 | == Response Status XML Example == | ||
1464 | |||
1465 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
1466 | <Response> | ||
1467 | <Orders> | ||
1468 | <Order> | ||
1469 | <OrderStatus>Reported</OrderStatus> | ||
1470 | <SIKBOrderId></SIKBOrderId> | ||
1471 | <SIKBOrderStatus>5</SIKBOrderStatus> | ||
1472 | <OrderId>4855422</OrderId> | ||
1473 | <RapportNummer>12193838</RapportNummer> | ||
1474 | <IsDelayed>False</IsDelayed> | ||
1475 | <ExpectedOn>09/10/2015 17:15:00</ExpectedOn> | ||
1476 | </Order> | ||
1477 | <Order> | ||
1478 | <OrderStatus>New</OrderStatus> | ||
1479 | <SIKBOrderId></SIKBOrderId> | ||
1480 | <SIKBOrderStatus>3</SIKBOrderStatus> | ||
1481 | <OrderId>7106525</OrderId> | ||
1482 | <RapportNummer>02808304-0749-41ae-96eb-d62b0365ebe4</RapportNummer> | ||
1483 | <IsDelayed>False</IsDelayed> | ||
1484 | <ExpectedOn></ExpectedOn> | ||
1485 | </Order> | ||
1486 | <Order> | ||
1487 | <OrderStatus>New</OrderStatus> | ||
1488 | <SIKBOrderId></SIKBOrderId> | ||
1489 | <SIKBOrderStatus>3</SIKBOrderStatus> | ||
1490 | <OrderId>7108954</OrderId> | ||
1491 | <RapportNummer>10776137-ef99-4947-9a6a-9a3b32cd2dec</RapportNummer> | ||
1492 | <IsDelayed>False</IsDelayed> | ||
1493 | <ExpectedOn></ExpectedOn> | ||
1494 | </Order> | ||
1495 | <Order> | ||
1496 | <OrderStatus>New</OrderStatus> | ||
1497 | <SIKBOrderId></SIKBOrderId> | ||
1498 | <SIKBOrderStatus>3</SIKBOrderStatus> | ||
1499 | <OrderId>7110401</OrderId> | ||
1500 | <RapportNummer>7881575c-bee2-409f-b304-9e472e7ac702</RapportNummer> | ||
1501 | <IsDelayed>False</IsDelayed> | ||
1502 | <ExpectedOn>11/10/2018 00:00:00</ExpectedOn> | ||
1503 | </Order> | ||
1504 | </Orders> | ||
1505 | <Status> | ||
1506 | <StatusCode>1</StatusCode> | ||
1507 | <StatusCodeDescription>OK</StatusCodeDescription> | ||
1508 | <AtmisErrorCode>0</AtmisErrorCode> | ||
1509 | <ErrorMessage></ErrorMessage> | ||
1510 | </Status> | ||
1511 | </Response> | ||
1512 | |||
1513 | |||
1514 | == Request example Order XML == | ||
1515 | |||
1516 | |||
1517 | public GetOrderResultsCall.Response GetOrderResults(string WebserviceUsername, string WebservicePassword, string CustomerUsername, string customerid, string orderid, string sikbVersion) | ||
1518 | { | ||
1519 | GetOrderResultsCall.Response set = new GetOrderResultsCall.Response(); | ||
1520 | string responseMessage = null; | ||
1521 | try | ||
1522 | { | ||
1523 | bool useZipstream = true; | ||
1524 | var content = new FormUrlEncodedContent(new[] | ||
1525 | { | ||
1526 | new KeyValuePair<string, string>("userName", WebserviceUsername), | ||
1527 | new KeyValuePair<string, string>("password", WebservicePassword), | ||
1528 | new KeyValuePair<string, string>("customerUsername", CustomerUsername), | ||
1529 | new KeyValuePair<string, string>("clientId", customerid), | ||
1530 | new KeyValuePair<string, string>("orderId", orderid), | ||
1531 | new KeyValuePair<string, string>("sikbVersion", sikbVersion), | ||
1532 | new KeyValuePair<string, string>("useZip", useZipstream.ToString() ), | ||
1533 | }); | ||
1534 | |||
1535 | HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/GetOrderResults", content).GetAwaiter().GetResult(); | ||
1536 | responseMessage = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); | ||
1537 | response.EnsureSuccessStatusCode(); | ||
1538 | |||
1539 | if (string.IsNullOrEmpty(responseMessage)) | ||
1540 | { | ||
1541 | throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " /GetOrderResults" + "]"); | ||
1542 | } | ||
1543 | using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage~)~)~) | ||
1544 | { | ||
1545 | XmlSerializer serializer = new XmlSerializer(typeof(GetOrderResultsCall.Response)); | ||
1546 | set = (GetOrderResultsCall.Response)serializer.Deserialize(ms); | ||
1547 | } | ||
1548 | |||
1549 | if (useZipstream && !string.IsNullOrEmpty(set.FileContent)) | ||
1550 | { | ||
1551 | ~/~/convert from base64 string back to normal | ||
1552 | ~/~/first check for real Base64, by checking there is no 'xml' in it | ||
1553 | ~/~/If encoded, it wont contain either of the root XML tags of SIKB | ||
1554 | if (!set.FileContent.Contains("FeatureCollectionIMSIKB0101") && !set.FileContent.Contains("labresultaat")) | ||
1555 | { | ||
1556 | set.FileContent = ZipStreamHelper.DecompressBase64StringToString(set.FileContent); | ||
1557 | } | ||
1558 | } | ||
1559 | |||
1560 | } | ||
1561 | catch (Exception ex) | ||
1562 | { | ||
1563 | #region handle exception | ||
1564 | |||
1565 | set.Status = new BusinessEntities.LabRestService.GetOrderResultsCall.ResponseStatus(); | ||
1566 | set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString(); | ||
1567 | set.Status.ErrorMessage = "Exception occurred in GetOrderResults (username: " + WebserviceUsername + ", password: " + WebservicePassword + ") with message: " + ex.ToString(); | ||
1568 | |||
1569 | ex.Data.Add("Response", responseMessage); | ||
1570 | ex.Data.Add("WebserviceUsername", WebserviceUsername); | ||
1571 | ex.Data.Add("WebservicePassword", WebservicePassword); | ||
1572 | ex.Data.Add("CustomerUsername", CustomerUsername); | ||
1573 | ex.Data.Add("sikbVersion", sikbVersion); | ||
1574 | ex.Data.Add("customerid", customerid); | ||
1575 | ex.Data.Add("orderId", orderid); | ||
1576 | ex.Data.Add("Result", set); | ||
1577 | |||
1578 | throw; | ||
1579 | #endregion | ||
1580 | } | ||
1581 | |||
1582 | return set; | ||
1583 | |||
1584 | |||
1585 | == Response Order XML Example == | ||
1586 | |||
1587 | |||
1588 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
1589 | <Response> | ||
1590 | <FileContent>DhVn3Q1AA==</FileContent> ~/~/BASE64 Zip Stream, SIKB0101 labresults xml file | ||
1591 | <Status> | ||
1592 | <StatusCode>1</StatusCode> | ||
1593 | <StatusCodeDescription>OK</StatusCodeDescription> | ||
1594 | <AtmisErrorCode>0</AtmisErrorCode> | ||
1595 | <ErrorMessage></ErrorMessage> | ||
1596 | </Status> | ||
1597 | </Response> | ||
1598 | |||
1599 | |||
1600 | == Request example Order PDF File == | ||
1601 | |||
1602 | |||
1603 | |||
1604 | bool useZipstream = true; ~/~/ Always Supported, Keep it true!! | ||
1605 | var content = new FormUrlEncodedContent(new[] | ||
1606 | { | ||
1607 | new KeyValuePair<string, string>("userName", WebserviceUsername), | ||
1608 | new KeyValuePair<string, string>("password", WebservicePassword), | ||
1609 | new KeyValuePair<string, string>("customerUsername", CustomerUsername), | ||
1610 | new KeyValuePair<string, string>("clientId", customerid), | ||
1611 | new KeyValuePair<string, string>("orderId", orderid), | ||
1612 | new KeyValuePair<string, string>("useZip", useZipstream.ToString()), ~/~/ Always Supported, Keep it true!!. | ||
1613 | new KeyValuePair<string, string>("languageCode", languageCode) | ||
1614 | }); | ||
1615 | |||
1616 | HttpResponseMessage response = _HttpClient.PostAsync("GetOrderPdf", content).GetAwaiter().GetResult(); | ||
1617 | responseMessage = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); | ||
1618 | response.EnsureSuccessStatusCode(); | ||
1619 | |||
1620 | |||
1621 | == Response Order PDF Example == | ||
1622 | |||
1623 | <Response> | ||
1624 | <OrderId>7113737</OrderId> | ||
1625 | <FileContent> | ||
1626 | BASE64 encoded file | ||
1627 | </FileContent> | ||
1628 | <Status> | ||
1629 | <StatusCode>1</StatusCode> | ||
1630 | <StatusCodeDescription>OK</StatusCodeDescription> | ||
1631 | <ErrorMessage></ErrorMessage> | ||
1632 | </Status> | ||
1633 | </Response> | ||
1634 | |||
1635 | |||
1636 | |||
1637 | (% element-id="357" %) | ||
1638 | = (% element-id="356" %)Customer wants to see real time information about the status in the interface(%%) = | ||
1639 | |||
1640 | (% element-id="354" %) | ||
1641 | == (% element-id="353" %)Solution/Design(%%) == | ||
1642 | |||
1643 | (% element-id="352" %) | ||
1644 | To always show up-to-date information in the TerraIndex interface when a user opens a lab assignment to see the status, we reuse part of the GetOrderStatus, but with a specific OrderID. | ||
1645 | |||
1646 | (% element-id="351" %) | ||
1647 | ..NOT SUPPORTED YET... | ||
1648 | |||
1649 | (% class="table-hover" element-id="350" %) | ||
1650 | (% element-id="348" %)|(% colspan="1" element-id="347" %)Action|(% colspan="1" element-id="346" %)TerraIndex|(% colspan="1" element-id="345" %) |(% colspan="1" element-id="343" %)Laboratorium|(% colspan="1" element-id="342" %)Parameters/Message|(% colspan="1" element-id="341" %)Remarks|(% colspan="1" element-id="340" %)ResultCodes | ||
1651 | (% element-id="339" %)|(% element-id="338" %)1|(% element-id="337" %)Request the Order status for a single Order/Labassignment. | ||
1652 | Function: GetOrderStatus()|=(% element-id="335" %)>|(% element-id="334" %) |(% element-id="332" %)WebserviceUsername (string), | ||
1653 | WebservicePassword (string), | ||
1654 | CustomerUsername (string), | ||
1655 | CustomerCode (string), | ||
1656 | OrderID (string),|(% element-id="327" %) |(% element-id="325" %) | ||
1657 | (% element-id="323" %)|(% element-id="322" %)2|(% element-id="321" %) |(% element-id="319" %) |(% element-id="317" %)Receives the request and gets the status for the Order.|(% element-id="316" %) |(% element-id="314" %) |(% element-id="312" %) | ||
1658 | (% element-id="310" %)|(% element-id="309" %)3|(% element-id="308" %) |(% element-id="306" %)<=|(% element-id="305" %)Sends back the status of the order.|(% element-id="304" %)ResultCode (), | ||
1659 | ErrorMessage (string), | ||
1660 | OrderID (string), | ||
1661 | LabassignmentGUID (GUID), | ||
1662 | CertificateNumber (string) | ||
1663 | OrderStatusSIKB (int), | ||
1664 | Delayed (boolean), | ||
1665 | ExpectedTimeStamp (DateTime),|(% element-id="296" %)OrderStatusSIKB is the SIKB Labassignment status. | ||
1666 | \\Delayed is a boolean to tell the customer a order will be later ready then expected. The ExpectedTimestamp. | ||
1667 | If Delayed for the firsttime, TerraIndex can send a notification to the users and show a different layout. | ||
1668 | \\LabassignmentGUID is filled to support also Labassignments that are not from TerraIndex Ordered.|(% element-id="290" %)1 = Success, | ||
1669 | 2 = GeneralError, | ||
1670 | 3 = WrongSIKBVersion, | ||
1671 | 4 = InvalidCredentials, | ||
1672 | 5 = CustomerUsernameInvalid, | ||
1673 | 6 = CustomerUsernameNotValidForCustomerCode | ||
1674 | 7 = FileContentProblem, | ||
1675 | 8 = InvalidOrderId, | ||
1676 | 9 = OrderIdAlreadyApproved | ||
1677 | 10 = PDFNotAvailable | ||
1678 | (% element-id="280" %)|(% element-id="279" %)4|(% element-id="278" %)Receives the status and shows in the interface the updated info. | ||
1679 | Update the CertificateNr if this is not already present in the labassignment. |(% element-id="276" %) |(% element-id="274" %) |(% element-id="272" %) |(% element-id="270" %)CertifcateNumber could be new here, if the lab wasn't able to fill it directly at the ApproveOrder.|(% element-id="269" %) | ||
1680 | |||
1681 | (% element-id="265" %) | ||
1682 |