Title: Create a directory on the local computer
Post by: Jose Edvandro M. on July 12, 2022, 04:01:25 am
Goodnight, I would like to know if there is a way to create a directory on the local computer and then copy a file to that directory created? Example directory: C:\test\SIN
Title: Re: Create a directory on the local computer
Post by: Stefan S. on July 12, 2022, 08:44:29 am
Good Morning, you can create a bat and copy this to the Client-PC (fgl_putfile) Then execute this File on the client. To execute the Client-File I create a further vbs script, to avoid the popup of the dos-command box Stefan #------------------------------------------------------------------------------ function wc_verzeichnis_anlegen(lo_wcdir) define lo_stm string, lo_clientfile string, lo_clientdir string, lo_clientbatchfile string, lo_serverfile string, lo_wcdir string, --name des webcomponent-verzeichnis lo_z smallint, lo_i smallint, lo_buf base.StringBuffer, lo_ch base.channel, lo_z2 smallint, lo_z3 smallint call ui.interface.frontcall("standard", "feinfo", ["datadirectory"],[lo_clientfile]) let lo_clientdir = lo_clientfile --batchdatei für mkdir let lo_serverfile = "/programme/lutztmp/anlegen_", gl_vlogin clipped, ".bat" let lo_ch = base.channel.create() call lo_ch.openfile(lo_serverfile, "w") call lo_ch.setdelimiter("") let lo_clientfile = lo_clientdir clipped, "\\anlegen.bat" let lo_stm = "mkdir ", "\"", lo_clientdir clipped, "\\", lo_wcdir clipped, "\"" call lo_ch.write(lo_stm) call lo_ch.write(ascii 13) call lo_ch.close() call datei_auf_client_maps(lo_serverfile, "X") returning lo_clientbatchfile --nur ablegen, nicht ausführen --dieses VB-Script wird ausgeführt. Das verhindert das Aufpoppen der DOS-Box let lo_serverfile = "/programme/lutztmp/ausfuehren_", gl_vlogin clipped, ".vbs" let lo_ch = base.channel.create() call lo_ch.openfile(lo_serverfile, "w") call lo_ch.setdelimiter("") call lo_ch.write("Set WshShell = WScript.CreateObject(\"WScript.Shell\")") let lo_clientbatchfile = "\"", "\"", lo_clientbatchfile clipped, "\"", "\"" --es müssen drei vorher und nachher sein ! let lo_stm = "WshShell.Run ", lo_clientbatchfile clipped, ",0,True" call lo_ch.write(lo_stm) call lo_ch.close() call datei_auf_client_maps(lo_serverfile, "A") returning lo_clientbatchfile end function #--------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------ function datei_auf_client_maps(lo_serverfile, lo_aktion) define lo_serverfile string, #pfad + Name der ServerDatei, lo_clientfile string, # lo_datei string, #Name des lo_serverfile, ohne Verzeichnis lo_datei2 string, #Name des lo_serverfile, ohne Verzeichnis + currentstempel lo_time string, lo_aktion char(1) ##A=ausführen (pdf wird angezeigt, vbs ausgeführt), K=nur auf client ##X=Datei ohne Zeitstempel ablegen, aber nicht ausführen! let lo_serverfile = lo_serverfile clipped if os.path.isfile(lo_serverfile) = false then error "......Datei nicht auf dem Server ...." return --keine Anzeige end if --call set_current() returning lo_time call ui.interface.frontcall("standard", "feinfo", ["datadirectory"],[lo_clientfile]) if lo_aktion = "X" then --kein Zeitstempel! let lo_datei = os.path.basename(lo_serverfile) let lo_datei2 = lo_datei let lo_clientfile = lo_clientfile clipped, "\\", lo_datei2 else let lo_datei = os.path.basename(lo_serverfile) let lo_datei2 = os.path.rootname(lo_datei) clipped, "_", lo_time clipped, ".", os.path.extension(lo_datei clipped) let lo_clientfile = lo_clientfile clipped, "\\", lo_datei2 end if try call fgl_putfile(lo_serverfile, lo_clientfile) end try let lo_clientfile = "\"", lo_clientfile clipped, "\"" if lo_aktion = "A" then --anzeigen, oder ausführen call ui.Interface.frontCall("standard", "shellexec", [lo_clientfile clipped], []) else --nix, wird nur auf client kopiert end if return lo_clientfile end function #------------------------------------------------------------------------------
Title: Re: Create a directory on the local computer
Post by: Gary C. on July 12, 2022, 09:02:49 am
Hello This is how we do this using GDC as the client and exploiting front calls: # Use a frontcall to get the base directory from the local environment variable # Then build a string holding the target directory using the relevant path separator and directory, in our case the ID of the MDI container # Then build and execute the relevant local command if g_clientOperatingSystem = "LINUX" then call ui.interface.frontCall("standard", "getenv", "HOME", g_tmpClientDir) let g_tmpClientDir = g_tmpClientDir.append(g_ClientPathSeparator||g_container) let sCmd = "mkdir "||g_tmpClientDir call ui.Interface.frontCall("standard", "execute", [sCmd, 1], []) else call ui.interface.frontCall("standard", "getenv", "LOCALAPPDATA", g_tmpClientDir) let g_tmpClientDir = g_tmpClientDir.append(g_ClientPathSeparator||g_container) let sCmd = "cmd.exe /C \"mkdir ", g_tmpClientDir, "\"" call ui.Interface.frontCall("standard", "execute", [sCmd, 1], []) end if
Then to clean up after the application finishes we use this: if g_clientOperatingSystem = "LINUX" then let sCmd = "rm -fr ", g_tmpClientDir call ui.Interface.frontCall("standard", "execute", [sCmd, 1], []) else let sCmd = "cmd.exe /C \"rmdir /S /Q ", g_tmpClientDir, "\"" call ui.Interface.frontCall("standard", "execute", [sCmd, 1], []) end if
To copy a file to the local directory we use fgl_putfile in a fashion like this: # We stop the standard error handling and build the path to the destination file # We then use fgl_putfile and check for any issue before resuming normal error handling whenever error continue let sFileDestination = g_tmpClientDir.trim(), g_ClientPathSeparator.trim(), p_documentR.documentname call fgl_putfile(sFileSource, sFileDestination) if status then call sys_showMessage("Error", "Unable to download file: "||sFileSource||"||CRLF||To: "||sFileDestination, "") whenever error call sys_errorHandler return end if whenever error call sys_errorHandler
Hope that helps. Gary
|