FileMonitor

Discuss RoboTask here
Post Reply
Adrien
Posts: 5
Joined: Thu Dec 01, 2016 12:25 pm

FileMonitor

Post by Adrien »

Hi,
(sorry for my bad english - Google Translation)
I currently test your software in order to buy it.
I have for the moment a major problem with filemonitor. (We process many files per day)
When a first file is scanned, the task is started.
This task runs for a while.
In the meantime, another file arrives.
In the log it says: W: 01/12/2016 12:29:04: Task "test reception file" is already running
Then the task ends.
The second file is then ignored because it has been scanned during the current task and will never be processed.
Another problem is that a file being copied will be scanned while the transfer is not complete. As a result, the treatment behind it fails.
Is it possible to disable the trigger while the task is running ? Or is it possible to scan files infinitely ?
Regards,
Adrien
RT 6.7.2.911
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: FileMonitor

Post by Oleg »

Task "test reception file" is already running
RoboTask can run the task only once at a time. It ignores the attempt to start the task if it is already running.

Look at my example below.
This task monitors the folder c:\incoming and runs the task if file (or files) arrives
The task processes all files and moves them into another folder.
So this algorithm allows to avoid your problem. The folder c:\incoming will be empty in idle mode.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task109"
Hide=INTEGER|0
ID=INTEGER|1210225817
LogOnAsUser=INTEGER|1
Name=STRING|"Filemonitor demo"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER

[Actions\Action1]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action1\Params]
createmode=STRING|"1"
date1=STRING|"20161201"
date2=STRING|"20161201"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"c:\incoming\*.*"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//wait until the file will be free"
Params=FOLDER

[Actions\Action2\Params]
comment=STRING|"wait until the file will be free"

[Actions\Action3]
ActionID=STRING|"A_FILE_WAIT"
Enabled=INTEGER|-1
Name=STRING|"Waiting {filename} file for 60 sec"
Params=FOLDER

[Actions\Action3\Params]
filename=STRING|"{filename}"
timeout=STRING|"60"

[Actions\Action4]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//do something with the file - place your actions here"
Params=FOLDER

[Actions\Action4\Params]
comment=STRING|"do something with the file - place your actions here"

[Actions\Action5]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//and MOVE the file into another folder"
Params=FOLDER

[Actions\Action5\Params]
comment=STRING|"and MOVE the file into another folder"

[Actions\Action6]
ActionID=STRING|"A_FILE_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy/Move File"
Params=FOLDER

[Actions\Action6\Params]
destdir=STRING|"c:\PrecessedFiles"
f_count=STRING|"1"
file0=STRING|"{filename}"
hidden=STRING|"1"
ifexists=STRING|"1"
move=STRING|"1"
rename=STRING|"0"
renamemask=STRING|"*.*.new"
subdir=STRING|"0"
system=STRING|"1"

[Actions\Action7]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_FILE_MONITOR"
Params=FOLDER
UniqueID=INTEGER|2146489094

[Events\Event1\Params]
chg=STRING|"0"
chga=STRING|"1"
chgsl=STRING|"1"
chgsm=STRING|"1"
chgtl=STRING|"1"
chgtm=STRING|"1"
del=STRING|"0"
folder1=STRING|"c:\incoming"
foldercount=STRING|"1"
incmask=STRING|"*.*"
interval=STRING|"60"
listmode=STRING|"1"
mon_files=STRING|"1"
mon_folders=STRING|"0"
new=STRING|"1"
pass=STRING|"0"
passmode=STRING|"1"
saveresults=STRING|"0"
subfolders1=STRING|"0"
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Do not forget to enable the task after importing.
Oleg Yershov
Adrien
Posts: 5
Joined: Thu Dec 01, 2016 12:25 pm

Re: FileMonitor

Post by Adrien »

Thank you for answering me.
I tried your task. Same problem.
If a file arrives after the beginning of the loop. It will not be used.
W: 01/12/2016 16:24:27: Task "Filemonitor demo (imported)" is already running
The files are permanently unloaded with us. It looks like the trigger stores the scan of a file in order not to scan it again.
I tried many possibilities and I always put it at fault.
The best I have succeeded is to block the task at startup and restore it at the end by another task but there are still files not recovered in rare cases :

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|587442669
Comment=STRINGLIST
ContinueOnError=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task109"
Hide=INTEGER|0
ID=INTEGER|1210225817
LogOnAsUser=INTEGER|1
Name=STRING|"Filemonitor demo (imported)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_TASKS_DISABLE"
Enabled=INTEGER|-1
Name=STRING|"Disable Task ""Filemonitor demo (imported)"""
Params=FOLDER

[Actions\Action1\Params]
taskid=STRING|"1210225817"

[Actions\Action10]
ActionID=STRING|"A_TASKS_START"
Enabled=INTEGER|-1
Name=STRING|"Start Task ""Enable_Reception"""
Params=FOLDER

[Actions\Action10\Params]
parametercount=STRING|"0"
required=STRING|"0"
taskid=STRING|"1343301932"
wait=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action2\Params]
createmode=STRING|"1"
date1=STRING|"20161201"
date2=STRING|"20161201"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"c:\incoming\*.*"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//wait until the file will be free"
Params=FOLDER

[Actions\Action3\Params]
comment=STRING|"wait until the file will be free"

[Actions\Action4]
ActionID=STRING|"A_FILE_WAIT"
Enabled=INTEGER|-1
Name=STRING|"Waiting {filename} file for 60 sec"
Params=FOLDER

[Actions\Action4\Params]
filename=STRING|"{filename}"
timeout=STRING|"60"

[Actions\Action5]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//do something with the file - place your actions here"
Params=FOLDER

[Actions\Action5\Params]
comment=STRING|"do something with the file - place your actions here"

[Actions\Action6]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//and MOVE the file into another folder"
Params=FOLDER

[Actions\Action6\Params]
comment=STRING|"and MOVE the file into another folder"

[Actions\Action7]
ActionID=STRING|"A_FILE_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy/Move File"
Params=FOLDER

[Actions\Action7\Params]
destdir=STRING|"c:\PrecessedFiles"
f_count=STRING|"1"
file0=STRING|"{filename}"
hidden=STRING|"1"
ifexists=STRING|"1"
move=STRING|"1"
rename=STRING|"0"
renamemask=STRING|"*.*.new"
subdir=STRING|"0"
system=STRING|"1"

[Actions\Action8]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""[{Time}, {DayOfWeek}, {Date}]"""
Params=FOLDER

[Actions\Action8\Params]
icon=STRING|"1"
msg0=STRING|"[{Time}, {DayOfWeek}, {Date}]"
msg1=STRING|"Hey, awake!"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action9]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_FILE_MONITOR"
Params=FOLDER
UniqueID=INTEGER|1895217078

[Events\Event1\Params]
chg=STRING|"0"
chga=STRING|"1"
chgsl=STRING|"1"
chgsm=STRING|"1"
chgtl=STRING|"1"
chgtm=STRING|"1"
del=STRING|"0"
folder1=STRING|"c:\incoming"
foldercount=STRING|"1"
incmask=STRING|"*.*"
interval=STRING|"4"
listmode=STRING|"1"
mon_files=STRING|"1"
mon_folders=STRING|"0"
new=STRING|"1"
pass=STRING|"0"
passmode=STRING|"1"
saveresults=STRING|"0"
subfolders1=STRING|"0"

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|587442669
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task12"
Hide=INTEGER|0
ID=INTEGER|1343301932
LogOnAsUser=INTEGER|1
Name=STRING|"Enable_Reception"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER

[Actions\Action1]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay 11 sec"
Params=FOLDER

[Actions\Action1\Params]
delay=STRING|"11"
dimension=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_TASKS_ENABLE"
Enabled=INTEGER|-1
Name=STRING|"Enable Task ""test reception fichier"""
Params=FOLDER

[Actions\Action2\Params]
taskid=STRING|"265184114"

Adrien
Posts: 5
Joined: Thu Dec 01, 2016 12:25 pm

Re: FileMonitor

Post by Adrien »

I just understood your solution. Files will be processed later on the next pass.
It is better than nothing, in some cases there may be a delay in treatment.
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: FileMonitor

Post by Oleg »

f a file arrives after the beginning of the loop. It will not be used.
This file will be processed at next run of the task.
Yes, the task will miss this file at this loop, but it will process it later.
I just understood your solution. Files will be processed later on the next pass.

Yes, of course.
Oleg Yershov
Adrien
Posts: 5
Joined: Thu Dec 01, 2016 12:25 pm

