Version 6.2 by Robert Jan Daams on 2022/08/23 11:14

Show last authors
1 (% class="jumbotron" %)
2 (((
3 (% class="container" %)
4 (((
5 To connect with the TerraIndex database to retreive projects from or upload new projects, you can connect to a webservice. This webservice provides Exports and enables these export with changes to be uploaded again.
6
7 There are two steps to consider, it’s possible to request an exact projectcode export or you could request all changed projects from a timestamp. This last option is an additional Webservice call that is very easy to use. It will tell you what Project to download because they have changes since a timestamp. This Timestamp could be your last donwload moment.
8 )))
9 )))
10
11 {{box title="**Contents**"}}
12 [[image:data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==||height="15" role="presentation" title="Click and drag to move" width="15"]]
13 {{/box}}
14
15 (% class="row" %)
16 (((
17 (% class="col-xs-12 col-sm-8" %)
18 (((
19 == Changelog ==
20
21 === Update 2022-08-23 ===
22
23 As part of on-going efforts to improve performance and scalability, we have introduced a dedicated version of DataWS named DataWSExternals.  This new service should be used for external API consumers.
24
25 | |**URL**|
26 |**Old**|{{code language="none"}}https://web.terraindex.com/DataWS/{{/code}}|[[https:~~/~~/web.terraindex.com/DataWS/ITWImportExportServiceASMX_V1_0.asmx?wsdl>>https://web.terraindex.com/DataWS/ITWImportExportServiceASMX_V1_0.asmx?wsdl]]
27 |**New**|​{{code language="none"}}https://web.terraindex.com/DataWSExternals/{{/code}}|[[https:~~/~~/web.terraindex.com/DataWSExternals/ITWImportExportServiceASMX_V1_0.asmx?wsdl>>https://web.terraindex.com/DataWSExternals/ITWImportExportServiceASMX_V1_0.asmx?wsdl]]
28
29 (% class="wikigeneratedid" %)
30 == ==
31
32 == 1. Retreive all changed project from TerraIndex ==
33
34 To retreive all changed project from the TerraIndex database since a specific timestamp, there is a webservice call you can do. This will return all project rows that have changes since the timestamp you send within the request.
35 This way you only download projects that have changes, and it will not request project that are not needed, so it won’t keep our servers busy with exports that are not necessary.
36
37 To start connecting this webservice, you should use this URL:
38 [[https:~~/~~/web.terraindex.com/DataWS/ITWDataRestService_V1_0/GetProjectsJSON>>url:https://web.terraindex.com/DataWS/ITWDataRestService_V1_0/GetProjectsJSON]]
39
40 Fill the **Body **of a **POST **HTTP call with:
41
42 {{code language="JSON" layout="LINENUMBERS"}}
43 {
44 "Authorisation": {
45 "Username": "username",
46 "Password": "password",
47 "Licensenumber": 123,
48 "ApplicationCode": 12,
49 "Language": "en"
50 },
51 "LanguageCode": "en",
52 "WebserviceVersion": "1.0",
53 "SearchFilter": "",
54 "ArchiveID": 0,
55 "PageSize": 30,
56 "LastRowNR": 0,
57 "OrderPreviewBy": 2,
58 "FromDateContentLastChanged": "2019-04-01T00:00:00"
59 }
60 {{/code}}
61
62
63 Set the correct values for:
64
65 * (% class="mark" %)username(%%); as the username in TerraIndex
66 * (% class="mark" %)password(%%); as the username in TerraIndex
67 * (% class="mark" %)LicenseNumber(%%); as your companies license number
68 * (% class="mark" %)ApplicationCode(%%); as provided by TerraIndex to you, if not provided, request one at: service@terraindex.com
69 * (% class="mark" %)PageSize (%%)is in the example set to 30, it will return max 30 projects if possible. This can be upgraded to more records, but it will take longer.
70 * (% class="mark" %)FromDateContentLastChanged(%%); set the correct timestamp of your last call, it will return all projects that have been changed since that timestamp.
71 * (% class="mark" %)SearchFilter(%%); set a part of the projectcode in this field and it will search for projectcodes with this specific text part in it. It will add wildcars in front and at the end of the searchfilter automatically. So not needed to provide. The searchfilter will be applied on three columns: Project Code, Project Name and Project location City name.
72 * (% class="mark" %)LastRowNR(%%); fill default with zero/'0'. If your project isn’t in the first page of 30, you could use this field for lazy loading. Call the webservice with in the request the LastRowNR = 30, and you will receive project rows 31 t/m 60 (when the pagesize is 30).
73
74 Fill the header with:
75
76 {{code language="none"}}
77 application/json
78 {{/code}}
79
80
81 You will receive a reponse like this:
82
83 {{code language="JSON" layout="LINENUMBERS"}}
84 [
85 {
86 "PrID": 242,
87 "PrCode": "2018-010-DEMO",
88 "PrName": "TU Delft, the Netherlands",
89 "PrTypeCode": null,
90 "PrLocName": null,
91 "PrLocCity": null,
92 "PrLeaderCode": "Consult",
93 "PrConsultancyFirm": "TerraIndex",
94 "PrFieldworkFirm": "TerraIndex",
95 "PrPrincipalName": null,
96 "PrDateLastChanged": "2018-08-31T11:12:50.45",
97 "RowNumber": 1,
98 "Uitwissel": 0,
99 "geometryWKT_WGS84": "POINT (6.1000890695634133 52.58846240818189)"
100 },
101 {
102 "PrID": 241,
103 "PrCode": "2018-009-DEMO",
104 "PrName": "TU Delft, the Netherlands",
105 "PrTypeCode": null,
106 "PrLocName": null,
107 "PrLocCity": null,
108 "PrLeaderCode": "Consult",
109 "PrConsultancyFirm": "TerraIndex",
110 "PrFieldworkFirm": "TerraIndex",
111 "PrPrincipalName": null,
112 "PrDateLastChanged": "2018-08-31T11:12:48.603",
113 "RowNumber": 2,
114 "Uitwissel": 0,
115 "geometryWKT_WGS84": "POINT (6.1000890695634133 52.58846240818189)"
116 },
117 {
118 "PrID": 240,
119 "PrCode": "2018-008-DEMO",
120 "PrName": "TU Delft, the Netherlands",
121 "PrTypeCode": null,
122 "PrLocName": null,
123 "PrLocCity": null,
124 "PrLeaderCode": "Consult",
125 "PrConsultancyFirm": "TerraIndex",
126 "PrFieldworkFirm": "TerraIndex",
127 "PrPrincipalName": null,
128 "PrDateLastChanged": "2018-08-31T11:12:46.46",
129 "RowNumber": 3,
130 "Uitwissel": 0,
131 "geometryWKT_WGS84": "POINT (6.1000890695634133 52.58846240818189)"
132 },
133 {
134 "PrID": 239,
135 "PrCode": "2018-007-DEMO",
136 "PrName": "TU Delft, the Netherlands",
137 "PrTypeCode": null,
138 "PrLocName": null,
139 "PrLocCity": null,
140 "PrLeaderCode": "Consult",
141 "PrConsultancyFirm": "TerraIndex",
142 "PrFieldworkFirm": "TerraIndex",
143 "PrPrincipalName": null,
144 "PrDateLastChanged": "2018-08-31T11:12:44.853",
145 "RowNumber": 4,
146 "Uitwissel": 0,
147 "geometryWKT_WGS84": "POINT (6.1000890695634133 52.58846240818189)"
148 },
149 {
150 "PrID": 238,
151 "PrCode": "2018-006-DEMO",
152 "PrName": "TU Delft, the Netherlands",
153 "PrTypeCode": null,
154 "PrLocName": null,
155 "PrLocCity": null,
156 "PrLeaderCode": "Consult",
157 "PrConsultancyFirm": "TerraIndex",
158 "PrFieldworkFirm": "TerraIndex",
159 "PrPrincipalName": null,
160 "PrDateLastChanged": "2018-08-31T11:12:43.033",
161 "RowNumber": 5,
162 "Uitwissel": 0,
163 "geometryWKT_WGS84": "POINT (6.1000890695634133 52.58846240818189)"
164 },
165 {
166 "PrID": 237,
167 "PrCode": "2018-005-DEMO",
168 "PrName": "TU Delft, the Netherlands",
169 "PrTypeCode": null,
170 "PrLocName": null,
171 "PrLocCity": null,
172 "PrLeaderCode": "Consult",
173 "PrConsultancyFirm": "TerraIndex",
174 "PrFieldworkFirm": "TerraIndex",
175 "PrPrincipalName": null,
176 "PrDateLastChanged": "2018-08-31T11:12:41.273",
177 "RowNumber": 6,
178 "Uitwissel": 0,
179 "geometryWKT_WGS84": "POINT (6.1000890695634133 52.58846240818189)"
180 },
181 {
182 "PrID": 236,
183 "PrCode": "2018-004-DEMO",
184 "PrName": "TU Delft, the Netherlands",
185 "PrTypeCode": null,
186 "PrLocName": null,
187 "PrLocCity": null,
188 "PrLeaderCode": "Consult",
189 "PrConsultancyFirm": "TerraIndex",
190 "PrFieldworkFirm": "TerraIndex",
191 "PrPrincipalName": null,
192 "PrDateLastChanged": "2018-08-31T11:12:39.57",
193 "RowNumber": 7,
194 "Uitwissel": 0,
195 "geometryWKT_WGS84": "POINT (6.1000890695634133 52.58846240818189)"
196 },
197 {
198 "PrID": 235,
199 "PrCode": "2018-003-DEMO",
200 "PrName": "TU Delft, the Netherlands",
201 "PrTypeCode": null,
202 "PrLocName": null,
203 "PrLocCity": null,
204 "PrLeaderCode": "Consult",
205 "PrConsultancyFirm": "TerraIndex",
206 "PrFieldworkFirm": "TerraIndex",
207 "PrPrincipalName": null,
208 "PrDateLastChanged": "2018-08-31T11:12:37.77",
209 "RowNumber": 8,
210 "Uitwissel": 0,
211 "geometryWKT_WGS84": "POINT (6.1000890695634133 52.58846240818189)"
212 },
213 {
214 "PrID": 234,
215 "PrCode": "2018-002-DEMO",
216 "PrName": "TU Delft, the Netherlands",
217 "PrTypeCode": null,
218 "PrLocName": null,
219 "PrLocCity": null,
220 "PrLeaderCode": "Consult",
221 "PrConsultancyFirm": "TerraIndex",
222 "PrFieldworkFirm": "TerraIndex",
223 "PrPrincipalName": null,
224 "PrDateLastChanged": "2018-08-31T11:12:36.02",
225 "RowNumber": 9,
226 "Uitwissel": 0,
227 "geometryWKT_WGS84": "POINT (6.1000890695634133 52.58846240818189)"
228 },
229 {
230 "PrID": 233,
231 "PrCode": "2018-001-DEMO",
232 "PrName": "TU Delft, the Netherlands",
233 "PrTypeCode": null,
234 "PrLocName": null,
235 "PrLocCity": null,
236 "PrLeaderCode": "Consult",
237 "PrConsultancyFirm": "TerraIndex",
238 "PrFieldworkFirm": "TerraIndex",
239 "PrPrincipalName": null,
240 "PrDateLastChanged": "2018-08-31T11:12:30.037",
241 "RowNumber": 10,
242 "Uitwissel": 0,
243 "geometryWKT_WGS84": "POINT (4.3694882989839243 52.00722295311251)"
244 }
245 ]
246 {{/code}}
247
248 The **PrID **can be used as **ProjectID **in the next call to get the actual project xml file export.
249
250
251 == 2. Retreive the project export from TerraIndex ==
252
253 To request the export from TerraIndex we have a SOAP webservice. This webservice is called the ExportService, and it will provide a full project in TerraIndex Format.
254 The format of the projectfile is documentated here: [[Documentation TerraIndex Export format - dsFieldProject.xsd>>Implementation documentation.Documentation TerraIndex Export format - dsFieldProject\.xsd.WebHome]]
255
256 To start connecting this webservice, you should use this URL of the Import Export Webservice:
257 [[https:~~/~~/web.terraindex.com/DataWS/ITWImportExportServiceASMX_V1_0.asmx>>url:https://web.terraindex.com/DataWS/ITWImportExportServiceASMX_V1_0.asmx]]
258
259 With this URL many IDE’s can create a proxy for you, just by providing the URL. Once this proxy is created, you will have a few classes looking like the call in the image below.
260
261 [[image:image-20200108-123431.png]]
262
263 The image is created with WebserviceStudio to visualise the SOAP call to send to the webservice.
264 This is the explanation of each number inside the image~:
265 1; The endpoint URL
266 2; Create the proxy based on the WSDL
267 3; Select the export call to see what it looks like
268 4; Fill the username + password of the TerraIndex user* to call the webservice with.
269 Also fill the license and the applicationCode. //(These two fields can be requested at the TerraIndex Servicedesk.)//
270 5; Fill the **ExportType **'**Export_FIELD_XML_v1_0_0**’. This export corresponds with dsFieldProject.xsd and is the best XML to connect TI with.
271 Create at least create 2 parameters as in the image. Beacause 2 parameters are needed.
272 //If JSON is prevered use: ExportType = 'Export_FIELD_JSON_v1_0_0'//
273 6; Fill the parameter with the FileName.
274 7; Fill the parameter with **projectID**. Instead of ‘ProjectID' it’s also possible to fill the parameter ‘ProjectCode'.
275 8; Send the request and wait for the reponse. In response field ‘ResultCode’ should be 'SUCCES’ when it all went OK. If not it will tell what went wrong.
276 9; The response field 'Filecontent’is filled if it went OK, and it contains XML you can serialize.
277 10; an extra parameter is added calles: **UseZipStream**. The result data is default Base64 encoded, if you add UseZipStream = true, the result string is GZIPSTREAMED Base64 encoded. **At the end of this page, we have added an class as code, to parse the base64 or ZIPStream Base64 to a normal string.**
278 *Username and password are known by each TI user and the application manager of your company can create new usernames.
279
280
281 **EXAMPLE CODE**
282
283 ExportType:
284 ITWorks.TerraIndex.ImportExportTest.ImportExportServiceTest.ExportType.Export_Field_XML_v1_0_0;
285
286 {{code language="C#" layout="LINENUMBERS"}}
287 [TestMethod] public void Export_FieldXml_Local() {
288 ITWorks.TerraIndex.ImportExportTest.ImportExportServiceTest.TWImportExportServiceASMX_V1_0SoapClient client = new ITWorks.TerraIndex.ImportExportTest.ImportExportServiceTest.TWImportExportServiceASMX_V1_0SoapClient();
289 ITWorks.TerraIndex.ImportExportTest.ImportExportServiceTest.ExportRequest req = new ITWorks.TerraIndex.ImportExportTest.ImportExportServiceTest.ExportRequest() {
290 AuthorisationRequest = new ITWorks.TerraIndex.ImportExportTest.ImportExportServiceTest.AuthorisationRequest() {
291 Username = "xxxxx", Password = "xxxxx", Licensenumber = "x"
292 }, LanguageCode = "eng", WebserviceVersion = "1.0",
293 };
294 req.TypeOfExport = ITWorks.TerraIndex.ImportExportTest.ImportExportServiceTest.ExportType.Export_Field_XML_v1_0_0;
295 req.UseZipStream = true;
296 List < ExportParameter > paramsList = new List < ExportParameter > ();
297 paramsList.Add(new ExportParameter() {
298 ParameterType = ExportParameterType.FileName, StringValue = "Export"
299 });
300 paramsList.Add(new ExportParameter() {
301 ParameterType = ExportParameterType.ProjectID, FloatValue = 917
302 });
303 req.Parameters = paramsList;
304 try {
305 var result = client.Export(req);
306 if (result != null) {
307 if (result.ResultCode == ITWorks.TerraIndex.ImportExportTest.ImportExportServiceTest.ExportResultCode.Export_Succes) {
308 System.IO.File.WriteAllText(@ "C:\Temp\ExportTestField.xml", result.Files[0].FileContent);
309 System.IO.File.WriteAllText(@ "C:\Temp\ExportTestField.html", result.ExportLog);
310 } else {
311 throw new Exception(result.ResultCode.ToString() + " - " + result.ResultMessage);
312 }
313 }
314 } catch (Exception e) {
315 throw e;
316 }
317 }
318 {{/code}}
319
320 Example call
321
322 {{code language="none" layout="LINENUMBERS"}}
323 <soapenv:Envelope
324 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
325 xmlns:itw="https://wsterraindex.terraindex.com/ITWorks.TerraIndex/">
326 <soapenv:Header></soapenv:Header>
327 <soapenv:Body>
328 <itw:Export>
329 <itw:request>
330 <itw:AuthorisationRequest>
331 <itw:Username>USERNAME</itw:Username>
332 <itw:Password>PASSWORD</itw:Password>
333 <itw:Licensenumber>LICENSE</itw:Licensenumber>
334 <itw:ApplicationCode>APPCODE</itw:ApplicationCode>
335 </itw:AuthorisationRequest>
336 <itw:WebserviceVersion>1.0</itw:WebserviceVersion>
337 <itw:LanguageCode>nld</itw:LanguageCode>
338 <itw:UseCompression>true</itw:UseCompression>
339 <itw:TypeOfExport>Export_FIELD_XML_v1_0_0</itw:TypeOfExport>
340 <itw:Parameters>
341 <itw:ExportParameter>
342 <itw:ParameterType>FileName</itw:ParameterType>
343 <itw:StringValue>Export</itw:StringValue>
344 </itw:ExportParameter>
345 <itw:ExportParameter>
346 <itw:ParameterType>projectID</itw:ParameterType>
347 <itw:FloatValue>917</itw:FloatValue>
348 </itw:ExportParameter> -----
349 <itw:ExportParameter>
350 <itw:ParameterType>ProjectCode</itw:ParameterType>
351 <itw:StringValue>202020</itw:StringValue>
352 </itw:ExportParameter> ----
353 </itw:Parameters>
354 <itw:LogFormat>XML</itw:LogFormat>
355 <itw:UseZipStream>true</itw:UseZipStream>
356 </itw:request>
357 </itw:Export>
358 </soapenv:Body>
359 </soapenv:Envelope>
360 {{/code}}
361
362 Example response:
363
364 {{code language="none"}}
365 <soap:Envelope
366 xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
367 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
368 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
369 <soap:Body>
370 <ExportResponse
371 xmlns="https://wsterraindex.terraindex.com/ITWorks.TerraIndex/">
372 <ExportResult>
373 <ResultCode>Export_Succes</ResultCode>
374 <TypeOfExport>Export_TI_v1_0_0</TypeOfExport>
375 <Files>
376 <File>
377 <FileName>917.xml</FileName>
378 <TypeOfFile>Field_XML_Compressed</TypeOfFile>
379 <FileContent>H4sIAAAAAAAEAFWRuZaqQABEP4hAGnAGggm6odlREFkkA2WRRRCBxv76YeYF70yFVXUqqBvgl4KQBzcZ8Aho2iqxdhxDSPDmNGjz9Z/weMa8/aimTAUeF42KgxRRzd3YaGfdXtvECEBvWafSNwf+dOsjVXpZUzs+lw/p3gBhuXQ5S8T3MdIBlxUQEam+LOVgVo4D8w4c2E8pEgp3haewcpQx1KQ41Z8DKWv16seaDLp3GABLuIKXK5Ucq31EfSXm0172YvG87hcbayYGdB1t0CbcuueLpU5UawgHSitFr564Aet5LeegD0/tocZDTvuIuc9Ja0tDFt/m7kZnomdVJc+2SkqBGXmTdPiiPzJa2OznLkX67p2PCNM7iHU11QbIilVkMDBVd0J8gK4Ams6ycJQagnww/SaxuiZ/EdS6DZ0cf17BIhUq87CSkQvxat/2dEG1xu94BoaeT7C8XR38/C1DZbpygwfW+gk8Z+Mgm3DDhAj8r6099Rj+5YNs5F3+5R5EUPmd6+EvYvj1Dd8o9lLwAQAA</FileContent>
380 </File>
381 <File>
382 <FileName>ProjectInfo.xml</FileName>
383 <TypeOfFile>Field_XML_Compressed</TypeOfFile>
384 <FileContent>H4sIAAAAAAAEAI1Qy5JDQAD8IAdj1/M4hJggDBnEbTxDsV7BxtdvNqm9bx+6urq7+tBEnw+qiuETCLrcTlst9Pajtb0soj7JeynztNIubHK9XZJOXoojN8dXpaxltOlOwAZzK033Edx7HWT1ZFVYNljpsT7iCVDbxb5tlmw3GhV7vgty5jqiGzWSYEvL7RCIQifzchIoMJnHz+fO17C4JAwA0hNRb247SR1ba8OunCV4ralK1rjwBhUAJ2pihopeuxqXIUecePETLhx8zT6IZX5GzafC0XHTrauISeyIM2+2g1PzEymRZrTtglKlsFYHXDKmoYTp+jw1zNDyAFZOTN9XHkuNGmU33905uipWMTsjm2ccm6+bxqk2xAjCf/z3BwS1j+qVqTjrlDGJziCIhC59CHwafeNgI8d3U4cQQ+VXSdXb+QGLuAuvrAEAAA==</FileContent>
385 </File>
386 </Files>
387 </ExportResult>
388 </ExportResponse>
389 </soap:Body>
390 </soap:Envelope>
391 {{/code}}
392
393
394 == Zip Stream class ==
395
396 If needed, this is the Zip Stream class you can use to extract the zipstream as used above:
397
398 {{code language="Csharp" layout="LINENUMBERS"}}
399 /// <summary>
400 /// Helper class for compress en decompress of file data
401 /// </summary>
402 public static class ZipStreamHelper {
403 #region Compress and encode
404 /// <summary>
405 /// Comprimeer een string en geeft deze terug in Base64 string.
406 /// </summary>
407 /// <param name="content">filecontent</param>
408 /// <returns>gecomprimeerde string</returns>
409 public static string CompressToBase64String(string content) {
410 //string to byte[]
411 byte[] contentArray = stringToByteArray(content);
412 // Compress
413 byte[] compressed = Compress(contentArray);
414 return base64_encode(compressed);
415 }
416
417 /// <summary>
418 /// Zet een string om naar een ByteArray
419 /// </summary>
420 /// <param name="content">filecontent</param>
421 /// <returns>ByteArray</returns>
422 public static byte[] stringToByteArray(string content) {
423 System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
424 return encoding.GetBytes(content);
425 }
426
427 /// <summary>
428 /// comprimeer een ByteArray
429 /// </summary>
430 /// <param name="data">filedata als ByteArray</param>
431 /// <returns>gecomprimeerde ByteArray</returns>
432 public static byte[] Compress(byte[] data) {
433 using(var compressedStream = new MemoryStream())
434 using(var zipStream = new GZipStream(compressedStream, CompressionMode.Compress)) {
435 zipStream.Write(data, 0, data.Length);
436 zipStream.Close();
437 return compressedStream.ToArray();
438 }
439 }
440
441 /// <summary>
442 /// Zet een ByteArray om naar een Base64 string
443 /// </summary>
444 /// <param name="data">gecomprimeerde ByteArray</param>
445 /// <returns>Base 64 string</returns>
446 public static string base64_encode(byte[] data) {
447 if (data == null)
448 return string.Empty;
449 return Convert.ToBase64String(data);
450 }
451
452 /// <summary>
453 /// Zet een string om naar een Base64 string
454 /// </summary>
455 /// <param name="data">string</param>
456 /// <returns>Base 64 string</returns>
457 public static string string_base64_encode(string data) {
458 if (string.IsNullOrEmpty(data))
459 return string.Empty;
460
461 //string to byte[]
462 byte[] contentArray = stringToByteArray(data);
463 return base64_encode(contentArray);
464 }
465 #endregion
466
467 #region Decompress and decode
468 // Decode and decompress
469 /// <summary>
470 /// Decomprimeer een Base64 string naar een string
471 /// </summary>
472 /// <param name="contentBase64">GZIP Base64 string</param>
473 /// <returns>string</returns>
474 public static string DecompressBase64StringToString(string contentBase64) {
475 // Decompress
476 byte[] decoded = base64_decode(contentBase64);
477 byte[] decompressed = Decompress(decoded);
478
479 return byteArrayTostring(decompressed);
480 }
481
482 /// <summary>
483 /// Zet een ByteArray om in een normale string
484 /// </summary>
485 /// <param name="data">ByteArray</param>
486 /// <returns>string</returns>
487 public static string byteArrayTostring(byte[] data) {
488 System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
489 return enc.GetString(data);
490 }
491
492 /// <summary>
493 /// Zet een Base64 string om naar een ByteArray
494 /// </summary>
495 /// <param name="encodedData">Base64 string</param>
496 /// <returns>gecomprimeerde ByteArray</returns>
497 public static byte[] base64_decode(string encodedData) {
498 byte[] encodedDataAsBytes = Convert.FromBase64String(encodedData);
499 return encodedDataAsBytes;
500 }
501
502 /// <summary>
503 /// Zet een gecomprimeerde ByteArray om in een ByteArray
504 /// </summary>
505 /// <param name="data">gecomprimeerde ByteArray</param>
506 /// <returns>ByteArray (gedecomprimeerd)</returns>
507 public static byte[] Decompress(byte[] data) {
508 using(var compressedStream = new MemoryStream(data))
509 using(var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
510 using(var resultStream = new MemoryStream()) {
511 var buffer = new byte[4096];
512 int read;
513
514 while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0) {
515 resultStream.Write(buffer, 0, read);
516 }
517
518 return resultStream.ToArray();
519 }
520 }
521 #endregion
522 }
523 {{/code}}
524 )))
525
526
527 (% class="col-xs-12 col-sm-4" %)
528 (((
529
530 )))
531 )))