G
Guest
Hi! I keep running into really odd behaviour with this object and I've been
working with it for over 2 moths now. I really need someone's help who has
delt with it before. I'll list below the logic of what my application does.
It would be even better if someone would be willing to review my code which
for reasons of being pretty extensive will not be included here. In short,
the FSW is not working consistently in our production environment while
watching only a handfull of files. Any help is greatly appreciated, thanks
in advance!
1) Service runs every 30 minutes
2) checks database for any records for files to watch
3) locates those records, creates 1 FSW object for each record with
File Name and Path pointing to the info in database, wires up OnChanged,
OnRenamed, OnCreated, and OnDeleted events to their handlers
4) Adds the instance of the FSW object to global shared Hashtable
5) Updates SQL status for this file to 2, meaning that FSW created, waiting
for the file to be generated/updated.
6) OnChanged event contains the code that reacts on 2 types of events
OnChanged and OnCreated. When it fires, it checks that the instance of FSW
that raised the event is contained in global hashtable. If so, it connects to
database and gets the XML options for this specific file (such as FTP file,
email it, back it up, etc...)
7) In OnChanged event there's loop inside of which it keeps trying to rename
the file that has raised the event to a new name (just appends one to the
end of the file name). This is done so that if the file is very large it
would not
try to work with it (FTP or something else) until it's fully written.
Once it's able to rename it, it means the system no longer has a lock on the
file. It then renames the file to its original name and kicks off the
function that process the XML actions associated with this file.
8) Upon completion of all the actions or in case of failure the SQL status
for this file is updated (1 for success, 3 for failure.
9) The reference for this FSW object is removed from global hashtable.
10) Same thing is done for any other files that have been picked up by the
service
when it ran initially with same logic.
11) Service runs once again in 30 minutes.
working with it for over 2 moths now. I really need someone's help who has
delt with it before. I'll list below the logic of what my application does.
It would be even better if someone would be willing to review my code which
for reasons of being pretty extensive will not be included here. In short,
the FSW is not working consistently in our production environment while
watching only a handfull of files. Any help is greatly appreciated, thanks
in advance!
1) Service runs every 30 minutes
2) checks database for any records for files to watch
3) locates those records, creates 1 FSW object for each record with
File Name and Path pointing to the info in database, wires up OnChanged,
OnRenamed, OnCreated, and OnDeleted events to their handlers
4) Adds the instance of the FSW object to global shared Hashtable
5) Updates SQL status for this file to 2, meaning that FSW created, waiting
for the file to be generated/updated.
6) OnChanged event contains the code that reacts on 2 types of events
OnChanged and OnCreated. When it fires, it checks that the instance of FSW
that raised the event is contained in global hashtable. If so, it connects to
database and gets the XML options for this specific file (such as FTP file,
email it, back it up, etc...)
7) In OnChanged event there's loop inside of which it keeps trying to rename
the file that has raised the event to a new name (just appends one to the
end of the file name). This is done so that if the file is very large it
would not
try to work with it (FTP or something else) until it's fully written.
Once it's able to rename it, it means the system no longer has a lock on the
file. It then renames the file to its original name and kicks off the
function that process the XML actions associated with this file.
8) Upon completion of all the actions or in case of failure the SQL status
for this file is updated (1 for success, 3 for failure.
9) The reference for this FSW object is removed from global hashtable.
10) Same thing is done for any other files that have been picked up by the
service
when it ran initially with same logic.
11) Service runs once again in 30 minutes.