Retrieve a future instance of a recurring appointment

6 posts, 0 answers
  1. Scott
    Scott avatar
    13 posts
    Member since:
    Dec 2015

    Posted 29 Sep Link to this post

    I need to perform data retrieval and analysis on recurring appointment instances that exist in the future.

    Here is the business logic:

    1.  User selects a date & resource combination.

    2.  Application pulls instances from scheduler tables.

    3.  Instances are loaded into var or datatable for application retrieval and analysis

    Problem:

    Instances of future recurring appointments do not exist in scheduler appointment table so I cannot perform a filtered retrieval.

    Question:

    How can I perform this action?

  2. Dess
    Admin
    Dess avatar
    1605 posts

    Posted 03 Oct Link to this post

    Hello Scott,

    Thank you for writing.  

    According to the provided information, I suppose that you bind RadScheduler with recurring appointments. However, the future occurrences are not displayed. It is necessary to specify the AppointmentMappingInfo.RecurrenceRule property to which column from your DataTable should be retrieved in order to load correctly the recurrence rule:
    this.radScheduler1.ActiveViewType = SchedulerViewType.Month;
     
    DataTable dt = new DataTable();
    dt.Columns.Add("ID", typeof(int));
    dt.Columns.Add("Start", typeof(DateTime));
    dt.Columns.Add("End", typeof(DateTime));
    dt.Columns.Add("Description", typeof(string));
    dt.Columns.Add("Location", typeof(string));
    dt.Columns.Add("RecurrenceRule", typeof(string));
     
    dt.Rows.Add(1, DateTime.Now.AddHours(1), DateTime.Now.AddHours(2), "Meeting A", "Sofia", "FREQ=DAILY;INTERVAL=2");
    SchedulerBindingDataSource source = new SchedulerBindingDataSource();
    AppointmentMappingInfo appointmentMappingInfo = new AppointmentMappingInfo();
    appointmentMappingInfo.Start = "Start";
    appointmentMappingInfo.End = "End";
    appointmentMappingInfo.Summary = "Description";
    appointmentMappingInfo.Location = "Location";
    appointmentMappingInfo.RecurrenceRule = "RecurrenceRule";
    source.EventProvider.Mapping = appointmentMappingInfo;
    source.EventProvider.DataSource = dt;
    this.radScheduler1.DataSource = source;

    Additional information how to setup the scheduler binding is available here: http://docs.telerik.com/devtools/winforms/scheduler/data-binding/using-datasource-property

    If you need to remove some of the occurrences it is necessary to add the desired date to the Appointment.RecurrenceRule.ExceptionDates collection:
    this.radScheduler1.Appointments[0].RecurrenceRule.ExceptionDates.Add(this.radScheduler1.Appointments[0].Occurrences.Last().Start);

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Scott
    Scott avatar
    13 posts
    Member since:
    Dec 2015

    Posted 04 Oct in reply to Dess Link to this post

    Hi Dess-

    Thank you for responding, but I don't think I explained problem well.  I have a scheduler that is working just fine.  But I need to do some analysis of recurring calendar items that exist in the future.

    Something like this(Please reference attached files):
    I want to pull the instance information on Oct-28 for Laburay, Stevens, and Koepke.  Once I have that instance information, I need to conduct analytics for that day on those singular instances of an otherwise recurring appointment.

    I am thinking I need to create a temp table to add(make a copy and insert) the instance information(rows) into that temp table in order to work with them.  However, I do not see how to extract future instances of a recurring appointment from the Recurring Appointment record from the ServicesAppointments table.

    I have attached a copy of my Scheduler and the rows from ServiceAppointments table. 

    Thank you again!

    -Scott

  5. Dess
    Admin
    Dess avatar
    1605 posts

    Posted 05 Oct Link to this post

    Hello Scott, 

    Thank you for writing back. 

    The Occurrences property of the Appointment class returns an enumerator that can be used to retrieve all the occurrences defined by the rule. Thus, you can fill the temporary table with the desired future occurrences.

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  6. Scott
    Scott avatar
    13 posts
    Member since:
    Dec 2015

    Posted 05 Oct in reply to Dess Link to this post

    Hi Dess!

    You set me down the exact right path!  Thank you so much.

    The only thing I would add to this is the use of custom Appointment classes.  I have included a snippet of my implementation in case anyone else runs into this.

     

            {
                DataTable futureInstances = new DataTable();
                futureInstances.Columns.Add("ServiceDate", typeof(DateTime));
                futureInstances.Columns.Add("ServiceSummary", typeof(string));
                futureInstances.Columns.Add("ServiceLocation", typeof(string));
                futureInstances.Columns.Add("ServiceDefinition", typeof(string));
                futureInstances.Columns.Add("ServiceLabor", typeof(double));

                var clsAppt = radScheduler1.Appointments.ToList();

                clsServiceAppointments varAppt = (clsServiceAppointments)radScheduler1.Appointments.First();

                DateTime farOut = DateTime.Parse("11/30/2016");  // required to limit the ForEach iterations.  Will be change to be user assignable.

                var serviceDefs = from sd in db.t_Estimates where sd.Void == false select sd;

                foreach (clsServiceAppointments ca in clsAppt)
                {
                    {
                        foreach (IEvent ev in ca.Occurrences)
                        {
                            if (ev.Start > farOut ) { break; }

                            DataRow row = futureInstances.NewRow();
                            row["ServiceDate"] = ev.Start;
                            row["ServiceSummary"] = ca.Subject;
                            row["ServiceLocation"] = ca.ServiceLocation;
                            row["ServiceDefinition"] = ca.ServiceDefinition;
                            row["ServiceLabor"] = serviceDefs.Where(p => p.ID == ca.ServiceDefinition).Single().SelectedServiceLabor;
                            futureInstances.Rows.Add(row);
                        }
                    }
                }

                radGridView1.DataSource = futureInstances;
            }

  7. Dess
    Admin
    Dess avatar
    1605 posts

    Posted 10 Oct Link to this post

    Hello Scott, 

    Thank you for writing back. 

    It doesn't matter whether you use a custom Appointment class or not. The Occurrences property will always give the collection of future events belonging to this recurring appointment.

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready