RadScheduler Recurrence Engine

6 posts, 0 answers
  1. Carlo DiCelico
    Carlo DiCelico avatar
    15 posts
    Member since:
    Sep 2007

    Posted 23 Oct 2007 Link to this post

    What would be the best way to store the RecurrenceRule and the RecurrenceParentId in the database? Would varchar and int, respectively, be the best data types to use in SQL?

    Also, what would be the best way to translate a recurrence rule into something I can use somewhere else? For example, if I wanted to populate a DropDownList control with appointment titles and then upon SelectedIndexChanged, populate the second DropDownList with all of the available (recurring) time slots, would that be possible? If so, what would be the best way of going about it?

    Thanks.

  2. Ryan
    Ryan avatar
    14 posts
    Member since:
    Sep 2007

    Posted 23 Jan 2008 Link to this post

    I would like to know the answer to Carlo's first question:

    "What would be the best way to store the RecurrenceRule and the RecurrenceParentId in the database? Would varchar and int, respectively, be the best data types to use in SQL?"
  3. T. Tsonev
    Admin
    T. Tsonev avatar
    2816 posts

    Posted 24 Jan 2008 Link to this post

    Hi Ryan,

    The recommended storage for RecurrenceRule is varchar with maximum size of about 1024 characters. Most recurrence rules take much less and the extra space is needed for appending exception dates.

    The RecurrenceParentID field is a foreign key pointing to the primary key, so it must be of the same type as the PK.

    In order to make sense of the recurrence rule it should be parsed first. The Telerik.Web.UI.RecurrenceRule class makes this task easy. The following example first builds a recurrence rule, then converts it to string (as for storage in a database) and finally parses it and outputs the occurrence dates:

    using System; 
    using Telerik.Web.UI; 
    namespace RecurrenceExamples 
       class ParsingExample 
       { 
           static void Main() 
           { 
               // Creates a sample appointment that starts at 6/1/2007 3:30 PM (local time) and lasts half an hour. 
               Appointment recurringAppointment = new Appointment("1", Convert.ToDateTime("6/1/2007 3:30 PM"), 
                   Convert.ToDateTime("6/1/2007 4:00 PM"), "Sample appointment"); 
               // Creates a recurrence range, that specifies a limit of 10 occurrences for the appointment. 
               RecurrenceRange range = new RecurrenceRange(); 
               range.Start = recurringAppointment.Start; 
               range.EventDuration = recurringAppointment.End - recurringAppointment.Start; 
               range.MaxOccurences = 10; 
               // Creates a recurrence rule to repeat the appointment every 2 hours. 
               HourlyRecurrenceRule rrule = new HourlyRecurrenceRule(2, range); 
               Console.WriteLine("The appointment recurs at the following times"); 
               foreach (DateTime occurrence in rrule.Occurrences) 
               { 
                   Console.WriteLine("\t{0}", occurrence); 
               } 
               Console.WriteLine(); 
               // Prints the string representation of the recurrence rule: 
               string rruleAsString = rrule.ToString(); 
               Console.WriteLine("Recurrence rule:\n\n{0}\n", rruleAsString); 
               // The string representation can be stored in a database, etc. 
               // ... 
               // Then it can be reconstructed using TryParse method: 
               RecurrenceRule parsedRule; 
               RecurrenceRule.TryParse(rruleAsString, out parsedRule); 
               Console.WriteLine("After parsing (should be the same):\n\n{0}", parsedRule); 
           } 
       } 
    }  

    More information in the online documentation.

    Kind regards,
    Tsvetomir Tsonev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  4. Ryan
    Ryan avatar
    14 posts
    Member since:
    Sep 2007

    Posted 24 Jan 2008 Link to this post

    Thanks for the fast response.
  5. Eugene
    Eugene avatar
    1 posts
    Member since:
    May 2013

    Posted 01 May Link to this post

    First, I apologize for resurrecting this thread nearly a decade later.  Is there any problem setting the column size larger than varchar(1024)?  I am working with a system in which client users are occasionally setting recurring appointments in which the recurrence rule data size hits the 1024 character limit and starts causing issues with the calendar.  I know this control is old but would like to avoid the effort of changing out this control because of a column size?
  6. Peter Milchev
    Admin
    Peter Milchev avatar
    552 posts

    Posted 03 May Link to this post

    Hello Eugene,

    The recommended size is 1024 for optimization purposes, as it is rarely the case when there are so many exception dates that the total string count exceeds 1024 characters. 

    With that said, there should be no issue with increasing the number of characters limit.

    Regards,
    Peter Milchev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top