Too many recurrence exceptions

5 posts, 0 answers
  1. Andrew
    Andrew avatar
    14 posts
    Member since:
    Nov 2010

    Posted 16 Sep 2011 Link to this post

    Hello,

    I have a situation where users are creating a single never ending recurrence on the scheduler then editing the appointment each week to account for small variances in attributes or resources. This is not a problem except that the "exception" string continues to grow with each change. Currently I have the length of the recurrencerule at 2048 bytes and I don't think the correct solution is to keep extending that columns size.

    My preferred solution would be to do something like count the number of exceptions created. I think there are some examples demonstrating a way to do this using parsing and something like "parsedrule.Occurrences". If the count is higher than 50 then I would like to create a new appointment which is a copy of the appointment being modified "newappt = e.appointment" then remove all exceptions from the new appointment and set it with a start date one day past the last exception in the old appointment. Then I would like to change the old appointment from a never ending recurrence to have an end date on the date of its last exception.

    Does that make sense?

    I've pretty much got it worked out except the copy, creation and modification steps. Is there any easier way to do this? If not, can you give me some pointers to proceed with my concept above?

    Thanks!
  2. Plamen
    Admin
    Plamen avatar
    3048 posts

    Posted 21 Sep 2011 Link to this post

    Hello Andrew,

    I will need some more time to provide you with a solution for this issue. I will follow up early next week with my findings.

    Kind regards,
    Plamen Zdravkov
    the Telerik team
    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
  3. Plamen
    Admin
    Plamen avatar
    3048 posts

    Posted 26 Sep 2011 Link to this post

    Hello Andrew,

    Please excuse me for delaying your answer.

    Here is one way we can "cut" the recurrence appointment and create the new appointment so that the recurrence rule is in the regular size by catching the ReccurenceExceptionCreated. You can also try the following variation and decide which one fits your needs better:
    protected void RadScheduler1_RecurrenceExceptionCreated(object sender, RecurrenceExceptionCreatedEventArgs e)
       {
            
           Response.Write(e.Appointment.RecurrenceRule.Length);
           int size = 50;
           if (e.Appointment.RecurrenceRule.Length > size)
           {
           RecurrenceRule parsedRule;
           RecurrenceRule.TryParse(e.Appointment.RecurrenceRule.ToString(), out parsedRule);
           parsedRule.Range.RecursUntil = e.OccurrenceAppointment.End.AddMinutes(-1);
          
           Appointment newApp = new Appointment();
           newApp.Subject = "New" + e.Appointment.Subject;
           newApp.Start = e.OccurrenceAppointment.Start;
           newApp.End = e.OccurrenceAppointment.End;
        
           RecurrenceRule newParsedRule;
           RecurrenceRule.TryParse(e.Appointment.RecurrenceRule.ToString(), out newParsedRule);
           newParsedRule.Exceptions.Clear();       
           newParsedRule.Range.Start = e.OccurrenceAppointment.Start;
           newParsedRule.Range.EventDuration = e.OccurrenceAppointment.Duration;
           newApp.RecurrenceRule = newParsedRule.ToString();
           e.Appointment.RecurrenceRule = parsedRule.ToString();
           RadScheduler1.InsertAppointment(newApp);
           }
          
     
       }

    This one does not have the 24 hour shift as in the attached demo.

    Hope this will help you. If you have further questions please don't hesitate to ask.

    Regards,
    Plamen Zdravkov
    the Telerik team
    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
  4. Andrew
    Andrew avatar
    14 posts
    Member since:
    Nov 2010

    Posted 16 Oct 2011 Link to this post

    Thanks for that example. I took your example and rewrote it as follows. Could you please review it for any major flaws? Yes the length is short for testing. I will expand it before publishing anything. My goal was to have something that would only create a new recurring appointment after the last exception as to not duplicate or overwrite any existing exceptions. I'm only running into one glitch. I think it has something to do with the end of the recurrence rule being the same time as the last appointment. Occasionally when I "reset" occurrences on any single group created by the code below, either the last appointment is deleted or all the appointments are deleted. It's a little confusing, but I'm working on it.

    Below is the code for review. Thanks!!!!!

    If e.Appointment.RecurrenceRule.Length > 150 Then
        ' Reset the current recurrence to end on the day of the last recurrence
        Dim parsedrule As RecurrenceRule
        RecurrenceRule.TryParse(e.Appointment.RecurrenceRule.ToString(), parsedrule)
        If parsedrule.Exceptions.Max > e.ExceptionAppointment.Start Then
            parsedrule.Range.RecursUntil = parsedrule.Exceptions.Max
        Else
            parsedrule.Range.RecursUntil = e.OccurrenceAppointment.Start
        End If
     
        ' Create a new appointment based on the previous recurring appointment
        Dim newAppt As New Appointment
        newAppt.Subject = e.Appointment.Subject
        'newAppt.Start = e.OccurrenceAppointment.Start.AddDays(1)
        newAppt.Start = parsedrule.Range.RecursUntil.AddDays(1)
        'newAppt.End = e.OccurrenceAppointment.End.AddDays(1)
        newAppt.End = newAppt.Start.Add(e.OccurrenceAppointment.Duration)
     
        ' Change the recurrence rule of the new appointment to start after the old rule
        Dim newparsedrule As RecurrenceRule
        RecurrenceRule.TryParse(e.Appointment.RecurrenceRule.ToString, newparsedrule)
        newparsedrule.Exceptions.Clear()
        newparsedrule.Range.Start = parsedrule.Range.RecursUntil.AddDays(1)
        newparsedrule.Range.EventDuration = e.OccurrenceAppointment.Duration
        newAppt.RecurrenceRule = newparsedrule.ToString
     
        ' Change the recurrence rule on the original appointment to have an end date
        e.Appointment.RecurrenceRule = parsedrule.ToString
     
        ' Insert the new recurring appointment
        RadScheduler1.InsertAppointment(newAppt)
    End If

  5. Plamen
    Admin
    Plamen avatar
    3048 posts

    Posted 19 Oct 2011 Link to this post

    Hi Andrew,

    This behaviour sounds like a known bug in the "reset exceptions"  that is already logged for fixing.
     
    All the best,
    Plamen Zdravkov
    the Telerik team
    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
Back to Top