Hello.
I have been developing a web application that accesses the database via web service.
In order to block time slots of the RadScheduler component, I have implemented the following method, which is associated with event OnTimeSlotCreated:
Method TimeSlotBlock checks if the resource is blocked for the start and end times provided:
blockedTime is a list of blocked times:
For testing purposes, I have loaded blockedTime on Page_Load:
This list item indicates that resource "575204" is blocked from 08:00 AM to 10:00 AM on 01/25/2012.
This solution works only partially for two reasons:
1) Method TimeSlotCreated is not called when the calendar date changes. Although in the code above the resource is blocked only on 01/25/2012, all dates will have the time slots blocked from 8 to 10.
Is there a way to solve this problem?
2) Instead of Page_Load, the routine that populates the list of blocked times needs to be called every time the calendar date changes. This is required because the time resources are blocked varies on a daily basis. On one day, a resource might be blocked from 8 to 10 AM. On another day, from 5 to 7 AM. And in another day, not blocked at all.
How can the list of blocked times be populated every time the calendar date changes?
Thank you in advance.
Paulo
I have been developing a web application that accesses the database via web service.
In order to block time slots of the RadScheduler component, I have implemented the following method, which is associated with event OnTimeSlotCreated:
protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e) { // checking if the current time slot is blocked if (TimeSlotBlocked(e.TimeSlot.Resource.Key.ToString(), e.TimeSlot.Start, e.TimeSlot.End)) { e.TimeSlot.CssClass = "Disabled"; } }Method TimeSlotBlock checks if the resource is blocked for the start and end times provided:
protected bool TimeSlotBlocked(String pt, DateTime dt1, DateTime dt2) { foreach (PTBlockedTime bt in blockedTime) { if ((pt == bt.PersonalTrainerId) && ((dt1.AddMinutes(+1) >= bt.Start && dt1.AddMinutes(+1) <= bt.End) || (dt2.AddMinutes(-1) >= bt.Start && dt2.AddMinutes(-1) <= bt.End))) { return true; } } return false; }blockedTime is a list of blocked times:
public struct PTBlockedTime { public String PersonalTrainerId; public DateTime Start; public DateTime End; public PTBlockedTime(String pt, DateTime dt1, DateTime dt2) { PersonalTrainerId = pt; Start = dt1; End = dt2; } } . . . List<PTBlockedTime> blockedTime = new List<PTBlockedTime>();For testing purposes, I have loaded blockedTime on Page_Load:
DateTime aux1 = new DateTime(2012, 1, 25, 8, 0, 0); DateTime aux2 = new DateTime(2012, 1, 25, 10, 0, 0); PTBlockedTime aux = new PTBlockedTime("575204", aux1, aux2); blockedTime.Add(aux);This solution works only partially for two reasons:
1) Method TimeSlotCreated is not called when the calendar date changes. Although in the code above the resource is blocked only on 01/25/2012, all dates will have the time slots blocked from 8 to 10.
Is there a way to solve this problem?
2) Instead of Page_Load, the routine that populates the list of blocked times needs to be called every time the calendar date changes. This is required because the time resources are blocked varies on a daily basis. On one day, a resource might be blocked from 8 to 10 AM. On another day, from 5 to 7 AM. And in another day, not blocked at all.
How can the list of blocked times be populated every time the calendar date changes?
Thank you in advance.
Paulo
