bbaldwin
asked on
Windows service with 24 hour trigger
I am creating a service that will create a PDF with a date included in the name of the file. The PDF is created from other PDFs that accumulate within a group of folders. Every morning at a user defined time (probably 7AM) all the files that have been accumlated will be cleared out and new files will start to accumlate and a new PDF will be created with a new date included file name. I will have a timer that creates the new PDF every few minutes.
My question is how do I trigger the clearing out the PDFs in the accumlation folders at the user defined time? I can imagine a couple of methods that might work but hoped that someone might suggest a proven method.
My question is how do I trigger the clearing out the PDFs in the accumlation folders at the user defined time? I can imagine a couple of methods that might work but hoped that someone might suggest a proven method.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'd recommend that you just create a console application and use the built-in Scheduled Tasks to determine when the program runs.
you could start a seperate time in the service and add your test there to the next date of the run.
as a service you will have to store the users start time in a configuration file if you have not figured this at already.
make your interval in minutes (1440) minutes is 1 day. this way if it needs to change in the future to occurr twice a day or evey hour your code is easily changed. and if you pass the parameter in with start time you don't even have to change the code.
finally why delete yesterdays data immediatly. Not sure what the data is but my users generally ask to see the old data at some point for comparison. could you not create a new directory each time the directory name as a date and time then write to that. You would then delete directories that are say 7 days old.
You might not need all this functionality but sometimes it helps to protect yourself in the initial design
greg
as a service you will have to store the users start time in a configuration file if you have not figured this at already.
make your interval in minutes (1440) minutes is 1 day. this way if it needs to change in the future to occurr twice a day or evey hour your code is easily changed. and if you pass the parameter in with start time you don't even have to change the code.
finally why delete yesterdays data immediatly. Not sure what the data is but my users generally ask to see the old data at some point for comparison. could you not create a new directory each time the directory name as a date and time then write to that. You would then delete directories that are say 7 days old.
You might not need all this functionality but sometimes it helps to protect yourself in the initial design
greg
ASKER
Graye,
the service is really doing much more than I indicated (checking for files in emails and folders, converting files to PDFs from other sources, etc.) This needs to be done quite often so a scheduled task will not work for us. Thanks for the suggestion.
AutoeForm,
already added the item to the configuration file, thanks. The files that we are going to delete are actually copies of files from other folders and this is just the staging folders for the PDFs for this day and therefore can be deleted whenever. Thanks for the great suggestions though.
the service is really doing much more than I indicated (checking for files in emails and folders, converting files to PDFs from other sources, etc.) This needs to be done quite often so a scheduled task will not work for us. Thanks for the suggestion.
AutoeForm,
already added the item to the configuration file, thanks. The files that we are going to delete are actually copies of files from other folders and this is just the staging folders for the PDFs for this day and therefore can be deleted whenever. Thanks for the great suggestions though.
ASKER