Get a list of appointments in a time range programmatically

4 posts, 0 answers
  1. Michael
    Michael avatar
    23 posts
    Member since:
    Jan 2012

    Posted 22 May 2013 Link to this post

    I know how to render a scheduler on a page and use GetAppointmentsInRange to get/count appointments, but how can I get that information programmatically without having to put a scheduler on a page? Based on the default schema. 

    I have an application used for scheduling staff. Staff use appointments to mark when they are unavailable. I need to get a list of all staff that are unavailable during a certain time frame, but rendering a scheduler control with 2000 staff then calling GetAppointmentsInRange is too slow. Based on the schema and the way the scheduler control saves recurrence, is it possible to get a list of all appointments in a range without rendering the control? 

    Here are my database columns, I only added one, "employeeID"

    ID
    Subject
    Description
    Start
    End
    RecurrenceRule
    RecurrenceParentID
    Reminder
    Annotations
    EmployeeID

    So I need a command that will return all employeeID numbers that have appointments between 2 dates (a timeframe). Considering how recurrence is done by the radScheduler, what can I do to get this result? 

    Thank you very much!
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 24 May 2013 Link to this post

    Hi,

    There is no out-of-the-box way to that, however, you can add LINQ Entity Model for your table and then use LINQ to grab the records between given start and end date. There is plenty of info on MSDN on how to use LINQ so if you are not sure I suggest that you take a look there. And here is some random code that uses LINQ to filter all dates bigger than a given value:

    DateTime lastMonth = DateTime.Today.AddMonths(-1);
    using (var db = new MyEntities())
    {
        var query = from s in db.ViewOrTable
                    orderby s.ColName
                    where (s.StartDate > lastMonth)
                    select s;
     
        _dsResults = query.ToList();
    }



    Regards,
    Genady Sergeev
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Michael
    Michael avatar
    23 posts
    Member since:
    Jan 2012

    Posted 24 May 2013 Link to this post

    That you for the reply. 

    I do use linq quite a bit, so selecting by date range is fine for fixed dates, but what about the recurrence rule? 

    The control must process the recurrence rule in order to display appointments on the calendar, so the code must exist for dealing with that rule.  Here is a sample rule:

    DTSTART:20121015T050000Z
    DTEND:20121015T060000Z
    RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO

    Is there any code available that I can call in order to process this rule? 

    As an example, I give a timeframe, or 2 datetimes, and get back a list of all appointments in that range? (Without drawing the control to the page) 

  4. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 29 May 2013 Link to this post

    Hi,

    You can use the TryParse method of the RecurrenceRule class that can be found the Telerik.Web.UI namespace. Then you can use the properties of the RecurrenceRule class to compare the instances.

    Regards,
    Genady Sergeev
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top