Click here to Skip to main content
15,896,330 members
Home / Discussions / C#
   

C#

 
GeneralRe: Reports every Monday at 7am. Pin
Luc Pattyn25-May-09 7:37
sitebuilderLuc Pattyn25-May-09 7:37 
GeneralRe: Reports every Monday at 7am. Pin
Le centriste28-May-09 8:33
Le centriste28-May-09 8:33 
GeneralRe: Reports every Monday at 7am. Pin
Jacob Dixon25-May-09 15:20
Jacob Dixon25-May-09 15:20 
AnswerRe: Reports every Monday at 7am. Pin
Le centriste25-May-09 7:18
Le centriste25-May-09 7:18 
AnswerRe: Reports every Monday at 7am. Pin
_Maxxx_25-May-09 12:27
professional_Maxxx_25-May-09 12:27 
GeneralRe: Reports every Monday at 7am. Pin
Jacob Dixon25-May-09 15:26
Jacob Dixon25-May-09 15:26 
AnswerRe: Reports every Monday at 7am. Pin
Jacob Dixon25-May-09 15:36
Jacob Dixon25-May-09 15:36 
GeneralRe: Reports every Monday at 7am. Pin
_Maxxx_25-May-09 19:05
professional_Maxxx_25-May-09 19:05 
That would run your report at 00:02 (or there abouts) on monday and, if you don't persist the 'ran' status somehow, won't work if the program is stopped for any reason (if it is restarted on a Monday you would always get another copy of the report).

Maybe..


timer.Stop();
if (!ran && DateTime.Today.DayOfWeek == dayToRun && DateTime.Now.TimeOfDay >= timeToRun)
{
    PrepareReport();
    ran = true;
}

timer.Interval = MillisecondsBeforeTimeToRun();
            ran = false;
timer.Start();


Then you write MillisecondsBeforeTimeToRun() to calculate how long between now and the next time you want to test for the report being run.
Simplest case - if today is report day and the report has not been run, it's the difference between the time right now and the report time.
If the day is report day and the report has been run, it's 6 days from now plus the number of minutes until midnight from now, plus the report time.
If the day is not report day, you can safely leave it for (24 - now) + report time before checking again (or you can work it out accurately)

All this is obviously a bit pedantic - if you are just running one report once a week - I mean, the overheads of the polling every 2 mins are nothing - but it's nice to do these things 'properly'

___________________________________________
.\\axxx
(That's an 'M')

QuestionPop ContextMenu on NotifyIcon without mouse activity Pin
jackgeek25-May-09 5:58
jackgeek25-May-09 5:58 
QuestionRe: Pop ContextMenu on NotifyIcon without mouse activity Pin
jackgeek29-May-09 12:23
jackgeek29-May-09 12:23 
QuestionNeed help with TableAdapter problem [modified] Pin
kensai25-May-09 5:01
kensai25-May-09 5:01 
AnswerRe: Need help with TableAdapter problem Pin
Fahad Sadah25-May-09 7:28
Fahad Sadah25-May-09 7:28 
GeneralRe: Need help with TableAdapter problem Pin
kensai25-May-09 23:48
kensai25-May-09 23:48 
AnswerRe: Need help with TableAdapter problem Pin
kensai26-May-09 0:13
kensai26-May-09 0:13 
QuestionFile types Pin
viciouskinid25-May-09 4:13
viciouskinid25-May-09 4:13 
AnswerRe: File types Pin
harold aptroot25-May-09 4:44
harold aptroot25-May-09 4:44 
GeneralRe: File types Pin
viciouskinid25-May-09 5:17
viciouskinid25-May-09 5:17 
GeneralRe: File types Pin
harold aptroot25-May-09 5:31
harold aptroot25-May-09 5:31 
GeneralRe: File types Pin
viciouskinid25-May-09 7:07
viciouskinid25-May-09 7:07 
GeneralRe: File types Pin
harold aptroot25-May-09 7:28
harold aptroot25-May-09 7:28 
GeneralRe: File types Pin
viciouskinid25-May-09 8:19
viciouskinid25-May-09 8:19 
GeneralRe: File types Pin
harold aptroot25-May-09 8:35
harold aptroot25-May-09 8:35 
GeneralRe: File types Pin
viciouskinid25-May-09 10:19
viciouskinid25-May-09 10:19 
GeneralRe: File types Pin
harold aptroot25-May-09 10:42
harold aptroot25-May-09 10:42 
GeneralRe: File types Pin
viciouskinid25-May-09 19:05
viciouskinid25-May-09 19:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.