Re: FileMonitor

Post by Adrien »

Thank you for taking the time to respond.
So if I can make a suggestion, it would be nice if the trigger is disabled when the task is running because anyway it can not be launched twice at the same time.
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: FileMonitor

Post by Oleg »

Thank you for your suggestion.
In any case we'll try to improve this trigger.
I wrote this into our ToDo
Oleg Yershov
Adrien
Posts: 5
Joined: Thu Dec 01, 2016 12:25 pm

Re: FileMonitor

Post by Adrien »

Great ! Thank you
userXXX
Posts: 58
Joined: Wed Jun 11, 2014 8:45 am

Re: FileMonitor

Post by userXXX »

You could try to use a file counting loop around the other loop, like this:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|740980707
Comment=STRINGLIST
ContinueOnError=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task109"
Hide=INTEGER|0
ID=INTEGER|1210225817
LogOnAsUser=INTEGER|1
Name=STRING|"Filemonitor demo (imported) (imported)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_TASKS_DISABLE"
Enabled=INTEGER|-1
Name=STRING|"Disable Task ""Filemonitor demo (imported)"""
Params=FOLDER

[Actions\Action1\Params]
taskid=STRING|"1210225817"

[Actions\Action10]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action11]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action12]
ActionID=STRING|"A_TASKS_START"
Enabled=INTEGER|-1
Name=STRING|"Start Task ""Enable_Reception"""
Params=FOLDER

[Actions\Action12\Params]
parametercount=STRING|"0"
required=STRING|"0"
taskid=STRING|"1343301932"
wait=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_LOOP_WHILE"
Enabled=INTEGER|-1
Name=STRING|"While loop"
Params=FOLDER

[Actions\Action2\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"3"
type=STRING|"1"
value1=STRING|"{FilesCount(c:\incoming)}"
value2=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action3\Params]
createmode=STRING|"1"
date1=STRING|"20161201"
date2=STRING|"20161201"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"c:\incoming\*.*"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//wait until the file will be free"
Params=FOLDER

[Actions\Action4\Params]
comment=STRING|"wait until the file will be free"

[Actions\Action5]
ActionID=STRING|"A_FILE_WAIT"
Enabled=INTEGER|-1
Name=STRING|"Waiting {filename} file for 60 sec"
Params=FOLDER

[Actions\Action5\Params]
filename=STRING|"{filename}"
timeout=STRING|"60"

[Actions\Action6]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//do something with the file - place your actions here"
Params=FOLDER

[Actions\Action6\Params]
comment=STRING|"do something with the file - place your actions here"

[Actions\Action7]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//and MOVE the file into another folder"
Params=FOLDER

[Actions\Action7\Params]
comment=STRING|"and MOVE the file into another folder"

[Actions\Action8]
ActionID=STRING|"A_FILE_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy/Move File"
Params=FOLDER

[Actions\Action8\Params]
destdir=STRING|"c:\PrecessedFiles"
f_count=STRING|"1"
file0=STRING|"{filename}"
hidden=STRING|"1"
ifexists=STRING|"1"
move=STRING|"1"
rename=STRING|"0"
renamemask=STRING|"*.*.new"
subdir=STRING|"0"
system=STRING|"1"

[Actions\Action9]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""[{Time}, {DayOfWeek}, {Date}]"""
Params=FOLDER

[Actions\Action9\Params]
icon=STRING|"1"
msg0=STRING|"[{Time}, {DayOfWeek}, {Date}]"
msg1=STRING|"Hey, awake!"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_FILE_MONITOR"
Params=FOLDER
UniqueID=INTEGER|993196262

[Events\Event1\Params]
chg=STRING|"0"
chga=STRING|"1"
chgsl=STRING|"1"
chgsm=STRING|"1"
chgtl=STRING|"1"
chgtm=STRING|"1"
del=STRING|"0"
folder1=STRING|"c:\incoming"
foldercount=STRING|"1"
incmask=STRING|"*.*"
interval=STRING|"4"
listmode=STRING|"1"
mon_files=STRING|"1"
mon_folders=STRING|"0"
new=STRING|"1"
pass=STRING|"0"
passmode=STRING|"1"
saveresults=STRING|"0"
subfolders1=STRING|"0"

Post Reply