Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Calendar
  New Posts New Posts RSS Feed - C#, SQL and RecurrencePatterns
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

C#, SQL and RecurrencePatterns

 Post Reply Post Reply
Author
Message
njcurrie View Drop Down
Newbie
Newbie


Joined: 18 September 2005
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote njcurrie Quote  Post ReplyReply Direct Link To This Post Topic: C#, SQL and RecurrencePatterns
    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

Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
njcurrie View Drop Down
Newbie
Newbie


Joined: 18 September 2005
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote njcurrie Quote  Post ReplyReply Direct Link To This Post 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

 



Edited by njcurrie
Back to Top
gshawn View Drop Down
Senior Member
Senior Member


Joined: 04 October 2004
Status: Offline
Points: 227
Post Options Post Options   Thanks (0) Thanks(0)   Quote gshawn Quote  Post ReplyReply Direct Link To This Post 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.



Edited by gshawn
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.227 seconds.