Version 3.1 by Robin Huisman on 2022/02/08 11:50

Hide last authors
Roelof Zwaan 1.1 1 {{toc/}}
2
3
4 = Firewall IP-Adresssen van TerraIndex =
5
6 Onze IP-adressen:
7
8 ingaand [[Web.terraindex.com>>url:http://Web.terraindex.com]]
9 137.116.199.164
10
11 ingaand [[Test.terraindex.com>>url:http://Test.terraindex.com]]
12 104.45.9.128
13
14 Productie uitgaand
15 40.115.34.64
16
17 Test uitgaand
18 13.73.138.173
19
20 CD/CI uitgaand
21 40.114.238.16
22
23 --Kantoor VPN uitgaand  (niet meer in gebruik, was de oude OpenVPN)
24 10.33.66.215--
25
26 Kantoor uitgaand
27 213.124.115.132
28
29 --Oude Citrix uitgaand (citrix is ook verhuisd, dit is niet meer in gebruik)
30 83.96.194.140--
31
32
33 = Labaanlever bestanden uitwisseling =
34
35 == Oplossing/Design ==
36
37
38 (% class="table-hover" %)
39 |**Action**|**TerraIndex**| |**Laboratorium**|**Parameters/Message**|**Remarks**|**ResultCodes**
40 |1|Sends a request to the function: GetCustomers().|=>| |**WebserviceUsername (string), **
41 **WebservicePassword (string),**
42 **CustomerUsername (string)**| |
43 |2| | |Receives the request and check the customers this username and searches the dateLastChanged for this Customer.| | |
44 |3| |<=|Sends back the list of customers with the lastChangedTimestamp|ResultCode (),
45 ErrorMessage (string),
46 List<customer> , Customer:
47 CustomerCode (string),
48 CustomerName (string),
49 LabID (int),
50 LabName (string),
51 ChangedTimeStamp (DateTime)|We receive the dateTimestamp instead of sending it, so we always get the full list and we are also able to delete customercodes.|1 = Success,
52 2 = GeneralError,
53 3 = WrongSIKBVersion,
54 4 = InvalidCredentials,
55 5 = CustomerUsernameInvalid,
56 6 = CustomerUsernameNotValidForCustomerCode
57 7 = FileContentProblem,
58 8 = InvalidOrderId,
59 9 = OrderIdAlreadyApproved
60 10 = PDFNotAvailable
61 |4|Receives the list of Customers, and will check for each customer it needs to request a new/changed labdelivery file based on the ChangedTimestamp.| | | |If a customer is not longer in this list, TerraIndex can remove this customercode from the customer database.|
62 |5|Sends a request to the function: GetProductList() if it has changed.|=>| |**WebserviceUsername (string), **
63 **WebservicePassword (string),**
64 **CustomerUsername (string),**
65 LabID (int),
66 CustomerCode (string),
67 LanguageCode (string, default 'nld' volgens ISO 639-3-codes),
68 SIKBVersion (string, default: '13.4.0'),
69 UseZipStream/UseZip (bool, default: 'false')|(((
70 We start with dutch, then extend with multiple languages, TerraIndex is in the lead to request multiple languages.
71 TerraIndex uses: 'fra', 'nld', 'eng', 'spa', 'deu', 'ita', 'por', 'dan'
72
73
74 Besides SIKB 13.4.0, TerraIndex also supports 9.0.0/8.0.0 etc.
75 )))|
76 |6| | |Reveives a request to create a labdelivery file in a certain version of SIKB. It will generate the file.| | |
77 |7| |<=|Sends back the SIKB file, as a Base64 encoded string, with or without using a zipstream.|ResultCode (),
78 ErrorMessage (string),
79 FileContent_Base64 (string),
80 UseZipStream/UseZip (bool, default: 'false')| |1 = Success,
81 2 = GeneralError,
82 3 = WrongSIKBVersion,
83 4 = InvalidCredentials,
84 5 = CustomerUsernameInvalid,
85 6 = CustomerUsernameNotValidForCustomerCode
86 7 = FileContentProblem,
87 8 = InvalidOrderId,
88 9 = OrderIdAlreadyApproved
89 10 = PDFNotAvailable
90 |8|Receives the DeliveryFile and saves the file for import into customer database.| | | | |
91 |9|Go back to step 5, for every Customer code, every language.| | | | |
92 |10|Process the LabDeliveryFiles| | | | |
93
94 == Get Customers (POST) ==
95
96 === Request example ===
97
98 |(((
Robin Huisman 1.4 99 {{code language="C#"}}
Roelof Zwaan 1.1 100 public GetCustomersCall.Response GetCustomers(string WebserviceUsername, string WebservicePassword, string CustomerUsername)
Robin Huisman 1.4 101         {
102             GetCustomersCall.Response set = new GetCustomersCall.Response();
Roelof Zwaan 1.1 103
Robin Huisman 1.4 104             try
105             {
106                 var content = new FormUrlEncodedContent(new[]
107                 {
108                     new KeyValuePair<string, string>("userName", WebserviceUsername),
109                     new KeyValuePair<string, string>("password", WebservicePassword),
110                     new KeyValuePair<string, string>("customerUsername", CustomerUsername),
111                 });
Roelof Zwaan 1.1 112
Robin Huisman 1.4 113                 HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/GetCustomers", content).Result;
114                 response.EnsureSuccessStatusCode();
115                 string responseMessage = response.Content.ReadAsStringAsync().Result;
Roelof Zwaan 1.1 116
Robin Huisman 1.4 117                 if (string.IsNullOrEmpty(responseMessage))
118                 {
119                     throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " / GetCustomers" + "]");
120                 }
121                 using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage)))
122                 {
123                     XmlSerializer serializer = new XmlSerializer(typeof(GetCustomersCall.Response));
124                     set = (GetCustomersCall.Response)serializer.Deserialize(ms);                 
125                 }
126             }
127             catch (Exception ex)
128             {
129                 #region handle exception
130                 set.Status = new BusinessEntities.LabRestService.GetCustomersCall.ResponseStatus();
131                 set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString();               
132                 set.Status.ErrorMessage = "Exception occurred in GetCustomers (username: " + WebserviceUsername + ", password: " + WebservicePassword + ") with message: " + ex.Message;
133                 ex.Data.Add("WebserviceUsername", WebserviceUsername);
134                 ex.Data.Add("WebservicePassword", WebservicePassword);
135                 ex.Data.Add("CustomerUsername", CustomerUsername);
136                 ExceptionHandler.HandleException(ex);
137                 #endregion
138             }
139             return set;
140         }
141 {{/code}}
Roelof Zwaan 1.1 142
Robin Huisman 1.4 143
Roelof Zwaan 1.1 144 )))
145
146 |(((
147 POST https:~/~/<URL>/GetCustomers HTTP/1.1
148
149 Content-Type: application/x-www-form-urlencoded
150
151 Host: 81.175.89.24
152
153 Content-Length: 115
154
155 Expect: 100-continue
156
157
158 userName=<webservice_username>&password=<Webservice_password>&customerUsername=<customer_username or token>
159 )))
160
161 === Response example ===
162
163 |(((
Robin Huisman 3.1 164 {{code language="XML"}}
Roelof Zwaan 1.1 165 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
166 <Response><Customers>
Robin Huisman 3.1 167   <Customer LabId="1" LabName="Example Laboratorium" CustomerId="300" CustomerName="Adviesbureau De bodemkoning - Rotterdam" LastModifiedOnClient="2019-05-08T11:05:14.17+02:00" />
168   <Customer LabId="1" LabName="Example Laboratorium" CustomerId="656" CustomerName="Adviesbureau De bodemkoning - Delft" LastModifiedOnClient="2019-04-19T13:20:10.123+02:00" />
Roelof Zwaan 1.1 169 </Customers>
170 <Status>
Robin Huisman 3.1 171     <StatusCode>1</StatusCode>
172     <StatusCodeDescription>OK</StatusCodeDescription>
173     <ErrorMessage></ErrorMessage>
Roelof Zwaan 1.1 174 </Status>
Robin Huisman 3.1 175 </Response>
176 {{/code}}
Roelof Zwaan 1.1 177
Robin Huisman 3.1 178
Roelof Zwaan 1.1 179 )))
180
181 == Get Products (POST) ==
182
183 === Request example ===
184
185 |(((
186 public GetProductsCall.Response GetProductList(string WebserviceUsername, string WebservicePassword, string CustomerUsername, string customerid, int labid, string sikbVersion, string languageCode)
187
188 {
189
190
191 GetProductsCall.Response set = new GetProductsCall.Response();
192
193
194 try
195
196 {
197
198 bool useZipstream = true;
199
200 var content = new FormUrlEncodedContent(new[]
201
202 {
203
204 new KeyValuePair<string, string>("userName", WebserviceUsername),
205
206 new KeyValuePair<string, string>("password", WebservicePassword),
207
208 new KeyValuePair<string, string>("customerUsername", CustomerUsername),
209
210 new KeyValuePair<string, string>("languageCode", languageCode),
211
212 new KeyValuePair<string, string>("clientId", customerid),
213
214 new KeyValuePair<string, string>("sikbVersion", sikbVersion),
215
216 new KeyValuePair<string, string>("useZip", useZipstream.ToString() ),
217
218 });
219
220
221 HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/GetProducts", content).Result;
222
223 response.EnsureSuccessStatusCode();
224
225 string responseMessage = response.Content.ReadAsStringAsync().Result;
226
227
228 if (string.IsNullOrEmpty(responseMessage))
229
230 {
231
232 throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " /GetProducts" + "]");
233
234 }
235
236 using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage~)~)~)
237
238 {
239
240 XmlSerializer serializer = new XmlSerializer(typeof(GetProductsCall.Response));
241
242 set = (GetProductsCall.Response)serializer.Deserialize(ms);
243
244 }
245
246
247 if (useZipstream && !string.IsNullOrEmpty(set.FileContent))
248
249 {
250
251 ~/~/convert from base64 string back to normal
252
253 ~/~/first check for real Base64, by checking there is no 'xml'  in it
254
255 if (!set.FileContent.Contains("<labaanlevering"))
256
257 {
258
259 set.FileContent = ZipStreamHelper.DecompressBase64StringToString(set.FileContent);
260
261 }
262
263 }
264
265
266 }
267
268 catch (Exception ex)
269
270 {
271
272 #region handle exception
273
274
275 set.Status = new BusinessEntities.LabRestService.GetProductsCall.ResponseStatus();
276
277 set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString();
278
279 set.Status.ErrorMessage = "Exception occurred in GetProducts (username: " + WebserviceUsername + ", password: " + WebservicePassword + ") with message: " + ex.Message;
280
281
282 ex.Data.Add("WebserviceUsername", WebserviceUsername);
283
284 ex.Data.Add("WebservicePassword", WebservicePassword);
285
286 ex.Data.Add("CustomerUsername", CustomerUsername);
287
288 ex.Data.Add("sikbVersion", sikbVersion);
289
290 ex.Data.Add("customerid", customerid);
291
292 ex.Data.Add("languageCode", languageCode);
293
294
295 ExceptionHandler.HandleException(ex);
296
297 #endregion
298
299 }
300
301
302 return set;
303
304 }
305 )))
306
307 |(((
308 POST https:~/~/<URL>/GetProducts HTTP/1.1
309
310 Content-Type: application/x-www-form-urlencoded
311
312 Host: 81.175.89.24
313
314 Content-Length: 179
315
316 Expect: 100-continue
317
318
319 userName=<webservice_username>&password=<Webservice_password>&customerUsername=<customer_username or token>&languageCode=nld&clientId=300&sikbVersion=13.5.0&useZip=True
320 )))
321
322 === Response example ===
323
324 |(((
325 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
326
327 <Response>
328
329 <FileContent> {SIKB FILE in ZIPSTREAM BASE64 format}</FileContent>
330
331 <Status>
332
333 <StatusCode>1</StatusCode>
334
335 <StatusCodeDescription>OK</StatusCodeDescription>
336
337 <ErrorMessage></ErrorMessage>
338
339 </Status></Response>
340 )))
341
342 = Gebruikersaccount controleren. =
343
344
345 == Oplossing/Design ==
346
347 Bij iedere call gaan we geen username van de klanten meer sturen met een vast webservice username en password voor TerraIndex. Hier willen we ook snel op kunnen controleren of deze wel bestaat.
348
349 WebserviceUsername (string),
350 WebservicePassword (string),
351 CustomerUsername (string)
352
353
354 Hiervoor maken we een Webserice voor ValidCredentials Check:
355
356
357 (% class="table-hover" %)
358 |**Action**|**TerraIndex**| |**Laboratorium**|**Parameters/Message**|**Remarks**|**ResultCodes**
359 |1|Sends a request to the function: ValidCredentials().|=>| |WebserviceUsername (string),
360 WebservicePassword (string),
361 CustomerUsername (string)|We want to skip the Password of the customer, and we use the WebserviceUsername + WebservicePassword for real authentication.|
362 |2| | |Receives the request and checks the combination of WebserviceUsername and WebservicePassword is Ok. Then checks the CustomerUsername is valid.| | |
363 |3| |<=|Sends back a Success of InvalidCredentials|ResultCode (),
364 ErrorMessage (string),| |1 = Success,
365 2 = GeneralError,
366 3 = WrongSIKBVersion,
367 4 = InvalidCredentials,
368 5 = CustomerUsernameInvalid,
369 6 = CustomerUsernameNotValidForCustomerCode
370 7 = FileContentProblem,
371 8 = InvalidOrderId,
372 9 = OrderIdAlreadyApproved
373 10 = PDFNotAvailable
374
375 == Check ValidCredentials (POST) ==
376
377 === Request example ===
378
379 |(((
380 public ValidCredentialsCall.Response ValidCredentials(string WebserviceUsername, string WebservicePassword, string CustomerUsername, string customerid)
381
382 {
383
384 ValidCredentialsCall.Response set = new ValidCredentialsCall.Response();
385
386
387 try
388
389 {
390
391
392 var content = new FormUrlEncodedContent(new[]
393
394 {
395
396 new KeyValuePair<string, string>("userName", WebserviceUsername),
397
398 new KeyValuePair<string, string>("password", WebservicePassword),
399
400 ~/~/new KeyValuePair<string, string>("clientId", customerid),   ~/~/ Optional
401
402 new KeyValuePair<string, string>("customerUsername", CustomerUsername),
403
404 });
405
406
407 HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/ValidCredentials", content).Result;
408
409 response.EnsureSuccessStatusCode();
410
411 string responseMessage = response.Content.ReadAsStringAsync().Result;
412
413
414 if (string.IsNullOrEmpty(responseMessage))
415
416 {
417
418 throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " / ValidCredentials" + "]");
419
420 }
421
422 using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage~)~)~)
423
424 {
425
426 XmlSerializer serializer = new XmlSerializer(typeof(ValidCredentialsCall.Response));
427
428 set = (ValidCredentialsCall.Response)serializer.Deserialize(ms);
429
430
431 return set;
432
433 }
434
435
436 }
437
438 catch (Exception ex)
439
440 {
441
442 #region handle exception
443
444
445 set.Status = new BusinessEntities.LabRestService.ValidCredentialsCall.ResponseStatus();
446
447 set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString();
448
449 set.Status.ErrorMessage = "Exception occurred in GetValidCredentials (username: " + WebserviceUsername + ", with message: " + ex.Message;
450
451
452 ex.Data.Add("WebserviceUsername", WebserviceUsername);
453
454 ex.Data.Add("WebservicePassword", WebservicePassword);
455
456 ex.Data.Add("CustomerUsername", CustomerUsername);
457
458
459 ExceptionHandler.HandleException(ex);
460
461 #endregion
462
463 }
464
465
466 return set;
467
468 }
469 )))
470
471 |(((
472 POST https:~/~/<URL>/ValidCredentials HTTP/1.1
473
474 Content-Type: application/x-www-form-urlencoded
475
476 Host: 81.175.89.24
477
478 Content-Length: 125
479
480 Expect: 100-continue
481
482
483 userName=<webservice_username>&password=<Webservice_password>&clientId=<optional otherwise empty>&customerUsername=<customer_username or token>
484 )))
485
486 === Response example ===
487
488 |(((
489 <?xml version="1.0" encoding="UTF-8" standalone="no"?><Response>
490
491 <Status>
492
493 <StatusCode>1</StatusCode>
494
495 <StatusCodeDescription>OK</StatusCodeDescription>
496
497 <ErrorMessage></ErrorMessage>
498
499 </Status>
500
501 </Response>
502 )))
503
504 = Opdrachten versturen (POST) =
505
506 == Oplossing/Design ==
507
508 Hiervoor maken we een Webserice voor CreateOrder om de opdracht aan te maken.
509 Na de create willen we in de toekomst een overzicht van het laboratorium in bijv. PDF tonen, waarbij de gebruiker de prijzen ziet en kan bevestigen of annuleren.
510 Afhankelijk van de keuze van de gebruiker bij het laboratorium, roept TerraIndex de ApproveOrder of de CancelOrder aan.
511
512 Voor nu gaan we er vanuit dat wij dit niet kunnen, en stuurt TerraIndex needsApprovalIsSupported = false mee. Mocht dit True worden in de toekomst, dan kan het Lab bij het result aangeven of het wel of niet nodig is, in het NeedsApprove veld.
513
514
515 (% class="table-hover" %)
516 |**Action**|**TerraIndex**| |**Laboratorium**|**Parameters/Message**|**Remarks**|**ResultCodes**
517 |1|Sends a request to the function: CreateOrder().|=>| |WebserviceUsername (string),
518 WebservicePassword (string),
519 CustomerUsername (string),
520 FileContent_Base64 (string),
521 UseZipStream/UseZip (bool, default: 'false'),
522 CustomerCode (string),
523 SIKBVersion (string, default: '13.4.0'),
524 needsApprovalIsSupported (bool)|SIKB Version included, so labs can quickly check the version.
525 Besides SIKB 13.4.0, TerraIndex also supports 9.0.0.
526 \\Before sending the SIKB, validate to the XSD!
527 And to the XSLT?
528 \\needsApprovalIsSupported = false; means we dont get PDF with offerte. This will make is faster.
529 needsApprovalIsSupported = true; means lab will check the user setting to send a PDF Offerte back or not. (If the lab can support this.)|
530 |2| | |Receives the request and checks the credentials.| | |
531 |(% colspan="1" %)3|(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)Credentials are valid, the Filecontent is checked on a valid Labassignment. When valid it will be processed and a OrderId is given.|(% colspan="1" %) |(% colspan="1" %)Laboratorium saves the Sample GUIDs if it's SIKB 13 or higher.
532 Otherwise we use the idanlmons unique ID.|(% colspan="1" %)
533 |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)Based on what customer, the order will be approved or the approve needs to be done in laboratorium system.|(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)
534 |4| |<=|Sends back a Success with the new OrderId|ResultCode (),
535 ErrorMessage (string),
536 OrderId (string),
537 NeedsApprove (bool),
538 FileContent_Base64 (string),
539 UseZipStream/UseZip (bool, default: 'false'),|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.|1 = Success,
540 2 = GeneralError,
541 3 = WrongSIKBVersion,
542 4 = InvalidCredentials,
543 5 = CustomerUsernameInvalid,
544 6 = CustomerUsernameNotValidForCustomerCode
545 7 = FileContentProblem,
546 8 = InvalidOrderId,
547 9 = OrderIdAlreadyApproved
548 10 = PDFNotAvailable
549 |(% colspan="1" %)6|(% colspan="1" %)Receives the OrderId, and saves it.
550 |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)(((
551 Default for now laboratorium will send:
552 NeedsApprove = False,
553 PDF = Empty,
554 Zipstream = False,
555
556
557 In the future, do something with the PDF and show the PDF to users to Approve or Cancel.
558 This will be done by; NeedsApprove = true.
559 \\If NeedsApprove is False, the order is Processed and can't be changed in TI. Like it is now.
560
561
562 )))|(% colspan="1" %)
563 |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)
564 |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)
565 |(% colspan="1" %) |(% colspan="1" %)**IN THE FUTURE: APPROVEORDER**|(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)
566 |(% colspan="1" %)7|(% colspan="1" %)Sends a request to the function: ApproveOrder().|(% colspan="1" %)=>|(% colspan="1" %) |(% colspan="1" %)WebserviceUsername (string),
567 WebservicePassword (string),
568 CustomerUsername (string),
569 OrderId (string)|(% colspan="1" %) |(% colspan="1" %)
570 |(% colspan="1" %)8|(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)Receives the approve and checks the credentials and the OrderId.|(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)
571 |(% colspan="1" %)9|(% colspan="1" %) |(% colspan="1" %)<=|(% colspan="1" %)Sends back a Success with the new CertificateNr|(% colspan="1" %)ResultCode (),
572 ErrorMessage (string),
573 CertificateNr (string)|(% colspan="1" %)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" %)1 = Success,
574 2 = GeneralError,
575 3 = WrongSIKBVersion,
576 4 = InvalidCredentials,
577 5 = CustomerUsernameInvalid,
578 6 = CustomerUsernameNotValidForCustomerCode
579 7 = FileContentProblem,
580 8 = InvalidOrderId,
581 9 = OrderIdAlreadyApproved
582 10 = PDFNotAvailable
583 |(% colspan="1" %)10|(% colspan="1" %)Receives the CerificateNr and saves it.|(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)
584 |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)
585 |(% colspan="1" %) |(% colspan="1" %)**IN THE FUTURE: CANCELORDER**|(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)
586 |7|Sends a request to the function: CancelOrder().|=>| |WebserviceUsername (string),
587 WebservicePassword (string),
588 CustomerUsername (string),
589 OrderId (string)| |
590 |8| | |Receives the cancel and checks the credentials and the OrderId.| | |
591 |9| |<=|Sends back a Success |ResultCode (),
592 ErrorMessage (string)| |1 = Success,
593 2 = GeneralError,
594 3 = WrongSIKBVersion,
595 4 = InvalidCredentials,
596 5 = CustomerUsernameInvalid,
597 6 = CustomerUsernameNotValidForCustomerCode
598 7 = FileContentProblem,
599 8 = InvalidOrderId,
600 9 = OrderIdAlreadyApproved
601 10 = PDFNotAvailable
602 |10|Removes the OrderId and the IsSend to False| | | |If OrderIsAleadyApproved, set the values to Approved and keep the OrderId and IsSend.|
603 |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %) |(% colspan="1" %)
604
605 == Create Order ==
606
607 === Request example ===
608
609 |(((
610 public CreateOrderResponse.Response SendLabAssignment(string WebserviceUsername, string WebservicePassword, string CustomerUsername, string customerid, string sikbVersion, string assignmentXML, string languageCode, bool needsApprovalIsSupported = false)
611
612 {
613
614 CreateOrderResponse.Response set = new CreateOrderResponse.Response();
615
616
617 try
618
619 {
620
621 bool useZipstream = true;
622
623
624 MultipartFormDataContent content = new MultipartFormDataContent();
625
626
627 ~/~/Add Formdata
628
629 var formDataDictionary = new[]
630
631 {
632
633 new KeyValuePair<string, string>("userName", WebserviceUsername),
634
635 new KeyValuePair<string, string>("password", WebservicePassword),
636
637 new KeyValuePair<string, string>("customerUserName", CustomerUsername),
638
639 new KeyValuePair<string, string>("clientId", customerid),
640
641 new KeyValuePair<string, string>("sikbVersion", sikbVersion),
642
643 new KeyValuePair<string, string>("languageCode", languageCode),
644
645 new KeyValuePair<string, string>("useZip", useZipstream.ToString() ),
646
647 new KeyValuePair<string, string>("needsApprovalIsSupported", needsApprovalIsSupported.ToString() ),
648
649 ~/~/new KeyValuePair<string, string>("orderXml", ZipStreamHelper.CompressToBase64String(assignmentXML)),
650
651 ~/~/new KeyValuePair<string, string>("orderXml", assignmentXML),
652
653 };              
654
655 foreach (var item in formDataDictionary)
656
657 {
658
659 content.Add(new StringContent(item.Value), $"\"{item.Key}\"");
660
661 }
662
663
664 string filexml = string.Empty;
665
666 if (useZipstream)
667
668 {
669
670 filexml = ZipStreamHelper.CompressToBase64String(assignmentXML);
671
672 }
673
674 else
675
676 {
677
678 filexml = assignmentXML;
679
680 }
681
682
683 ~/~/Add filecontent
684
685 var fileContent = new ByteArrayContent(ZipStreamHelper.stringToByteArray(filexml));
686
687 fileContent.Headers.ContentDisposition =
688
689 new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") ~/~/<- 'form-data' instead of 'attachment'
690
691 {
692
693 Name = "\"orderXml\"", ~/~/ \" is needed so the message contains the quotes, wihtout it will fail
694
695 FileName = "\"VivaTerraIndexAssignment.xml\""
696
697 };
698
699 fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/xml");              
700
701 content.Add(fileContent);
702
703
704 ~/~/Start sending
705
706
707 HttpResponseMessage response = _HttpClient.PostAsync(_HttpClient.BaseAddress + "/CreateOrder", content).Result;
708
709 response.EnsureSuccessStatusCode();
710
711 string responseMessage = response.Content.ReadAsStringAsync().Result;
712
713
714 if (string.IsNullOrEmpty(responseMessage))
715
716 {
717
718 throw new Exception("Empty response from: [" + _HttpClient.BaseAddress + " /CreateOrder" + "]");
719
720 }
721
722 using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseMessage~)~)~)
723
724 {
725
726 XmlSerializer serializer = new XmlSerializer(typeof(CreateOrderResponse.Response));
727
728 set = (CreateOrderResponse.Response)serializer.Deserialize(ms);
729
730 }
731
732
733 ~/~/Can contain a PDf with price information
734
735 if (set.UseZip && !string.IsNullOrEmpty(set.FileContent))
736
737 {
738
739 ~/~/convert from base64 string back to normal
740
741 set.FileContent = ZipStreamHelper.DecompressBase64StringToString(set.FileContent);                  
742
743 }
744
745
746 }
747
748 catch (Exception ex)
749
750 {
751
752 #region handle exception
753
754
755 set.Status = new BusinessEntities.LabRestService.CreateOrderResponse.ResponseStatus();
756
757 set.Status.StatusCode = ((int)ResultCodes.GeneralError).ToString();
758
759 set.Status.ErrorMessage = "Exception occurred in CreateOrder (username: " + WebserviceUsername + ") with message: " + ex.Message;
760
761
762 ex.Data.Add("WebserviceUsername", WebserviceUsername);
763
764 ex.Data.Add("WebservicePassword", WebservicePassword);
765
766 ex.Data.Add("CustomerUsername", CustomerUsername);
767
768 ex.Data.Add("sikbVersion", sikbVersion);
769
770 ex.Data.Add("customerid", customerid);
771
772
773 ExceptionHandler.HandleException(ex);
774
775 #endregion
776
777 }
778
779
780 return set;
781
782 }
783 )))
784
785 |(((
786 POST https:~/~/<URL>/CreateOrder HTTP/1.1
787
788 Content-Type: multipart/form-data; boundary="28a3e130-70c9-4a1a-b544-a802a1ade6ca"
789
790 Host: 81.175.89.24
791
792 Content-Length: 5010
793
794 Expect: 100-continue
795
796
797 ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca
798
799 Content-Type: text/plain; charset=utf-8
800
801 Content-Disposition: form-data; name="userName"
802
803
804 <Webservice_Username>
805
806 ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca
807
808 Content-Type: text/plain; charset=utf-8
809
810 Content-Disposition: form-data; name="password"
811
812
813 <Webservice_Password>
814
815 ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca
816
817 Content-Type: text/plain; charset=utf-8
818
819 Content-Disposition: form-data; name="customerUserName"
820
821
822 <Customer_Username or token>
823
824 ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca
825
826 Content-Type: text/plain; charset=utf-8
827
828 Content-Disposition: form-data; name="clientId"
829
830
831 300
832
833 ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca
834
835 Content-Type: text/plain; charset=utf-8
836
837 Content-Disposition: form-data; name="sikbVersion"
838
839
840 13.4.0
841
842 ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca
843
844 Content-Type: text/plain; charset=utf-8
845
846 Content-Disposition: form-data; name="languageCode"
847
848
849 nld
850
851 ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca
852
853 Content-Type: text/plain; charset=utf-8
854
855 Content-Disposition: form-data; name="useZip"
856
857
858 True
859
860 ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca
861
862 Content-Type: text/plain; charset=utf-8
863
864 Content-Disposition: form-data; name="needsApprovalIsSupported"
865
866
867 False
868
869 ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca
870
871 Content-Disposition: form-data; name="orderXml"; filename="VivaTerraIndexAssignment.xml"
872
873 Content-Type: application/xml
874
875
876 <SIKB File in Zip stream Base64  encoding>
877
878 ~-~-28a3e130-70c9-4a1a-b544-a802a1ade6ca~-~-
879 )))
880
881 === Response example ===
882
883 |(((
884 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
885
886 <Response>
887
888 <OrderId>7113828</OrderId>
889
890 <NeedsApproval>True</NeedsApproval>
891
892 <FileContent></FileContent>
893
894 <Status>
895
896 <StatusCode>1</StatusCode>
897
898 <StatusCodeDescription>OK</StatusCodeDescription>
899
900 <ErrorMessage></ErrorMessage>
901
902 </Status></Response>
903 )))
904
905 = Get Order status and Results =
906
907 == Oplossing/Design ==
908
909 TerraIndex gaat opvragen per licentie, welke resultaten en klaar staan. Deze worden opgevraagd als de nieuwste wijzigingen nieuwer zijn dan de laatste keer checken. Zo downloaden we nooit onnodig teveel en is het altijd nogmaals op te vragen.
910
911
912 (% class="table-hover" %)
913 |Action|TerraIndex| |Laboratorium|Parameters/Message|Remarks|ResultCodes
914 |1|Sends a request to the function: GetCustomers().|=>| |WebserviceUsername (string), 
915 WebservicePassword (string),
916 CustomerUsername (string)|We want to skip the Password of the customer, and we introduce the WebserviceUsername + WebservicePassword.|
917 |2| | |Receives the request and check the customers this username and searches the dateLastChanged for this Customer.| | |
918 |3| |<=|Sends back the list of customers with the lastChangedTimestamp|ResultCode (),
919 ErrorMessage (string),
920 List<customer> , Customer:
921 CustomerCode (string),
922 CustomerName (string),
923 LabID (int),
924 LabName (string),
925 ChangedTimeStamp (DateTime)|We receive the dateTimestamp instead of sending it, so we always get the full list and we are also able to delete customercodes.|1 = Success,
926 2 = GeneralError,
927 3 = WrongSIKBVersion,
928 4 = InvalidCredentials,
929 5 = CustomerUsernameInvalid,
930 6 = CustomerUsernameNotValidForCustomerCode
931 7 = FileContentProblem,
932 8 = InvalidOrderId,
933 9 = OrderIdAlreadyApproved
934 10 = PDFNotAvailable
935 |4|Receives the list of Customers. Read the Timestamp this Customer is last checked for Results/Statuses.| | | | |
936 |5|Send for each Customer a  call to retreive all orders statuses changes since a certain timestamp.
937 Function: GetOrderStatuses()|=>| |WebserviceUsername (string), 
938 WebservicePassword (string),
939 CustomerUsername (string),
940 CustomerCode (string),
941 LastCheckedTimestamp (DateTime)|TerraIndex keeps track of the last check timestamp for each license.|
942 |6| | |Receives the request and check the orders that are changed since the timestamp for this Customer.| | |
943 |7| |<=|Sends back the list of orders with the status and lastChangedTimestamp|ResultCode (),
944 ErrorMessage (string),
945 OrderID (string),
946 LabassignmentGUID (GUID),
947 CertificateNumber (string)
948 OrderStatusSIKB (int),
949 Delayed (boolean),
950 ExpectedTimeStamp (DateTime),|OrderStatusSIKB is the SIKB Labassignment status.
951 \\Delayed is a boolean to tell the customer a order will be later ready then expected. The ExpectedTimestamp.
952 If Delayed for the firsttime, TerraIndex can send a notification to the users and show a different layout.
953 \\LabassignmentGUID is filled to support also Labassignments that are not from TerraIndex Ordered.|1 = Success,
954 2 = GeneralError,
955 3 = WrongSIKBVersion,
956 4 = InvalidCredentials,
957 5 = CustomerUsernameInvalid,
958 6 = CustomerUsernameNotValidForCustomerCode
959 7 = FileContentProblem,
960 8 = InvalidOrderId,
961 9 = OrderIdAlreadyApproved
962 10 = PDFNotAvailable
963 |8|Receives the list of Orders with status.
964 Update the CertificateNr if this is not already present in the labassignment. | | | |CertifcateNumber could be new here, if the lab wasn't able to fill it directly at the ApproveOrder.|
965 |9|Send for each Order a call to retreive all results.
966 Function: GetOrderResults()|=>| |WebserviceUsername (string), 
967 WebservicePassword (string),
968 CustomerUsername (string),
969 CustomerCode (string),
970 OrderID (string),
971 SIKBVersion (string, default: '13.4.0')|Besides SIKB 13.4.0, TerraIndex also supports 9.0.0/8.0.0 etc.|
972 |10| | |Receives the request and creates a SIKB results file based on the version that is requested.| | |
973 |11| |<=|Sends back the results of the orders.|ResultCode (),
974 ErrorMessage (string),
975 OrderId (string),
976 LabassignmentGUID (GUID),
977 FileContent_Base64 (string),
978 UseZipStream/UseZip (bool, default: 'false'),| |1 = Success,
979 2 = GeneralError,
980 3 = WrongSIKBVersion,
981 4 = InvalidCredentials,
982 5 = CustomerUsernameInvalid,
983 6 = CustomerUsernameNotValidForCustomerCode
984 7 = FileContentProblem,
985 8 = InvalidOrderId,
986 9 = OrderIdAlreadyApproved
987 10 = PDFNotAvailable
988 |12|Receives the results and imports all results.| | | |(((
989 Import will be done to corresponding samples based on:
990
991 * Find Project by ProjectGUID (as provided in the labassignment)
992 * Find Project by ProjectCode (as provided in the Labassignment)
993 * Find Project and Labassignment by LabassignmentGUID (as provided in the Labassignment)
994 * Find Project (only if Project is not found yet) and Samples based on SampleGUID (as provided in the Labassignment) .
995 Sample GUIDs that are send to the lab in the labassignment version SIKB 13 or higher are required in the results for labassignment.
996 For lower version Labassignments the lab should return the 'old' idanlmons as SampleGUID in the XML.
997 * Find Samples (only if Project is already found ) by SampleName
998
999 What is imported?
1000
1001 * If Sample is found, the results in the XML are always all updated and/or inserted.
1002 * 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)
1003 )))|
1004 |13|If OrderStatus is 'Completed/Reported' (SIKBID: 5)
1005 Request the PDF certificate.
1006 Function: GetOrderPDF()|=>| |WebserviceUsername (string), 
1007 WebservicePassword (string),
1008 CustomerUsername (string),
1009 CustomerCode (string),
1010 OrderID (string),| |
1011 |14| | |Receives the request and creates the PDF for the Order.| | |
1012 |15| |<=|Sends back the PDF of the order.|ResultCode (),
1013 ErrorMessage (string),
1014 OrderId (string),
1015 LabassignmentGUID (GUID),
1016 FileContent_Base64 (string),
1017 UseZipStream/UseZip (bool, default: 'false'),|If the PDF is not available yet, please give the resultcode: PDFNotAvailable.|1 = Success,
1018 2 = GeneralError,
1019 3 = WrongSIKBVersion,
1020 4 = InvalidCredentials,
1021 5 = CustomerUsernameInvalid,
1022 6 = CustomerUsernameNotValidForCustomerCode
1023 7 = FileContentProblem,
1024 8 = InvalidOrderId,
1025 9 = OrderIdAlreadyApproved
1026 10 = PDFNotAvailable
1027 |12|Receives the PDF and stores it for reporting and downloading.| | | | |
1028
1029 =
1030 Customer wants to see real time information about the status in the interface =
1031
1032 == Oplossing/Design ==
1033
1034 Om in de interface van TerraIndex altijd up to date informatie te tonen als een gebruiker een labopdracht opent om de status te zien, hergebruiken we een deel van de GetOrderStatus, maar dan met specifiek een OrderID.
1035
1036 ..NOT SUPPORTED YET...
1037
1038 (% class="table-hover" %)
1039 |(% colspan="1" %)Action|(% colspan="1" %)TerraIndex|(% colspan="1" %) |(% colspan="1" %)Laboratorium|(% colspan="1" %)Parameters/Message|(% colspan="1" %)Remarks|(% colspan="1" %)ResultCodes
1040 |1|Request the Order status for a single Order/Labassignment.
1041 Function: GetOrderStatus()|=>| |WebserviceUsername (string), 
1042 WebservicePassword (string),
1043 CustomerUsername (string),
1044 CustomerCode (string),
1045 OrderID (string),| |
1046 |2| | |Receives the request and gets the status for the Order.| | |
1047 |3| |<=|Sends back the status of the order.|ResultCode (),
1048 ErrorMessage (string),
1049 OrderID (string),
1050 LabassignmentGUID (GUID),
1051 CertificateNumber (string)
1052 OrderStatusSIKB (int),
1053 Delayed (boolean),
1054 ExpectedTimeStamp (DateTime),|OrderStatusSIKB is the SIKB Labassignment status.
1055 \\Delayed is a boolean to tell the customer a order will be later ready then expected. The ExpectedTimestamp.
1056 If Delayed for the firsttime, TerraIndex can send a notification to the users and show a different layout.
1057 \\LabassignmentGUID is filled to support also Labassignments that are not from TerraIndex Ordered.|1 = Success,
1058 2 = GeneralError,
1059 3 = WrongSIKBVersion,
1060 4 = InvalidCredentials,
1061 5 = CustomerUsernameInvalid,
1062 6 = CustomerUsernameNotValidForCustomerCode
1063 7 = FileContentProblem,
1064 8 = InvalidOrderId,
1065 9 = OrderIdAlreadyApproved
1066 10 = PDFNotAvailable
1067 |4|Receives the status and shows in the interface the updated info.
1068 Update the CertificateNr if this is not already present in the labassignment. | | | |CertifcateNumber could be new here, if the lab wasn't able to fill it directly at the ApproveOrder.|
1069
1070
1071
1072