getting files with getfiles method - WeOnlyDo Discussion board

getting files with getfiles method (wodFtpDLX / wodFtpDLX.NET)

by sstyer, Monday, January 20, 2014, 15:44 (3746 days ago)

I'd like to use getfiles to grab any files on an ftp site
And... after pulling those files down
process them.
But, it seems like it's running the rest of my code
before actually grabbing all the files
I'd really like for it to wait, to get all the files
i'm calling this from a powerbuilder application.

maybe it would help me to understand, the order of how the events fire
is there some way, that I can tell when getfiles has finished
pulling all the files?

thanks

getting files with getfiles method

by wodDrazen, Monday, January 20, 2014, 15:54 (3746 days ago) @ sstyer

Hi,


Did you try to use Done Event? This event should be fired when GetFiles Method finished with execution.

Let us know how it goes.


Regards,
Drazen

--
_________________________________________________
WeOnlyDo! Software - Internet Security Components
----------=== http://www.weonlydo.com ===----------

getting files with getfiles method

by Scot, Tuesday, January 21, 2014, 19:33 (3745 days ago) @ wodDrazen

well the done event will fire each time a function is executed
like connect, getfiles, etc
in this section below (it's on the connected event)
i want to get everything, of a certain naming convention
and, then delete those specific files that I pulled
but... i'm using the loopitem to try and trap the filenames that were pulled
and, it doesn't seem to be saving them off
every time, my nbr_ftp_files is just 1
even though I'm incrementing it in the loopitem event


connected
----------

nbr_ftp_files = 1

in_dir = capp_directory + 'jpmc\import\'
out_dir = '/Outbound/Encrypted/'
ole_ftp.object.getfiles(in_dir, out_dir )

for i = 1 to nbr_ftp_files
ole_ftp.object.deletefile(file_array )
next


f_list = capp_directory + '\jpmc\import\DOCCTS.EFS.ACK2*'
lb_filelist.dirlist(f_list, 0)
if lb_filelist.totalitems() < 1 then
messagebox('JPMC Upload', 'There are No files to Upload')
else
st_files.text = string(lb_filelist.totalitems())
if messagebox('JPMC Files','Do you wish to Proceed with the Processing of the files', Question!, YesNo!) = 2 then
else
for i = 1 to lb_filelist.totalitems()
process_files(lb_filelist.text(i))
next
end if
end if

ole_ftp.object.disconnect(true)
pb_update.enabled = true
pb_ok.enabled = false


loopitem
-------
if (match(remotefile,'DOCCTS.EFS.ACK2') = true) then
file_array[nbr_ftp_files] = remotefile
nbr_ftp_files = nbr_ftp_files + 1
messagebox('error',string(nbr_ftp_files))
Skip = false
else
messagebox('error','skip')
skip = true
end if

getting files with getfiles method

by wodDrazen, Tuesday, January 21, 2014, 19:44 (3745 days ago) @ Scot

Hi Scot,


If I understand your code correctly you are saving only DOCCTS.EFS.ACK2 file. Other files are skipped from download.

What happens if you remove match line from your code snippet inside LoopFiles Event?

Does it work in that case maybe?


Drazen

--
_________________________________________________
WeOnlyDo! Software - Internet Security Components
----------=== http://www.weonlydo.com ===----------

getting files with getfiles method

by scot, Tuesday, January 21, 2014, 19:53 (3745 days ago) @ wodDrazen

what's odd is, the pulling of the files seems to work
but, it doesn't want to count / capture
the number of files, and their filenames into an array

pulling out the match.. and just incrementing the nbr_ftp_files
still came up with only 1
even though there is more than 1 file, that is pulled

does the code keep processing?
and the getfiles is done in conjunction with the rest of the script
i would like to do it sequentially
only delete the files, once the getfiles has done it's job

getting files with getfiles method

by scot, Tuesday, January 21, 2014, 20:22 (3745 days ago) @ scot

what's really odd
is I tried to swap the deletfile, to deletefiles
and, just delete all of them
I'm getting an pb error on the function
when it hits the deletefiles
any ideas?


string local_send, remote_send
string in_dir, out_dir
long tot_files, i

If ErrorCode <> 0 Then
messagebox('ERROR','UNABLE TO CONNECT TO FTP SITE, CONTACT SUPPORT - ERROR CODE = ' + string(errorcode))
close(parent)
return
end if

nbr_ftp_files = 1

in_dir = capp_directory + 'jpmc\import\'
out_dir = '/Outbound/Encrypted/'
ole_ftp.object.getfiles(in_dir, out_dir )

ole_ftp.object.deletefiles(out_dir )

getting files with getfiles method

by wodDrazen, Tuesday, January 21, 2014, 20:32 (3745 days ago) @ scot

Scot,


You are missing MaxLevel argument inside GetFiles and DeleteFiles Method.

More info you can find here:

http://www.weonlydo.com/FtpDLX/Help/wodFtpDLX-GetFiles.html
http://www.weonlydo.com/FtpDLX/Help/wodFtpDLX-DeleteFiles.html

here is example when maxlevel argument is set to 1:
----------------------------------------
ole_ftp.object.getfiles(in_dir, out_dir,1)

ole_ftp.object.deletefiles(out_dir,1)
----------------------------------------


Drazen

--
_________________________________________________
WeOnlyDo! Software - Internet Security Components
----------=== http://www.weonlydo.com ===----------

getting files with getfiles method

by scot, Tuesday, January 21, 2014, 20:43 (3745 days ago) @ wodDrazen

getfiles was working without the maxlevel
and, the docs say it's optional

i tried the maxlevel on the delete
and it still blows up


in_dir = capp_directory + 'jpmc\import\'
out_dir = '/Outbound/Encrypted/'
ole_ftp.object.getfiles(in_dir, out_dir, 1 )

ole_ftp.object.deletefiles(out_dir, 1 )

getting files with getfiles method

by wodDrazen, Tuesday, January 21, 2014, 20:51 (3745 days ago) @ scot

Scot,


What happens if you add this line inside LoopError Event:

ErrorCode = 0


Drazen

--
_________________________________________________
WeOnlyDo! Software - Internet Security Components
----------=== http://www.weonlydo.com ===----------

getting files with getfiles method

by scot, Tuesday, January 21, 2014, 20:56 (3745 days ago) @ wodDrazen

if I comment out the loopitem code
the delete works without error
but, I need something to ensure that I don't delete the wrong files

//if (match(remotefile,'DOCCTS.EFS.ACK2') = true) then
// Skip = false
//else
// skip = true
//end if
//

getting files with getfiles method

by wodDrazen, Tuesday, January 21, 2014, 21:06 (3745 days ago) @ scot

Scot,


Which error did you receive?


Drazen

--
_________________________________________________
WeOnlyDo! Software - Internet Security Components
----------=== http://www.weonlydo.com ===----------

getting files with getfiles method

by scot, Tuesday, January 21, 2014, 21:14 (3745 days ago) @ wodDrazen

it seems like getfiles, or deletefiles work fine by themselves
but, when I try to do both... is when I get a powerbuilder error message


error #35
error calling external object function deletefiles at line 18
in the connected event of object ole_ftp of w_import_jpmc_trans
line 18 in script
which is the deletefiles line


if I comment out the getfiles, the deletefiles works
doesn't make much sense.

in_dir = capp_directory + 'jpmc\import\'
out_dir = '/Outbound/Encrypted/'
ole_ftp.object.getfiles(in_dir, out_dir, 1 )


ole_ftp.object.deletefiles(out_dir, 1 )

getting files with getfiles method

by wodDrazen, Tuesday, January 21, 2014, 21:16 (3745 days ago) @ scot

Scot,


You need to wait for first command to finished with execution and then execute next command.

You can use Done Event and execute commands there because Done Event is fired when command finished with execution.


Drazen

--
_________________________________________________
WeOnlyDo! Software - Internet Security Components
----------=== http://www.weonlydo.com ===----------

getting files with getfiles method

by scot, Tuesday, January 21, 2014, 21:21 (3745 days ago) @ wodDrazen

ok... but, how do I tell which method is actually finishing?
the done event will fire when the connection is established
AND.. when the deletefiles finishes
I don't want to do the same code over and over

unless I use a variable to keep track of what stage I'm in

stage = 1
getfiles


in done
if stage = 1
stage = 2
deletefiles
end


move the delete from connected to done

seems excessive

getting files with getfiles method

by wodDrazen, Tuesday, January 21, 2014, 21:23 (3745 days ago) @ scot

Scot,


You need to track somehow execution of your commands. So you need to do something like that.


Drazen

--
_________________________________________________
WeOnlyDo! Software - Internet Security Components
----------=== http://www.weonlydo.com ===----------