DayOfWeekMask

2 posts, 0 answers
  1. Robi
    Robi avatar
    7 posts
    Member since:
    Mar 2013

    Posted 21 Oct 2013 Link to this post

    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"..
  2. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 24 Oct 2013 Link to this post

    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 >>
  3. DevCraft banner
Back to Top