Changeset 2315


Ignore:
Timestamp:
10/20/2011 5:01:07 AM (3 years ago)
Author:
lowjoel
Message:

Backport from revision 2314 from trunk/eraser:
Fixed monthly schedules, as described in http://bbs.heidi.ie/viewtopic.php?p=24697#p24697. The old code does seem rather strange.

Location:
branches/eraser6/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/6.0

  • branches/eraser6/6.0/Eraser.Manager/Schedule.cs

    r1677 r2315  
    431431                    } 
    432432                    case RecurringScheduleUnit.Monthly: 
    433                         //Step the number of months since the last run 
    434                         if (LastRun != DateTime.MinValue) 
    435                             nextRun = nextRun.AddMonths(frequency); 
    436  
    437                         //Ensure that the next run day is before the scheduled day of month 
    438                         while (monthlySchedule < nextRun.Day) 
    439                             nextRun = nextRun.AddDays(1); 
    440                          
    441                         //Set the next run date to be the day on which the task will run. 
    442                         nextRun = nextRun.AddDays(-((int)monthlySchedule - nextRun.Day)); 
    443                         while (nextRun < DateTime.Now) 
    444                             nextRun = nextRun.AddMonths(frequency); 
     433                        if (LastRun == DateTime.MinValue) 
     434                        { 
     435                            //Since the schedule has never been used, find the next time 
     436                            //to run the task. If the current day is less than the 
     437                            //scheduled day, leave it alone. Otherwise, go to the 
     438                            //following month. 
     439                            while (monthlySchedule < nextRun.Day) 
     440                                nextRun = nextRun.AddDays(1); 
     441                        } 
     442                        else 
     443                        { 
     444                            //Step the number of months since the last run 
     445                            while (nextRun < DateTime.Now) 
     446                                nextRun = nextRun.AddMonths(frequency); 
     447                        } 
     448 
     449                        //Set the day of the month which the task is supposed to run. 
     450                        nextRun = nextRun.AddDays(monthlySchedule - nextRun.Day); 
    445451                        break; 
    446452                } 
Note: See TracChangeset for help on using the changeset viewer.