This is a migrated thread and some comments may be shown as answers.

RecurrenceDays.AddDay Question

3 Answers 76 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Stuart Cotts
Top achievements
Rank 1
Stuart Cotts asked on 09 Jul 2011, 07:32 PM
I am converting an outlook apppointment to a scheduleview appointment, in converting the recurrence I am trying to build a RecurrenceDays, I may be missing something but I have not been able to find any documentation on building a RecurrencePattern from scratch so I am winging it.

When I step through the code below everything is fine except RecurrenceDay.AddDay doesn't do anything, The result is that telerikdays is always None. What am I missing?


pat.Frequency = RecurrenceFrequency.Weekly;
pat.MaxOccurrences = week.NumberOfOccurrences;
Microsoft.Exchange.WebServices.Data.DayOfTheWeekCollection days = ((Microsoft.Exchange.WebServices.Data.Recurrence.WeeklyPattern)week).DaysOfTheWeek;
RecurrenceDays telerikdays = new RecurrenceDays();
 
foreach (DayOfWeek d in days)
{
    switch (d)
    {
        case DayOfWeek.Friday: telerikdays.AddDay(RecurrenceDays.Friday); break;
        case DayOfWeek.Saturday: telerikdays.AddDay(RecurrenceDays.Saturday); break;
        case DayOfWeek.Sunday: telerikdays.AddDay(RecurrenceDays.Sunday); break;
        case DayOfWeek.Monday: telerikdays.AddDay(RecurrenceDays.Monday); break;
        case DayOfWeek.Tuesday: telerikdays.AddDay(RecurrenceDays.Tuesday); break;
        case DayOfWeek.Wednesday: telerikdays.AddDay(RecurrenceDays.Wednesday); break;
        case DayOfWeek.Thursday: telerikdays.AddDay(RecurrenceDays.Thursday); break;
    }
}
 
pat.DaysOfWeekMask = telerikdays;

3 Answers, 1 is accepted

Sort by
0
Pana
Telerik team
answered on 15 Jul 2011, 07:54 AM
Hello,

The RecurrenceDays is an enum structure. It would be easier to instantinate and sum the recurrence days like this:

 

 

RecurrenceDays telerikdays = RecurrenceDays.None;
telerikdays |=
RecurrenceDays.Sunday;
telerikdays |=
RecurrenceDays.Monday;
telerikdays |=
RecurrenceDays.Wednesday;

Greetings,

Pana
the Telerik team

 

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Stuart Cotts
Top achievements
Rank 1
answered on 15 Jul 2011, 05:04 PM
That is what I ended doing, but I am still curious, what is the call AddDay for?
0
Pana
Telerik team
answered on 22 Jul 2011, 06:40 AM
Hello Stuart,

It is an extension on the enum. It's body is:

public static RecurrenceDays AddDay(this RecurrenceDays recurrenceDays, RecurrenceDays dayToAdd)
{
  return recurrenceDays | dayToAdd;
}

So instead of:
telerikdays.AddDay(RecurrenceDays.Friday);
you should actually use:
telerikdays = telerikdays.AddDay(RecurrenceDays.Friday);

Best wishes,
Pana
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
ScheduleView
Asked by
Stuart Cotts
Top achievements
Rank 1
Answers by
Pana
Telerik team
Stuart Cotts
Top achievements
Rank 1
Share this question
or