Version 1.4 by Robin Huisman on 2022/02/08 11:45

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