Print Page | Close Window

C#, SQL and RecurrencePatterns

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=2929
Printed Date: 25 November 2024 at 1:06am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: C#, SQL and RecurrencePatterns
Posted By: njcurrie
Subject: C#, SQL and RecurrencePatterns
Date Posted: 21 September 2005 at 3:10pm

Hi

Hope someone can help me here as I have run out of ideas what to do.

I am trying to integrate the Calendar Control into my C# Application.  All my data is held within a SQL database.

I have created a single table that contains all the required fields for the Event and its Recurrence Pattern should it have one.

Using a previous post in this forum as a guide I have created the necessary functions to handle the communication between the Calendar Control and my SQL Database.

For example to Load the events I loop through the database and create a new event for each record in the table. I add a recurrence Pattern if the ReccurenceState is set to RecurrenceMaster.

This works great, I can Add/Update/Delete Single Events and Events with Recurrence Patterns.

Now my problem occurs when I create a RecurrenceException inside the calendar control; What I do is I save the event as a new record to the database with its ReccurenceState set to RecurrenceException.

When I try to load the RecurrenceException back into the Calendar Control. I can add it as an event no problem at all, I detect during the load that it is a RecurrenceException and run the MakeAsRException() function on the event.

What I can’t work out is how I connect the RecurrenceException to its original Event and RecurrencePattern. The original event displays as normal with the event that was edited to become the RecurrenceException displayed as normal

How do I add a Recurrence Exception to a Recurrence Pattern from an external database?

Any help here would be appreciated as this is the final thing I have to get working for my evaluation program to be complete. 

Thanks

NJC
Development Team
The IT Manager Company




Replies:
Posted By: sserge
Date Posted: 22 September 2005 at 4:18pm
Hi,

The calendar events objects model, like tree is similar to the following:

<Normal event>
<Recurrence master event>
    <Recurrence pattern>
        <Recurrence occurrences list> - virtual events. They are not stored but generated by request.
        <Recurrence exception>        - instances stored inside pattern and used when generating occurrences.


Recurrence Exception event has a few special fields to connect to its occurrence:
RExceptionStartTimeOrig, RExceptionEndTimeOrig, and of cause RecurrencePatternID.
These fields mean original occurrence Start/End times (and of cause RecurrencePatternID is used there too)

The event object has such properties but they are not in the interface. You cannot set them directly.

When MakeAsRException() is called - event StartTime/EndTime is copied to RExceptionStartTimeOrig / RExceptionEndTimeOrig.

Other thing is that you have call AddEvent only for Normal and Master events.
For Exceptions/Occurrences you have to call ChangeEvent method.

The logic is that firstly you add master event with recurrence pattern. After that all occurrences virtually exist.

Then you call ChangeEvent() to change some occurrences and make them as exceptions.

EXAMPLE:
    // sort your records by RecurrenceState to be shure that master event
    // will be added before ocurrences.

    // Master event processing

    pMasterEvent.CreateRecurrenceEx(pEve ntRS("RecurrencePatternID"));

    // .....
    
    // Exception event processing


    pEvent.StartTime = pEventRS("RExceptionStartTimeOrig");
    pEvent.EndTime = pEventRS("RExceptionEndTimeOrig");
    
    pEvent.MakeAsRExceptionEx(pEventRS(" RecurrencePatternID"));



    pEvent.StartTime = pEventRS("StartDateTime");
    pEvent.EndTime = pEventRS("EndDateTime");
    
    pData.ChangeEvent(pEvent);

NOTE:
Unfortunately, following methods members for ActiveX control will be available only with the next release.
    CalendarEvent.CreateRecurrenceEx(Pat ternID As Long)
    CalendarEvent.MakeAsRExceptionEx(Pat ternID As Long)
    CalendarRecurrencePattern.Id
    CalendarRecurrencePattern.MasterEven tId

Let me know whether this is clear.

--
WBR,
Serge


Posted By: njcurrie
Date Posted: 28 September 2005 at 4:41am

Serge

Sorry for the delay in the reply I got diverted onto another project.

Thanks for the explanation, it now all makes perfect sense. I can proceed with the current version and incorporate Recurrence Exceptions at a later date when the new release is available.

So i guess the only question i have left to ask is when the new release will be out?

Thanks for the help

NJC
Development Team
The IT Manager Company

 



Posted By: gshawn
Date Posted: 28 September 2005 at 4:53am

Originally posted by njcurrie njcurrie wrote:

So i guess the only question i have left to ask is when the new release will be out?

I already sent you a PM about 10 minutes ago, but in case your popup blocker prevents you from seeing it: Version 9.80 was released a few hours ago. Check the Downloads section.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net