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

null reference error when adding KendoEvent.RecurrenceException to iCal.ExceptionDates

1 Answer 116 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Logan
Top achievements
Rank 1
Veteran
Logan asked on 17 Dec 2018, 05:47 PM

I need to take a recurring event that was set up in the kendo scheduler and unpack it so i can get an entry for each date. I am using iCal.Net to do this.

 

It works as expected for recurring events, but when i delete an occurrence from the recurring event and try to pass kendoEvent.RecurrenceException to iCalEvent.ExceptionDates.Add(new PeriodList(kendoEvent.RecurrenceException) I get a null reference exception when i call iCal-Calendar.GetOccurrences.

 

Do I need to do something when converting between kendo and ical?

 

TIA

 

My code is:

 

public static List<Occurrence> UnpackRecurrence(ISchedulerEvent scheduleEvent, DateTime? start = null, DateTime? end = null)
        {
            List<Occurrence> rVal = new List<Occurrence>();
            if (string.IsNullOrWhiteSpace(scheduleEvent.RecurrenceRule) == false)
            {
                var recurrencePattern = new RecurrencePattern(scheduleEvent.RecurrenceRule);
                iCalendar calendar = new iCalendar();
                Event evnt = new Event()
                {
                    Start = new iCalDateTime(scheduleEvent.Start),
                    End = new iCalDateTime(scheduleEvent.End)
                };
                evnt.RecurrenceRules.Add(recurrencePattern);
 
                if (string.IsNullOrWhiteSpace(scheduleEvent.RecurrenceException) == false)
                {
                    evnt.ExceptionDates.Add(new PeriodList(scheduleEvent.RecurrenceException));
                }
 
                calendar.Events.Add(evnt);
 
                start = start ?? scheduleEvent.Start;
                if (end == null)
                {
                    if (recurrencePattern.Until != DateTime.MinValue)
                    {
                        end = recurrencePattern.Until;
                    }
                    else if (recurrencePattern.Count > 0)
                    {
                        end = DateTime.Now.AddYears(recurrencePattern.Count);
                    }
                    else
                    {
                        end = DateTime.Now.AddYears(5); // we probably shouldn't hit this
                    }
                }
 
                rVal = calendar.GetOccurrences(new iCalDateTime(start.Value), new iCalDateTime(end.Value)).ToList();
            }
 
            return rVal;
        }

 

1 Answer, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 20 Dec 2018, 09:51 AM
Hello Logan,

We have not tested the functionality offered by the Ical.Net library. Note that the RecurrenceException field in the SchedulerEvent object will hold a string of coma separated ISO 8601 with a Z zone designator (UTC) dates. Depending on the implementation of the PeriodList() constructor, you may need to process that string before passing it to that method.

In case you have any other questions on the Kendo UI widgets or their build-in API, please do not hesitate to contact us.

Regards,
Veselin Tsvetanov
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.
Tags
Scheduler
Asked by
Logan
Top achievements
Rank 1
Veteran
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or