Zip GZip Compress string file (OpenInsight 32-bit)
At 04 FEB 2022 12:06:13PM Bruce Cameron wrote:
Hello all, – East coasters – careful on the roads out there!
I need to ZIP/Compress a large string of data before sending it as part of a SOAP POST.
Before I start down the path I was wondering if anything existed already (Rev or 3rd party)?
In my ideal world a function such as: Zip(submissionPayloadstring) was what I was thinking.
If not, I did see this thread from 2014;
which looks promising but I thought I would check first.
Thanks.
At 11 FEB 2022 11:55AM bshumsky wrote:
Hi, Bruce. Is this in OI 9.x or OI 10.x?
There is a function, UTILITY_DOTNET, that includes a method to zip and unzip files and folders. I'm pretty sure the functionality is present in both OI 9 and OI 10, but I'm SURE it's in OI 10…
It's pretty simple to zip up a folder - you can call it like this:
DestnZip = tempDir:rti_CreateGuid():'.zip'
SrcFolder = tempdir:source_folder[-1,'B\']
zipStatus = ""
zipResult = utility_DotNet( "ZIP", DestnZip,srcFolder, "", "", zipStatus )
Of course, you'd then have to oswrite your big string to an os file and folder; I don't know if that's a "deal breaker" for you or not.
If you're using OI 10.1, then there's a .net method in the RevUtils assembly that can help you (we use it in RUN_OECGI_REQUEST to support sending out gzip'd data):
Declare Function rti_select_assembly, olecreateinstance, olecallmethod
whichAssembly = RTI_SELECT_ASSEMBLY()
assemblyVersion = field(whichAssembly, "_", 1)
AssemblyRelease = field(whichAssembly, "_", 2)
oUtils = oleCreateInstance(whichAssembly:".RevUtils")
compressMethod = "StringCompressB64"
* compress the contents of the "response" variable
encResponse = oleCallMethod(oUtils, compressMethod, response)
See if either of these work for you and give you the results you need?
- Bryan Shumsky
At 11 FEB 2022 01:45PM Bruce Cameron wrote:
Hi Bryan, thanks!
Currently 9.x
Utility_DotNet works in 9.x however it just created an empty zip folder.
I can't seem to find any documentation for Utility_DotNet, can you advise?
Thanks.
At 11 FEB 2022 02:08PM bshumsky wrote:
UTILITY_DOTNET provides comparable functionality to the existing UTILITY function, but uses Microsoft .NET assemblies to provide this functionality using the latest operating system routines. By using the .NET assemblies, instead of Windows functions, UTILIY_DOTNET is also available to be used in non-UI contexts, such as O4W routines.
UTILITY_DOTNET has the following interface:
Function UTILITY_DOTNET(TYPE, PARAM1, PARAM2, PARAM3, PARAM4, STATUS)
where "TYPE" is the command you wish to execute; "PARAM1", "PARAM2", "PARAM3", and "PARAM4" are the (possibly optional) parameters required by the command; and "STATUS" is the returned status from the command.
The available TYPEs for UTILITY_DOTNET include:
CHECKWIN
GETWINHNDL
KILLWIN
MAKEDIR
REMOVEDIR
RUNWIN
TIMEZONE
UNZIP
ZIP
By default, UTILITY_DOTNET will use .NET 2.0 assemblies to execute these requests; however, if .NET 4.0 assemblies are desired, you may suffix the command with "4" - for example, RUNWIN4, CHECKWIN4, etc.
CHECKWIN: Pass in the handle to the REVDOTNET object for the window you wish to check (PARAM1), as obtained by RUNWIN with PARAM4 = "1". Returns the literal "True" if the window has exited, or the literal "False" if the window is still running. Any error messages are returned in STATUS.
GETWINHNDL: Pass in the handle to the REVDOTNET object for the window you wish to check (PARAM1), as obtained by RUNWIN with PARAM4 = "1". Returns the window handle (which can then be used in other Windows calls). Any error messages are returned in STATUS.
KILLWIN: Pass in the handle to the REVDOTNET object for the window you wish to check (PARAM1), as obtained by RUNWIN with PARAM4 = "1", and a flag to indicate whether you wish to have the window closed (PARAM2 = 1) or killed without invoking the closing logic (PARAM2 = 0). Any error messages are returned in STATUS.
MAKEDIR: Pass in the full path to the directory you wish to create (PARAM1). Any error messages are returned in STATUS.
REMOVEDIR: Pass in the full path to the directory you wish to remove (PARAM1). Any error messages are returned in STATUS.
RUNWIN: Pass in the command to run (PARAM1), the command line arguments (PARAM2), a flag to indicate whether UTILITY_DOTNET should wait for the command to complete (PARAM3), and a flag to indicate whether UTILITY_DOTNET should return the handle to the REVDOTNET object created (PARAM4). Returns null or the handle to the REVDOTNET object (if PARAM4 is "1"). Any error messages are returned in STATUS.
TIMEZONE: Pass in the DATETIME that you wish to "localize" (PARAM1), and the type of action you wish to perform on the DATETIME (PARAM2). If PARAM1 is null, the current DATETIME is used. If PARAM2 is null or "0", then the return value will be the DATETIME passed in PARAM1 formatted as a valid timezone string (in the format "ddd, dd MMM yyyy HH:mm:ss zz"); if PARAM2 is "1", then the return value will be the UTC offset of the DATETIME passed in PARAM1; if PARAM2 is -1, then the return value will be the DATETIME passed in PARAM1 converted into Universal Time. Any error messages are returned in STATUS.
UNZIP: Pass in the full path and file name of the zip file you wish to extract from (PARAM1), and the full path to the directory that you wish the unzipped files to be placed into (PARAM2). Any error messages are returned in STATUS.
ZIP: Pass in the full path and file name of the zip file to create (PARAM1), and the full path to the directory that contains the files you wish to zip (PARAM2). Any error messages are returned in STATUS.
- Bryan Shumsky
At 11 FEB 2022 02:14PM bshumsky wrote:
Hi Bryan, thanks!
Currently 9.x
Utility_DotNet works in 9.x however it just created an empty zip folder.
I can't seem to find any documentation for Utility_DotNet, can you advise?
Thanks.
Are you passing in the name of the folder where you have the file(s) you wish to compress, or the path and file name? I think the utility_dotnet will only compress ALL the files in the specified source folder, not just a single file…
And now thinking about your requirements, I can't see that this will help you, because you need to have the compressed string - so writing it out to an os file, and then compressing the file contents, MIGHT have been acceptable (you could then osread the results), but compressing the entire folder (even if it only contains one file) probably won't be readable/transmissable.
Have you _considered_ moving to OI 10.1…? That would make this much easier to resolve…
Assuming that I meant that in jest (ha ha) - let me see if I can figure out if you can use RevDotNet and the ionic zip library (which is what we use inside utility_dotnet) to compress a single file, or even better a single file contents…
- Bryan Shumsky
At 11 FEB 2022 02:46PM Bruce Cameron wrote:
Great thanks!
And yes single file contents is what I am going for.
The WSDL requirements are saying it needs to come as such (in Basic+ form) …
<tns:submissionDataEncoding>ZIP</tns:submissionDataEncoding><tns:submissionData>Base64Encode(ZIP(SubmissionData))</tns:submissionData>
At 14 FEB 2022 08:11AM Revelation Software wrote:
Post removed by Revelation Software
At 05 MAR 2022 02:27PM Bruce Cameron wrote:
Hi Bryan (and all), just checking back in here to see if there was any more info to the RevDotNet idea?
I did find out they (HUD) are only accepting ZIP and GZIP formats so that has been limiting my progress.
Thanks.
At 05 MAR 2022 09:27PM Donald Bakke wrote:
Hi Bryan (and all), just checking back in here to see if there was any more info to the RevDotNet idea?
I did find out they (HUD) are only accepting ZIP and GZIP formats so that has been limiting my progress.
Thanks.
Bruce - Normally I wouldn't post an advert here, but if you are in a pinch, this could be an option.
At 06 MAR 2022 10:36AM bshumsky wrote:
Hi Bryan (and all), just checking back in here to see if there was any more info to the RevDotNet idea?
I did find out they (HUD) are only accepting ZIP and GZIP formats so that has been limiting my progress.
Thanks.
Hi, Bruce. Sorry I hadn't replied sooner. I did create a RevDotNet program that could compress and decompress a string, but unfortunately it can't be "back ported" to OI 9.x - there are changes in RevDotNet that mean it only works in OI 10.1+.
I don't know if Don's solution will work - it seems to again rely on files, whereas you seem to want to compress/decompress strings - but if it doesn't, another solution might be to have a custom .net OLE control written to do this. There's actually not a lot involved and could be done very quickly (if you have Visual Studio and are familiar with, or interested in learning, VB.NET, it could be an educational exercise)…?
- Bryan Shumsky
At 06 MAR 2022 11:46AM Bruce Cameron wrote:
Hi Don, Thank you, I will contact you/SRP this week regarding.
At 06 MAR 2022 12:07PM Bruce Cameron wrote:
Hi Bryan, I am going to contact Don – but am also interested in your custom .NET OLE idea. Maybe we could discuss offline?
Thanks.