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

Help Debugging Recurrence Exceptions

1 Answer 69 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 10 May 2011, 06:09 AM
Hi All,

Can you point me toward some information that describes the sequence of events in the RadScheduleView when one attempts to modify an Appointment Exception? I'm using your ScheduleView_EF_SL.zip sampl project as a guide. When we move an occurrence of an Appointment Exception to new time slot on the RadScheduleView, we encounter several poblems: 1) the ExceptionOccurrence entity has an incorrect exception date; 2) the SqlException entity has an end date set to apparently DateTime.Min, etc. I can't figure out how to debug into the setting of these properties.

Is there an event raised by the control when an exception occurrence is modified such as RadScheduleView.AppointmentEdited for regular appointments? I need to find out where the DateTime.Min is coming from. It could very possibly be a mistake in our poject, but I don't understand the sequence of events well enough. For example, why does the code below appear in ScheduleView_EF_SL sample: When and why does the Copy() method get called and why is it an Invalid Operation? How can I hook into the process befor this method is called? Specifically, I need to find out when/where ExceptionAppointment and ExceptonOcurrence entities are created.

Unfortunatley the solution into which we've integrated the RadSchelueView is far too big to post as a sample, and i admit that your sample solution does work, but it's very frustrating because I don't understand why/when some things are being done. We are using all your IAppointment, IResource, etc, interfaces on our own entities (for example we have a Booking entity instead of a SqlAppointment), and generally it's working very well--except for recurrence exceptions.

Cheers,
Scott

namespace ScheduleView_EF_SL.Web.AppData
{
    public partial class SqlExceptionAppointment : IEditableObject, IAppointment, IObjectGenerator<IRecurrenceRule>
    {
        public event EventHandler RecurrenceRuleChanged;
 
        public IAppointment Copy()
        {
            throw new InvalidOperationException();
 
        }

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 13 May 2011, 10:10 AM
Hello Scott, 

Thank you for contacting us.

Straight to your questions:

Q"When and why does the Copy() method get called and why is it an Invalid Operation?"
A: The SqlExceptionAppointment.Copy() method shouldn't be used. This is the reason why an InvalidOperationException is thrown. The AppointmentException is only a copy of already created appointment, and only a CopyFrom(IAppointment other) method is in use. If you look into the SqlExceptionAppointment class, you will notice that the same exception will be thrown if the SqlExceptionAppointment.CreateNew() & SqlExceptionAppointment.CreateNew(IRecurrenceRule item) methods are called. The reason for this is the same - they shouldn't be called for the exceptions, but only for the regular appointments.

Q: "Is there an event raised by the control when an exception occurrence is modified such as RadScheduleView.AppointmentEdited for regular appointments?"
A: No, there is no such event, but you don't need it if you use the IRecurrenceRule interface. Please, open the SqlRecurrenceRule.cs file in the ScheduleView_EF_SL project and navigate to the following code snippet:


public IAppointment CreateExceptionAppointment(IAppointment master)
        {
            return (master as SqlAppointment).ShallowCopy();
        }
 
        public IExceptionOccurrence CreateNew()
        {
            return new SqlExceptionOccurrence();
        }
 
        public IExceptionOccurrence CreateNew(IExceptionOccurrence item)
        {
            var sqlExceptionOccurrence = this.CreateNew();
            sqlExceptionOccurrence.CopyFrom(item);
            return sqlExceptionOccurrence;
        }


Here the SqlExceptionAppointment and the SqlExceptionOccurence are created. When the CreateExceptionAppointment is called, we make a ShallowCopy of the master appointment. In the SqlAppointment.ShallowCopy() we create a new SqlExceptionAppointment and call SqlExceptionAppointment.CopyFrom(this) in order to copy the new appointment exception from the appointment.

I cannot say why the ExceptionAppointment has an invalid end date, but I really hope this information will guide you to pinpoint the problem. Also, you could use the IEditableOject.BeginEdit() and IEditableObject.EndEdit() methods and set break points there. They are called every time when an object that implements IEditableObject interface gets in edit state, including the SqlExceptionAppointment.


I hope this helps. Please do not hesitate to contact us if you require any further information. I am glad to assist you further.


All the best,
George
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
ScheduleView
Asked by
Scott
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or