GetOccurrences method

Hi,

I wanted to see the results of GetOccurrences method execution and I have an issue.

Here is the code I use :

            var testEvent = new CalendarEvent()
            {
                start_date = new DateTime(2013, 4, 8),
                end_date = new DateTime(2013, 5, 5),
                event_length = 86400,
                event_pid = null,
                id = 0,
                rec_type = "week_1___1#",
                text = "Test event"
            };

            var items = new List<CalendarEvent>() { testEvent };
            var helper = new DHXEventsHelper();
            var events = helper.GetOccurrences(items, testEvent.start_date.Value, testEvent.end_date.Value);

My CalendarEvent class looks like this :

    public class CalendarEvent
    {
        public int id { get; set; }
        public string text { get; set; }
        public DateTime? start_date { get; set; }
        public DateTime? end_date { get; set; }
        public int? event_length { get; set; }
        public string rec_type { get; set; }
        public int? event_pid { get; set; }
    }

The problem is that GetOccurrences throws an InvalidCastException without any other information.

Do you have an idea ?
When I use a CalendarEvent object without specifying recurring properties (event_length, rec_type, event_pid), everything is fine.

Thank you for your answers.

Hi,
event_length must be a long. It may contain timestamp which is out of int range. If you change class definition to following, everything should work: public class CalendarEvent { public int id { get; set; } public string text { get; set; } public DateTime? start_date { get; set; } public DateTime? end_date { get; set; } public long? event_length { get; set; } public string rec_type { get; set; } public int? event_pid { get; set; } }

Yes perfect ! Thanks