Changes for page Download a project (export)
Last modified by Nico Lemaire on 2025/09/01 13:36
From version 13.1
edited by Robin Huisman
on 2023/05/23 13:21
on 2023/05/23 13:21
Change comment:
There is no comment for this version
To version 1.2
edited by Roelof Zwaan
on 2021/11/22 10:41
on 2021/11/22 10:41
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Parent
-
... ... @@ -1,1 +1,1 @@ 1 -Implementati ondocumentation.WebHome1 +Implementatie dcoumentatie.WebHome - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki.Ro binHuisman1 +XWiki.RoelofZwaan - Content
-
... ... @@ -8,44 +8,10 @@ 8 8 ))) 9 9 ))) 10 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 15 (% class="row" %) 16 16 ((( 17 17 (% class="col-xs-12 col-sm-8" %) 18 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}}|((( 27 -[[https:~~/~~/web.terraindex.com/DataWS/ITWDataRestService_V1_0/GetProjectsJSON>>https://web.terraindex.com/DataWS/ITWDataRestService_V1_0/GetProjectsJSON]] 28 - 29 -[[https:~~/~~/web.terraindex.com/DataWS/ITWImportExportServiceASMX_V1_0.asmx>>https://web.terraindex.com/DataWSExternals/ITWImportExportServiceASMX_V1_0.asmx]] 30 -))) 31 -|**New**|{{code language="none"}}https://web.terraindex.com/DataWSExternals/{{/code}}|((( 32 -[[https:~~/~~/web.terraindex.com/DataWSExternals/ITWDataRestService_V1_0/GetProjectsJSON>>https://web.terraindex.com/DataWSExternals/ITWDataRestService_V1_0/GetProjectsJSON]] 33 - 34 -[[https:~~/~~/web.terraindex.com/DataWSExternals/ITWImportExportServiceASMX_V1_0.asmx>>https://web.terraindex.com/DataWSExternals/ITWImportExportServiceASMX_V1_0.asmx?wsdl]] 35 -))) 36 - 37 -== == 38 - 39 -{{info}} 40 -We also have new REST Calls, with the same Input Output formats: 41 -\\[[https:~~/~~/web.terraindex.com/datawsExternals/ITWImportExportRestService_V1_0/export>>https://web.terraindex.com/datawsExternals/ITWImportExportRestService_V1_0/export]] 42 - 43 -input as json: ExportRequest 44 -output as json: ExportResult 45 - 46 -as POST or GET 47 -{{/info}} 48 - 49 49 == 1. Retreive all changed project from TerraIndex == 50 50 51 51 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. ... ... @@ -52,7 +52,7 @@ 52 52 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. 53 53 54 54 To start connecting this webservice, you should use this URL: 55 -[[https:~~/~~/web.terraindex.com/DataWS Externals/ITWDataRestService_V1_0/GetProjectsJSON>>https://web.terraindex.com/DataWSExternals/ITWDataRestService_V1_0/GetProjectsJSON]]21 +[[https:~~/~~/web.terraindex.com/DataWS/ITWDataRestService_V1_0/GetProjectsJSON>>url:https://web.terraindex.com/DataWS/ITWDataRestService_V1_0/GetProjectsJSON]] 56 56 57 57 Fill the **Body **of a **POST **HTTP call with: 58 58 ... ... @@ -66,7 +66,7 @@ 66 66 "Language": "en" 67 67 }, 68 68 "LanguageCode": "en", 69 - "WebserviceVersion": "1.0",35 + "WebserviceVersion": 1, 70 70 "SearchFilter": "", 71 71 "ArchiveID": 0, 72 72 "PageSize": 30, ... ... @@ -268,12 +268,11 @@ 268 268 == 2. Retreive the project export from TerraIndex == 269 269 270 270 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. 271 -The format of the projectfile is documentated here: [[Documentation TerraIndex Export format - dsFieldProject.xsd>>Implementati ondocumentation.Documentation TerraIndex Export format - dsFieldProject\.xsd.WebHome]]237 +The format of the projectfile is documentated here: [[Documentation TerraIndex Export format - dsFieldProject.xsd>>Implementatie dcoumentatie.Documentation TerraIndex Export format - dsFieldProject\.xsd.WebHome]] 272 272 273 -To start connecting this webservice, you should use this URL of the Import Export Webservice: 239 +To start connecting this webservice, you should use this URL of the Import Export Webservice: 240 +[[https:~~/~~/web.terraindex.com/DataWS/ITWImportExportServiceASMX_V1_0.asmx>>url:https://web.terraindex.com/DataWS/ITWImportExportServiceASMX_V1_0.asmx]] 274 274 275 -[[https:~~/~~/web.terraindex.com/DataWSExternals/ITWImportExportService_V1_0.svc>>https://web.terraindex.com/DataWSExternals/ITWImportExportService_V1_0.svc]] 276 - 277 277 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. 278 278 279 279 [[image:image-20200108-123431.png]] ... ... @@ -287,15 +287,12 @@ 287 287 Also fill the license and the applicationCode. //(These two fields can be requested at the TerraIndex Servicedesk.)// 288 288 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. 289 289 Create at least create 2 parameters as in the image. Beacause 2 parameters are needed. 290 -//If JSON is prevered use: ExportType = 'Export_FIELD_JSON_v1_0_0'// 291 291 6; Fill the parameter with the FileName. 292 292 7; Fill the parameter with **projectID**. Instead of ‘ProjectID' it’s also possible to fill the parameter ‘ProjectCode'. 293 293 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. 294 294 9; The response field 'Filecontent’is filled if it went OK, and it contains XML you can serialize. 295 -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.** 296 -*Username and password are known by each TI user and the application manager of your company can create new usernames. 259 +\\*Username and password are known by each TI user and the application manager of your company can create new usernames. 297 297 298 - 299 299 **EXAMPLE CODE** 300 300 301 301 ExportType: ... ... @@ -337,76 +337,11 @@ 337 337 338 338 Example call 339 339 340 -{{code language="none" layout="LINENUMBERS"}} 341 -<soapenv:Envelope 342 - xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 343 - xmlns:itw="https://wsterraindex.terraindex.com/ITWorks.TerraIndex/"> 344 - <soapenv:Header></soapenv:Header> 345 - <soapenv:Body> 346 - <itw:Export> 347 - <itw:request> 348 - <itw:AuthorisationRequest> 349 - <itw:Username>USERNAME</itw:Username> 350 - <itw:Password>PASSWORD</itw:Password> 351 - <itw:Licensenumber>LICENSE</itw:Licensenumber> 352 - <itw:ApplicationCode>APPCODE</itw:ApplicationCode> 353 - </itw:AuthorisationRequest> 354 - <itw:WebserviceVersion>1.0</itw:WebserviceVersion> 355 - <itw:LanguageCode>nld</itw:LanguageCode> 356 - <itw:UseCompression>true</itw:UseCompression> 357 - <itw:TypeOfExport>Export_FIELD_XML_v1_0_0</itw:TypeOfExport> 358 - <itw:Parameters> 359 - <itw:ExportParameter> 360 - <itw:ParameterType>FileName</itw:ParameterType> 361 - <itw:StringValue>Export</itw:StringValue> 362 - </itw:ExportParameter> 363 - <itw:ExportParameter> 364 - <itw:ParameterType>projectID</itw:ParameterType> 365 - <itw:FloatValue>917</itw:FloatValue> 366 - </itw:ExportParameter> ----- 367 - <itw:ExportParameter> 368 - <itw:ParameterType>ProjectCode</itw:ParameterType> 369 - <itw:StringValue>202020</itw:StringValue> 370 - </itw:ExportParameter> ---- 371 - </itw:Parameters> 372 - <itw:LogFormat>XML</itw:LogFormat> 373 - <itw:UseZipStream>true</itw:UseZipStream> 374 - </itw:request> 375 - </itw:Export> 376 - </soapenv:Body> 377 -</soapenv:Envelope> 378 -{{/code}} 302 +<soapenv:Envelope xmlns:soapenv="http:~/~/schemas.xmlsoap.org/soap/envelope/" xmlns:itw="https:~/~/wsterraindex.terraindex.com/ITWorks.TerraIndex/"> <soapenv:Header/> <soapenv:Body> <itw:Export> <itw:request> <itw:AuthorisationRequest> <itw:Username>USERNAME</itw:Username> <itw:Password>PASSWORD</itw:Password> <itw:Licensenumber>LICENSE</itw:Licensenumber> <itw:ApplicationCode>APPCODE</itw:ApplicationCode> </itw:AuthorisationRequest> <itw:WebserviceVersion>1.0</itw:WebserviceVersion> <itw:LanguageCode>nld</itw:LanguageCode> <itw:UseCompression>true</itw:UseCompression> <itw:TypeOfExport>Export_FIELD_XML_v1_0_0</itw:TypeOfExport> <itw:Parameters> <itw:ExportParameter> <itw:ParameterType>FileName</itw:ParameterType> <itw:StringValue>Export</itw:StringValue> </itw:ExportParameter> <itw:ExportParameter> <itw:ParameterType>projectID</itw:ParameterType> <itw:FloatValue>917</itw:FloatValue> </itw:ExportParameter> ~-~-~-~-- <itw:ExportParameter> <itw:ParameterType>ProjectCode</itw:ParameterType> <itw:StringValue>202020</itw:StringValue> </itw:ExportParameter> ~-~-~-~- </itw:Parameters> <itw:LogFormat>XML</itw:LogFormat> <itw:UseZipStream>true</itw:UseZipStream> </itw:request> </itw:Export> </soapenv:Body></soapenv:Envelope> 379 379 380 380 Example response: 381 381 382 -{{code language="none"}} 383 -<soap:Envelope 384 - xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 385 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 386 - xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 387 - <soap:Body> 388 - <ExportResponse 389 - xmlns="https://wsterraindex.terraindex.com/ITWorks.TerraIndex/"> 390 - <ExportResult> 391 - <ResultCode>Export_Succes</ResultCode> 392 - <TypeOfExport>Export_TI_v1_0_0</TypeOfExport> 393 - <Files> 394 - <File> 395 - <FileName>917.xml</FileName> 396 - <TypeOfFile>Field_XML_Compressed</TypeOfFile> 397 - <FileContent>H4sIAAAAAAAEAFWRuZaqQABEP4hAGnAGggm6odlREFkkA2WRRRCBxv76YeYF70yFVXUqqBvgl4KQBzcZ8Aho2iqxdhxDSPDmNGjz9Z/weMa8/aimTAUeF42KgxRRzd3YaGfdXtvECEBvWafSNwf+dOsjVXpZUzs+lw/p3gBhuXQ5S8T3MdIBlxUQEam+LOVgVo4D8w4c2E8pEgp3haewcpQx1KQ41Z8DKWv16seaDLp3GABLuIKXK5Ucq31EfSXm0172YvG87hcbayYGdB1t0CbcuueLpU5UawgHSitFr564Aet5LeegD0/tocZDTvuIuc9Ja0tDFt/m7kZnomdVJc+2SkqBGXmTdPiiPzJa2OznLkX67p2PCNM7iHU11QbIilVkMDBVd0J8gK4Ams6ycJQagnww/SaxuiZ/EdS6DZ0cf17BIhUq87CSkQvxat/2dEG1xu94BoaeT7C8XR38/C1DZbpygwfW+gk8Z+Mgm3DDhAj8r6099Rj+5YNs5F3+5R5EUPmd6+EvYvj1Dd8o9lLwAQAA</FileContent> 398 - </File> 399 - <File> 400 - <FileName>ProjectInfo.xml</FileName> 401 - <TypeOfFile>Field_XML_Compressed</TypeOfFile> 402 - <FileContent>H4sIAAAAAAAEAI1Qy5JDQAD8IAdj1/M4hJggDBnEbTxDsV7BxtdvNqm9bx+6urq7+tBEnw+qiuETCLrcTlst9Pajtb0soj7JeynztNIubHK9XZJOXoojN8dXpaxltOlOwAZzK033Edx7HWT1ZFVYNljpsT7iCVDbxb5tlmw3GhV7vgty5jqiGzWSYEvL7RCIQifzchIoMJnHz+fO17C4JAwA0hNRb247SR1ba8OunCV4ralK1rjwBhUAJ2pihopeuxqXIUecePETLhx8zT6IZX5GzafC0XHTrauISeyIM2+2g1PzEymRZrTtglKlsFYHXDKmoYTp+jw1zNDyAFZOTN9XHkuNGmU33905uipWMTsjm2ccm6+bxqk2xAjCf/z3BwS1j+qVqTjrlDGJziCIhC59CHwafeNgI8d3U4cQQ+VXSdXb+QGLuAuvrAEAAA==</FileContent> 403 - </File> 404 - </Files> 405 - </ExportResult> 406 - </ExportResponse> 407 - </soap:Body> 408 -</soap:Envelope> 409 -{{/code}} 306 +<soap:Envelope xmlns:soap="http:~/~/schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http:~/~/www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http:~/~/www.w3.org/2001/XMLSchema"> <soap:Body> <ExportResponse xmlns="https:~/~/wsterraindex.terraindex.com/ITWorks.TerraIndex/"> <ExportResult> <ResultCode>Export_Succes</ResultCode> <TypeOfExport>Export_TI_v1_0_0</TypeOfExport> <Files> <File> <FileName>917.xml</FileName> <TypeOfFile>Field_XML_Compressed</TypeOfFile> <FileContent>H4sIAAAAAAAEAFWRuZaqQABEP4hAGnAGggm6odlREFkkA2WRRRCBxv76YeYF70yFVXUqqBvgl4KQBzcZ8Aho2iqxdhxDSPDmNGjz9Z/weMa8/aimTAUeF42KgxRRzd3YaGfdXtvECEBvWafSNwf+dOsjVXpZUzs+lw/p3gBhuXQ5S8T3MdIBlxUQEam+LOVgVo4D8w4c2E8pEgp3haewcpQx1KQ41Z8DKWv16seaDLp3GABLuIKXK5Ucq31EfSXm0172YvG87hcbayYGdB1t0CbcuueLpU5UawgHSitFr564Aet5LeegD0/tocZDTvuIuc9Ja0tDFt/m7kZnomdVJc+2SkqBGXmTdPiiPzJa2OznLkX67p2PCNM7iHU11QbIilVkMDBVd0J8gK4Ams6ycJQagnww/SaxuiZ/EdS6DZ0cf17BIhUq87CSkQvxat/2dEG1xu94BoaeT7C8XR38/C1DZbpygwfW+gk8Z+Mgm3DDhAj8r6099Rj+5YNs5F3+5R5EUPmd6+EvYvj1Dd8o9lLwAQAA</FileContent> </File> <File> <FileName>ProjectInfo.xml</FileName> <TypeOfFile>Field_XML_Compressed</TypeOfFile> <FileContent>H4sIAAAAAAAEAI1Qy5JDQAD8IAdj1/M4hJggDBnEbTxDsV7BxtdvNqm9bx+6urq7+tBEnw+qiuETCLrcTlst9Pajtb0soj7JeynztNIubHK9XZJOXoojN8dXpaxltOlOwAZzK033Edx7HWT1ZFVYNljpsT7iCVDbxb5tlmw3GhV7vgty5jqiGzWSYEvL7RCIQifzchIoMJnHz+fO17C4JAwA0hNRb247SR1ba8OunCV4ralK1rjwBhUAJ2pihopeuxqXIUecePETLhx8zT6IZX5GzafC0XHTrauISeyIM2+2g1PzEymRZrTtglKlsFYHXDKmoYTp+jw1zNDyAFZOTN9XHkuNGmU33905uipWMTsjm2ccm6+bxqk2xAjCf/z3BwS1j+qVqTjrlDGJziCIhC59CHwafeNgI8d3U4cQQ+VXSdXb+QGLuAuvrAEAAA==</FileContent> </File> </Files> </ExportResult> </ExportResponse> </soap:Body></soap:Envelope> 410 410 411 411 412 412 == Zip Stream class == ... ... @@ -413,137 +413,16 @@ 413 413 414 414 If needed, this is the Zip Stream class you can use to extract the zipstream as used above: 415 415 416 -{{code language="Csharp" layout="LINENUMBERS"}} 417 -/// <summary> 418 -/// Helper class for compress en decompress of file data 419 -/// </summary> 420 -public static class ZipStreamHelper { 421 - #region Compress and encode 422 - /// <summary> 423 - /// Comprimeer een string en geeft deze terug in Base64 string. 424 - /// </summary> 425 - /// <param name="content">filecontent</param> 426 - /// <returns>gecomprimeerde string</returns> 427 - public static string CompressToBase64String(string content) { 428 - //string to byte[] 429 - byte[] contentArray = stringToByteArray(content); 430 - // Compress 431 - byte[] compressed = Compress(contentArray); 432 - return base64_encode(compressed); 433 - } 434 - 435 - /// <summary> 436 - /// Zet een string om naar een ByteArray 437 - /// </summary> 438 - /// <param name="content">filecontent</param> 439 - /// <returns>ByteArray</returns> 440 - public static byte[] stringToByteArray(string content) { 441 - System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); 442 - return encoding.GetBytes(content); 443 - } 444 - 445 - /// <summary> 446 - /// comprimeer een ByteArray 447 - /// </summary> 448 - /// <param name="data">filedata als ByteArray</param> 449 - /// <returns>gecomprimeerde ByteArray</returns> 450 - public static byte[] Compress(byte[] data) { 451 - using(var compressedStream = new MemoryStream()) 452 - using(var zipStream = new GZipStream(compressedStream, CompressionMode.Compress)) { 453 - zipStream.Write(data, 0, data.Length); 454 - zipStream.Close(); 455 - return compressedStream.ToArray(); 456 - } 457 - } 458 - 459 - /// <summary> 460 - /// Zet een ByteArray om naar een Base64 string 461 - /// </summary> 462 - /// <param name="data">gecomprimeerde ByteArray</param> 463 - /// <returns>Base 64 string</returns> 464 - public static string base64_encode(byte[] data) { 465 - if (data == null) 466 - return string.Empty; 467 - return Convert.ToBase64String(data); 468 - } 469 - 470 - /// <summary> 471 - /// Zet een string om naar een Base64 string 472 - /// </summary> 473 - /// <param name="data">string</param> 474 - /// <returns>Base 64 string</returns> 475 - public static string string_base64_encode(string data) { 476 - if (string.IsNullOrEmpty(data)) 477 - return string.Empty; 478 - 479 - //string to byte[] 480 - byte[] contentArray = stringToByteArray(data); 481 - return base64_encode(contentArray); 482 - } 483 - #endregion 484 - 485 - #region Decompress and decode 486 - // Decode and decompress 487 - /// <summary> 488 - /// Decomprimeer een Base64 string naar een string 489 - /// </summary> 490 - /// <param name="contentBase64">GZIP Base64 string</param> 491 - /// <returns>string</returns> 492 - public static string DecompressBase64StringToString(string contentBase64) { 493 - // Decompress 494 - byte[] decoded = base64_decode(contentBase64); 495 - byte[] decompressed = Decompress(decoded); 496 - 497 - return byteArrayTostring(decompressed); 498 - } 499 - 500 - /// <summary> 501 - /// Zet een ByteArray om in een normale string 502 - /// </summary> 503 - /// <param name="data">ByteArray</param> 504 - /// <returns>string</returns> 505 - public static string byteArrayTostring(byte[] data) { 506 - System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); 507 - return enc.GetString(data); 508 - } 509 - 510 - /// <summary> 511 - /// Zet een Base64 string om naar een ByteArray 512 - /// </summary> 513 - /// <param name="encodedData">Base64 string</param> 514 - /// <returns>gecomprimeerde ByteArray</returns> 515 - public static byte[] base64_decode(string encodedData) { 516 - byte[] encodedDataAsBytes = Convert.FromBase64String(encodedData); 517 - return encodedDataAsBytes; 518 - } 519 - 520 - /// <summary> 521 - /// Zet een gecomprimeerde ByteArray om in een ByteArray 522 - /// </summary> 523 - /// <param name="data">gecomprimeerde ByteArray</param> 524 - /// <returns>ByteArray (gedecomprimeerd)</returns> 525 - public static byte[] Decompress(byte[] data) { 526 - using(var compressedStream = new MemoryStream(data)) 527 - using(var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress)) 528 - using(var resultStream = new MemoryStream()) { 529 - var buffer = new byte[4096]; 530 - int read; 531 - 532 - while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0) { 533 - resultStream.Write(buffer, 0, read); 534 - } 535 - 536 - return resultStream.ToArray(); 537 - } 538 - } 539 - #endregion 540 -} 541 -{{/code}} 313 +~/~// <summary> ~/~// Helper class for compress en decompress of file data ~/~// </summary> public static class ZipStreamHelper { #region Compress and encode ~/~// <summary> ~/~// Comprimeer een string en geeft deze terug in Base64 string. ~/~// </summary> ~/~// <param name="content">filecontent</param> ~/~// <returns>gecomprimeerde string</returns> public static string CompressToBase64String(string content) { ~/~/string to byte[] byte[] contentArray = stringToByteArray(content); ~/~/ Compress byte[] compressed = Compress(contentArray); return base64_encode(compressed); } ~/~// <summary> ~/~// Zet een string om naar een ByteArray ~/~// </summary> ~/~// <param name="content">filecontent</param> ~/~// <returns>ByteArray</returns> public static byte[] stringToByteArray(string content) { System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); return encoding.GetBytes(content); } ~/~// <summary> ~/~// comprimeer een ByteArray ~/~// </summary> ~/~// <param name="data">filedata als ByteArray</param> ~/~// <returns>gecomprimeerde ByteArray</returns> public static byte[] Compress(byte[] data) { using (var compressedStream = new MemoryStream()) using (var zipStream = new GZipStream(compressedStream, CompressionMode.Compress)) { zipStream.Write(data, 0, data.Length); zipStream.Close(); return compressedStream.ToArray(); } } ~/~// <summary> ~/~// Zet een ByteArray om naar een Base64 string ~/~// </summary> ~/~// <param name="data">gecomprimeerde ByteArray</param> ~/~// <returns>Base 64 string</returns> public static string base64_encode(byte[] data) { if (data == null) return string.Empty; return Convert.ToBase64String(data); } ~/~// <summary> ~/~// Zet een string om naar een Base64 string ~/~// </summary> ~/~// <param name="data">string</param> ~/~// <returns>Base 64 string</returns> public static string string_base64_encode(string data) { if (string.IsNullOrEmpty(data)) return string.Empty; ~/~/string to byte[] byte[] contentArray = stringToByteArray(data); return base64_encode(contentArray); } #endregion #region Decompress and decode ~/~/ Decode and decompress ~/~// <summary> ~/~// Decomprimeer een Base64 string naar een string ~/~// </summary> ~/~// <param name="contentBase64">GZIP Base64 string</param> ~/~// <returns>string</returns> public static string DecompressBase64StringToString(string contentBase64) { ~/~/ Decompress byte[] decoded = base64_decode(contentBase64); byte[] decompressed = Decompress(decoded); return byteArrayTostring(decompressed); } ~/~// <summary> ~/~// Zet een ByteArray om in een normale string ~/~// </summary> ~/~// <param name="data">ByteArray</param> ~/~// <returns>string</returns> public static string byteArrayTostring(byte[] data) { System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); return enc.GetString(data); } ~/~// <summary> ~/~// Zet een Base64 string om naar een ByteArray ~/~// </summary> ~/~// <param name="encodedData">Base64 string</param> ~/~// <returns>gecomprimeerde ByteArray</returns> public static byte[] base64_decode(string encodedData) { byte[] encodedDataAsBytes = Convert.FromBase64String(encodedData); return encodedDataAsBytes; } ~/~// <summary> ~/~// Zet een gecomprimeerde ByteArray om in een ByteArray ~/~// </summary> ~/~// <param name="data">gecomprimeerde ByteArray</param> ~/~// <returns>ByteArray (gedecomprimeerd)</returns> public static byte[] Decompress(byte[] data) { using (var compressedStream = new MemoryStream(data)) using (var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress)) using (var resultStream = new MemoryStream()) { var buffer = new byte[4096]; int read; while ((read = zipStream.Read(buffer, 0, buffer.Length)) > 0) { resultStream.Write(buffer, 0, read); } return resultStream.ToArray(); } } #endregion } 542 542 ))) 543 543 544 544 545 545 (% class="col-xs-12 col-sm-4" %) 546 546 ((( 319 +{{box title="**Contents**"}} 320 +{{toc/}} 321 +{{/box}} 322 + 547 547 548 548 ))) 549 549 )))