Pending Review
Last Updated: 16 Feb 2017 12:53 by Mauro
Mauro
Created on: 16 Feb 2017 12:53
Category: Scheduler
Type: Feature Request
1
getting expanded appointmens in SchedulerProviderBase
In a RadScheduler with a custom provider (inheriting from SchedulerProviderBase), there is no way to get "expanded" appointments (i.e. masters plus occurrences minus exceptions). 

I devised a solution (as suggested in http://www.telerik.com/forums/scheduler-exporting-a-range-of-appointments), using the Occurrences property of RecurrenceRule:

        public IEnumerable<Appointment> GetExpandedAppointments(RadScheduler owner, DateTime start, DateTime end)
        {
            var result = new List<Appointment>();

            foreach (Appointment a in this.GetAppointments(owner))
            {
                // see http://www.telerik.com/forums/scheduler-exporting-a-range-of-appointments
                if (a.RecurrenceState == RecurrenceState.Master)
                {
                    RecurrenceRule parsedRule;
                    RecurrenceRule.TryParse(a.RecurrenceRule, out parsedRule);
                    parsedRule.SetEffectiveRange(start, end);

                    int nc = 0;
                    foreach (DateTime occurrence in parsedRule.Occurrences)
                    {
                        Appointment app = a.Clone();
                        app.ID = a.ID + "_" + ++nc;
                        app.Start = occurrence;
                        app.End = occurrence.Add(a.Duration);
                        app.RecurrenceRule = null;
                        app.RecurrenceParentID = a.ID;
                        app.RecurrenceState = RecurrenceState.Occurrence;
                        result.Add(app);
                    }
                }
                else if (a.RecurrenceState != RecurrenceState.Occurrence)
                {
                    result.Add(a);
                }
            }

            return result;
        }
    }

I think this functionality can be part of SchedulerProviderBase, there is no custom logic.

Thanks

Regards

Mauro
0 comments