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

Get a list of appointments in a time range programmatically

3 Answers 134 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 22 May 2013, 03:45 PM
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!

3 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 24 May 2013, 09:02 AM
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.
0
Michael
Top achievements
Rank 1
answered on 24 May 2013, 03:36 PM
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) 

0
Genady Sergeev
Telerik team
answered on 29 May 2013, 03:19 PM
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.
Tags
Scheduler
Asked by
Michael
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Michael
Top achievements
Rank 1
Share this question
or