Esempio n. 1
0
        protected override IEnumerable<Occurrence> GetNextOccurrences(Occurrence lastOccurrence, TimeSpan startTime, TimeSpan endTime)
        {
            DateTime startDate;
            if (lastOccurrence != null)
            {
                startDate = lastOccurrence.Start.Date.Add(startTime).AddDays(Interval);
            }
            else
            {
                startDate = StartDate.Date.Add(startTime);
                if (StartDate > startDate)
                {
                    startDate = StartDate;
                }
            }
            if (IsWeekday)
            {
                while (startDate.DayOfWeek == System.DayOfWeek.Saturday || startDate.DayOfWeek == System.DayOfWeek.Sunday)
                {
                    startDate = startDate.AddDays(1);
                }
            }

            DateTime endDate = startDate.Date.Add(endTime);
            if (startDate <= endDate)
            {
                if (EndDate.HasValue && endDate >= EndDate.Value)
                {
                    yield return new Occurrence(startDate, EndDate.Value);
                }
                else
                {
                    yield return new Occurrence(startDate, endDate);
                }
            }
        }
Esempio n. 2
0
 protected override IEnumerable<Occurrence> GetNextOccurrences(Occurrence lastOccurrence, TimeSpan startTime, TimeSpan endTime)
 {
     DateTime startDate;
     if (lastOccurrence != null)
     {
         startDate = lastOccurrence.Start.Date.Add(startTime).AddDays(1 - lastOccurrence.Start.Day).AddYears(Interval);
     }
     else
     {
         startDate = StartDate.Date.Add(startTime);
         startDate = StartDate > startDate
             ? StartDate.AddDays(1 - startDate.Day)
             : startDate.AddDays(1 - startDate.Day);
         if (startDate.Month > (int)Month || (startDate.Month == (int)Month && startDate.Day > DayOfMonth))
         {
             startDate = startDate.AddDays(1 - startDate.Day).AddMonths((int)Month - startDate.Month).AddYears(1);
         }
     }
     int daysInMonth = DateTime.DaysInMonth(startDate.Year, startDate.Month);
     startDate = startDate.AddDays(((daysInMonth < DayOfMonth) ? daysInMonth : DayOfMonth) - 1);
     DateTime endDate = startDate.Date.Add(endTime);
     if (startDate <= endDate)
     {
         if (EndDate.HasValue && endDate >= EndDate.Value)
         {
             yield return new Occurrence(startDate, EndDate.Value);
         }
         else
         {
             yield return new Occurrence(startDate, endDate);
         }
     }
 }
Esempio n. 3
0
 protected override IEnumerable<Occurrence> GetNextOccurrences(Occurrence lastOccurrence, TimeSpan startTime, TimeSpan endTime)
 {
     DateTime startDate;
     if (lastOccurrence != null)
     {
         startDate = lastOccurrence.Start.Date.Add(startTime).AddDays(7 * Interval);
     }
     else
     {
         startDate = StartDate.Date.Add(startTime);
         if (StartDate > startDate)
         {
             startDate = StartDate;
         }
     }
     while (startDate.DayOfWeek != FirstDayOfWeek)
     {
         startDate = startDate.AddDays(-1);
     }
     do
     {
         DateTime endDate = startDate.Date.Add(endTime);
         if (startDate <= endDate)
         {
             if (SPRecurrenceHelper.IsDayOfWeekMatched(DaysOfWeek, startDate))
             {
                 if (EndDate.HasValue && endDate >= EndDate.Value)
                 {
                     yield return new Occurrence(startDate, EndDate.Value);
                 }
                 else
                 {
                     yield return new Occurrence(startDate, endDate);
                 }
             }
         }
         startDate = startDate.AddDays(1);
     } while (startDate.DayOfWeek != FirstDayOfWeek);
 }
Esempio n. 4
0
 protected override IEnumerable<Occurrence> GetNextOccurrences(Occurrence lastOccurrence, TimeSpan startTime, TimeSpan endTime)
 {
     DateTime startDate;
     if (lastOccurrence != null)
     {
         startDate = lastOccurrence.Start.Date.Add(startTime).AddDays(1 - lastOccurrence.Start.Day).AddYears(Interval);
     }
     else
     {
         startDate = StartDate.Date.Add(startTime);
         startDate = StartDate > startDate
             ? StartDate.AddDays(1 - startDate.Day)
             : startDate.AddDays(1 - startDate.Day);
         if (startDate.Month > (int)Month)
         {
             startDate = startDate.AddDays(1 - startDate.Day).AddMonths((int)Month - startDate.Month).AddYears(1);
         }
     }
     var days = SPRecurrenceHelper.GetMatchedDays(startDate, DayOfWeekOrdinal, DayOfWeek).ToArray();
     foreach (int day in days)
     {
         startDate = startDate.AddDays(day - startDate.Day);
         DateTime endDate = startDate.Date.Add(endTime);
         if (startDate <= endDate)
         {
             if (EndDate.HasValue && endDate >= EndDate.Value)
             {
                 yield return new Occurrence(startDate, EndDate.Value);
             }
             else
             {
                 yield return new Occurrence(startDate, endDate);
             }
         }
     }
 }
Esempio n. 5
0
 protected abstract IEnumerable<Occurrence> GetNextOccurrences(Occurrence lastOccurrence, TimeSpan startTime, TimeSpan endTime);