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

How to create Exceptions

2 Answers 114 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
andrea
Top achievements
Rank 1
andrea asked on 13 Mar 2009, 03:18 PM
Hello everybody.
I urgently need to create exceptions by code. Is there a simple way to accomplish that?
How coul be possible to modify the recurrence rule?
Immediate help would be kindly appreciated.

Andrea

2 Answers, 1 is accepted

Sort by
0
andrea
Top achievements
Rank 1
answered on 14 Mar 2009, 12:39 PM
Well, at the moment I'm creating exception performing insert of appointments directly in the db by custom code, during appointmentInsert event.
I wonder if it could be possible to achieve the same in a better way.

Let me know
Thanks
Andrea
0
Peter
Telerik team
answered on 16 Mar 2009, 02:15 PM
Hello andrea,

You can use the Exceptions.Add method of the recurrence rule to create exceptions by code. Here is a simple example of a daily recurrence rule which creates an exception at 1 pm :
 protected void Page_Load(object sender, EventArgs e)  
    {  
        // Create a recurrence range, that specifies a limit of 10 occurrences for the appointment.  
        RecurrenceRange range = new RecurrenceRange();  
        range.Start = new DateTime(2009, 3, 16, 9, 0, 0);  
        range.EventDuration = new TimeSpan(1, 0, 0);  
        range.MaxOccurences = 10;  
        // Create a recurrence rule to repeat the appointment every 2 hours.  
        HourlyRecurrenceRule rrule = new HourlyRecurrenceRule(2, range);  
        //Create exception at 1 pm:  
        rrule.Exceptions.Add(new DateTime(2009, 3, 16, 13, 0, 0));  
        Response.Write("The appointment recurs at the following times <br/>");  
        foreach (DateTime occurrence in rrule.Occurrences)  
        {  
            Response.Write(occurrence.ToString() + "<br/>");              
        }  
    } 



Greetings,
Peter
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Scheduler
Asked by
andrea
Top achievements
Rank 1
Answers by
andrea
Top achievements
Rank 1
Peter
Telerik team
Share this question
or