How to retrieve the recurrence pattern of an appointment

4 posts, 0 answers
  1. Divya
    Divya avatar
    11 posts
    Member since:
    Mar 2014

    Posted 06 Mar Link to this post

    Hi,

    I need to retrieve the recurrence pattern and set it to our custom object. I tried various methods. In all these cases, I am not able to retrieve DaysOfWeekMask which holds values like "Sunday" or "Monday|Tuesday|Wednesday" and cast it to our custom object DaysOfWeek which is also an enum.

    1st Method

    a) RecurrenceDays days = new RecurrenceDays();
    days = days.AddDay(CurrentCreatedAppointment.RecurrenceRule.Pattern.DaysOfWeekMask);
    var s = days.GetDaysOfWeek().Select(x => (DaysOfWeek)Enum.Parse(typeof(DaysOfWeek), x.ToString())).AsEnumerable();
    viewModel.BackupArchiveSettings.ByDay = new ObservableCollection<DaysOfWeek>( s);
    var k = s.GetEnumerator();

    var k1 = k.Current;

     

    2nd Method

     RecurrenceDays days = new RecurrenceDays();
    days = days.AddDay(CurrentCreatedAppointment.RecurrenceRule.Pattern.DaysOfWeekMask);
    var s = days.GetDaysOfWeek().Select(x => (DaysOfWeek)Enum.Parse(typeof(DaysOfWeek), x.ToString())).AsEnumerable();

    newcol = new ObservableCollection<DaysOfWeek>();
    foreach (var item in s.ToList())
    {
     viewModel.BackupArchiveSettings.ByDay.Add(item);
    }

     

    Please help

     

    Thanks,

    Divya

  2. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2480 posts

    Posted 11 Mar Link to this post

    Hello Divya,

    To get the recurrence pattern of an appointment, you can use its RecurrenceRule and the Pattern property, as you are already doing.

    var pattern = CurrentCreatedAppointment.RecurrenceRule.Pattern;

    Note that the Appointment elements doesn't have a recurrence rule set by default, so in the situations where the property is not set explicitly its value will be null. A similar statement applies for the DaysOfWeekMask property - if not defined explicitly, its value is None.

    Can you tell me what exactly doesn't work on your side? And also when your code is executed? It would be useful, if you could isolate the issue in a runnable project and send it over.

    Regards,
    Martin Ivanov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Divya
    Divya avatar
    11 posts
    Member since:
    Mar 2014

    Posted 01 Apr in reply to Martin Ivanov Link to this post

    Sorry for delayed reply. And thank you for your response

    I was able to achieve the same by these steps

                       var days = CurrentCreatedAppointment.RecurrenceRule.Pattern.DaysOfWeekMask.GetDaysOfWeek();                    
                        foreach (var day in days)
                        {
                            viewModel.BackupSettings.ByDay.Add((DaysOfWeek)((int)day));
                        }

    Thanks

  4. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2480 posts

    Posted 01 Apr Link to this post

    Hi Divya,

    It is good to hear that you managed to resolve this.

    Regards,
    Martin Ivanov
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top