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

DayOfWeekMask

1 Answer 58 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Robi
Top achievements
Rank 2
Robi asked on 21 Oct 2013, 01:38 PM
Hi,

I've created an custom recurrencedialog. When I want to add day to the DaysOfWeekMask it takes always "none". When I create a new recurrence order I can save it in the Database as string.

private void LoadOrders()
        {
            OrderAppointments = new ObservableCollection<OrderAppointment>();
 
            Context.Load(Context.GetOrdersQuery(),
                         lo =>
                             {
                                 if (lo.HasError)
                                 {
                                     throw lo.Error;
                                 }
 
                                 Orders = new ObservableCollection<Order>(lo.Entities);
                                 foreach (Order order in Orders)
                                 {
                                     var newOrderAppointment = new OrderAppointment(order, Context);
 
                                     var pattern = new RecurrencePattern();
                                     pattern.Frequency = RecurrenceFrequency.Daily;
                                     var recurrenceRule = new RecurrenceRule(pattern);
 
                                     ////Test
                                     //pattern.DaysOfWeekMask = RecurrenceDays.Monday;
                                     //var days = new RecurrenceDays();
                                     //try
                                     //{
                                     //    days.AddDay(RecurrenceDays.Monday);
                                     //}
                                     //catch (Exception)
                                     //{
                                     //    throw;
                                     //}
                                      
                                     newOrderAppointment.RecurrenceRule = recurrenceRule;
 
                                     if (order.Start_Date != null)
                                     {
                                         newOrderAppointment.Start = (DateTime) order.Start_Date;
                                     }
                                     if (order.End_Date != null)
                                     {
                                         newOrderAppointment.End = (DateTime) order.End_Date;
                                     }
                                     if (order.DayOfMonth != null)
                                     {
                                         newOrderAppointment.RecurrenceRule.Pattern.DayOfMonth = order.DayOfMonth;
                                     }
                                     if (order.DayOrdinal != null)
                                     {
                                         newOrderAppointment.RecurrenceRule.Pattern.DayOrdinal = order.DayOrdinal;
                                     }
                                     if (order.DaysOfWeekMask != null)
                                     {
                                         if (order.DaysOfWeekMask.Contains("Monday"))
                                         {
                                             newOrderAppointment.RecurrenceRule.Pattern.DaysOfWeekMask.AddDay(
                                                 RecurrenceDays.Monday);
                                         }
                                         if (order.DaysOfWeekMask.Contains("Tuesday"))
                                         {
                                             newOrderAppointment.RecurrenceRule.Pattern.DaysOfWeekMask.AddDay(
                                                 RecurrenceDays.Tuesday);
                                         }
                                         if (order.DaysOfWeekMask.Contains("Wednesday"))
                                         {
                                             newOrderAppointment.RecurrenceRule.Pattern.DaysOfWeekMask.AddDay(
                                                 RecurrenceDays.Wednesday);
                                         }
                                         if (order.DaysOfWeekMask.Contains("Thursday"))
                                         {
                                             newOrderAppointment.RecurrenceRule.Pattern.DaysOfWeekMask.AddDay(
                                                 RecurrenceDays.Thursday);
                                         }
                                         if (order.DaysOfWeekMask.Contains("Friday"))
                                         {
                                             newOrderAppointment.RecurrenceRule.Pattern.DaysOfWeekMask.AddDay(
                                                 RecurrenceDays.Friday);
                                         }
                                     }

how can I add the days to the DaysOfWeeksMask?? The result of DaysOfWeekMask with the code above = "none"..

1 Answer, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 24 Oct 2013, 12:14 PM
Hi Robi,

In order to achieve the desired scenario, you would need to keep reference to the RecurrenceDays and then you can use the AddDay method on it. Please note you would need to set the RecurrenceDays to the DaysOfWeekMask every time after adding a day.  Check the following code snippet for more details:

RecurrenceDays days = new RecurrenceDays();
days = days.AddDay(RecurrenceDays.Friday);        
 
pattern.DaysOfWeekMask = days;
appointment.RecurrenceRule = new RecurrenceRule(pattern);
 
...
 
days = days.AddDay(RecurrenceDays.Monday);
pattern.DaysOfWeekMask = days;

Hope this helps.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ScheduleView
Asked by
Robi
Top achievements
Rank 2
Answers by
Kalin
Telerik team
Share this question
or