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

Applying Recurrence Programatically on Server Side

5 Answers 284 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
PaladinMRB
Top achievements
Rank 1
PaladinMRB asked on 02 Apr 2009, 08:55 PM
Hi,

I'm trying to input schedule data into a RadScheduler that comes from a foreign system. For the purposes of this exercise let's just say it schedule data being imported into my App's SQL DB from another SQL server DB.

I have my own business object data layer and have an object called WorkSchedule which contains an instance of a class that contains multiple instances of another object called WorkScheduleTimeCollection (as an ArrayList). WorkScheduleTImeCollection in essence contains multiple instances of the class WorkScheduleTime (which is for all intents and purposes an object to represent an Appointment), this collection can thus be bound as a DataSource to RadScheduler.

When WorkScheduleTimeCollection is populated with data, an instance of a RadScheduler Recurrence Rule is created, both it and its string representation have been added as properties to the WorkScheduleTime Class. WorkScheduleTime also contains general data (like "Name" and "UniqueID"), as well as a StartTime and EndTime.

Also note I did find that formatting the RecurrenceRule string representation as discussed here: http://www.telerik.com/community/forums/aspnet-ajax/scheduler/daily-recurrence-string-is-correct.aspx to be useful.

Therefore I am attempting to bind this data to the RadScheduler as such:

With rsSchedule 
 
    Dim stcWorkSchedule As New WorkScheduleTimeCollection
    stcWorkSchedule = Database.SelectWorkScheduleTimes(ScheduleUniqueID, .VisibleRangeStart, .VisibleRangeEnd, True) 
 
    .DataSource = stcWorkSchedule 
    .DataKeyField = "UniqueID" 
    .DataSubjectField = "Name" 
    .DataStartField = "StartTime" 
    .DataEndField = "EndTime" 
    .DataRecurrenceParentKeyField = "UniqueID" 
    .DataRecurrenceField = "RecurrenceRuleValue" 
    .DataBind()                 
 
End With 

In the code the first line simply retrieves the collection of "appointment" objects in the current schedule from a database method for the current visible range, and then it is bound to the RadScheduler

Here is an example of what kind of data would be in a typical WorkScheduleTime Appointment object, including the recurrence rule:

ID: 562
UniqueID: 562.008
Name: 562.008
DateActiveFrom: 1/1/2000 12:00:00 AM
DateActiveTo: 1/1/2099 12:00:00 AM
StartTime: 1/1/2000 12:34:00 PM (UTC)
EndTime: 1/1/2000 1:10:00 PM (UTC)
DayFrequency: M,T,W,U,F
RecurrenceRuleValue: DTSTART:20000101T000000Z/r/nDTEND:20000101T003600Z/r/nRRULE:FREQ=WEEKLY;UNTIL=20990101T000000Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR/r/n

Here is (a simplified example of, but the same lines of code exist in the actual method of) how the recurrence rule is created, BTW:
 
Private Function CreateRecurrenceRule(wstTime As WorkScheduleTime) As WorkScheduleTime

    With wstTime 
       
        Dim rrRange As New RecurrenceRange() 
        rrRange.Start = .DateActiveFrom 
        rrRange.RecursUntil = .DateActiveTo 
        rrRange.EventDuration = .EndTime - .StartTime 
 
        'Here ".DayFrequency" is a class of boolean values representing the 7 character comma delimited day
        'frequency list I receive from the foreign schedule data, that class is "converted" to the Telerik
        'RecurrenceDay object.
        Dim rdDays As RecurrenceDay = Me.BuildScheduleDayRecurrence(.DayFrequency) 
 
        Dim wrRule As New WeeklyRecurrenceRule(1, rdDays, rrRange) 
 
        .RecurrenceRule = wrRule 
        .RecurrenceRuleValue = wrRule.ToString 
        .RecurrenceRuleValue = .RecurrenceRuleValue.Replace(vbCr, "/r") 
        .RecurrenceRuleValue = .RecurrenceRuleValue.Replace(vbLf, "/n") 
 
    End With 
 
    Return wstTime
End Sub 
 
 
 

Now my problem is, when the page loads all I get is one instance of each appointment created on the start date (DateActiveFrom) of the appointment and no others (it just so happens 1/1/2000 is a Saturday so the recurrence is truly not working correctly as these appointments almost always happen during the week as does the example). In essence the above example appointment does not recur every week day on M/W/T/U/F at 12:34p - 1:10p from 1/1/2000 - 1/1/2099. And at this point I'm not sure why.

The scheduler does see the appointment as a recurring appointment and will attempt to edit the individual occurence but If I try to "edit" the whole series the control breaks citing "not an instance of an object".

Any help would be appreciated, a trouble ticket can be submitted if that becomes necessary.

Thanks!

5 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 06 Apr 2009, 03:45 PM
Hi,

Thank you for describing the problem in detail. The issue seems to be that the DTSTART and DTEND fields do not correspond to the start and end time of the appointment. So the sample rule should look like this:

DTSTART:20000101T003400Z
DTEND:20000101T011000Z
RRULE:FREQ=WEEKLY;UNTIL=20990101T000000Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR


And the code should be changed to:

Dim rrRange As New RecurrenceRange()
rrRange.Start = .StartTime


Just one more thing - RadScheduler generates weekly occurrences sequentially and gives up after a given number of tries. This gets the job done for most cases, but sometimes this limit proves to be too small. You might need to set a higher value for the RadScheduler.MaximumRecurrenceCandidates property (say 10000), as the sample appointment starts 10 years in the past . We gradually optimize those algorithms, so they can directly calculate the occurrences for the current time range.

Let us know if you have any further questions.

Greetings,
Tsvetomir Tsonev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
.
Top achievements
Rank 1
answered on 10 Apr 2009, 06:01 PM

Hello, can someone provide sample C# code in creating a temporary recurrence rule object in which I can assign default values for a WEEKLY recurrence which then I can do some DateAdding functions to manipulate the DTSTART, DTEND, UNTIL, & INTERVAL sections mainly and then re-assign these manipulated values back to it?  Would it be using the TryParse method or something along those lines?

 

Thanks in advance.

0
Peter
Telerik team
answered on 13 Apr 2009, 01:34 PM
Hello,

The following topic will help you get started:
http://www.telerik.com/help/aspnet-ajax/schedule_serversideworkingwithrecurringappointments.html


All the best,
Peter
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
SKS
Top achievements
Rank 1
answered on 23 Mar 2010, 08:35 PM
is there any performance hit if you change the MaximumRecurrenceCandidates = 6000.
by default it is 3000.?
can you please clarify?
0
T. Tsonev
Telerik team
answered on 24 Mar 2010, 03:33 PM
Hello,

I'm copying my reply to this forum thread for reference:

No, there isn't direct performance hit from increasing this number. It simply tells RadScheduler to give up evaluating a recurrence rule after more retries. This mostly affects recurrence rules that span multiple years (over 30 or so). Even for them the performance hit is negligible.


Sincerely yours,
Tsvetomir Tsonev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Scheduler
Asked by
PaladinMRB
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
.
Top achievements
Rank 1
Peter
Telerik team
SKS
Top achievements
Rank 1
Share this question
or