Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to break up recurring items (Read 5380 times)
SLUser
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 34
Joined: Dec 7th, 2012
How to break up recurring items
Mar 12th, 2013 at 6:44pm
Print Post  
Suppose there exists a recurring item with 10 occurences.
The user wants for example to change the starttime from item 4 onwards.

Instead of creating 7 exceptions, I would prefer to break up the item into 2 recurring items (3 occurences and 7 occurences with another starttime).

How can this best be achieved ?
Thanks,
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How to break up recurring items
Reply #1 - Mar 13th, 2013 at 7:29am
Print Post  
Currently there is no way to achieve this other than using two identical items with separate recurrence patterns. In the WinForms version of the control the Recurrence class provides a special event (ValidateOccurrence) that can be used to customize the individual occurrences in the pattern. For example, this event could be used to adjust the start times of certain occurrences. We can port this event to the next version of the Silverlight control.

Regards,
Meppy
  
Back to top
 
IP Logged
 
SLUser
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 34
Joined: Dec 7th, 2012
Re: How to break up recurring items
Reply #2 - Mar 21st, 2013 at 9:53pm
Print Post  
Perhaps I should rephrase my question: Could you show me (in code) how I can break up an existing (recurring) Item into 2 (recurring) items ?
Thanks,
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How to break up recurring items
Reply #3 - Mar 22nd, 2013 at 6:46am
Print Post  
Let's assume that the item and its recurrence are created like this:

Code
Select All
var item = new Appointment();
item.StartTime = DateTime.Today;
item.EndTime = DateTime.Today;
item.HeaderText = "event";
var recurrence = new Recurrence();
recurrence.Pattern = RecurrencePattern.Daily;
recurrence.Days = 2;
recurrence.StartDate = item.StartTime;
recurrence.RecurrenceEnd = RecurrenceEnd.NumOccurrences;
recurrence.NumOccurrences = 10;
item.Recurrence = recurrence;
c.Schedule.Items.Add(item); 


Now handle the ItemClick event and 'break' the recurrence at the clicked item:

Code
Select All
// Reschedule the recurrence from the clicked item on
var occurrence = e.Item;
if (occurrence.Recurrence != null)
{
	// First, reduce the number of occurrences of the original recurrence
	var master = occurrence.Recurrence.Master;
	var recurrence = master.Recurrence;
	master.Recurrence = null;
	recurrence.NumOccurrences = occurrence.OccurrenceIndex;
	master.Recurrence = recurrence;

	// Then clone the original item and apply a new recurrence pattern to it,
	// starting from the date of the clicked occurrence
	var newItem = master.Clone() as Appointment;
	newItem.StartTime = occurrence.StartTime;
	newItem.EndTime = occurrence.EndTime;
	newItem.Recurrence = null;
	var newRecurrence = new Recurrence();
	newRecurrence.Pattern = RecurrencePattern.Daily;
	newRecurrence.Days = 3;
	newRecurrence.StartDate = newItem.StartTime;
	newRecurrence.RecurrenceEnd = RecurrenceEnd.NumOccurrences;
	newRecurrence.NumOccurrences = 10 - occurrence.OccurrenceIndex;
	newItem.Recurrence = newRecurrence;
	c.Schedule.Items.Add(newItem);
} 


I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
SLUser
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 34
Joined: Dec 7th, 2012
Re: How to break up recurring items
Reply #4 - Mar 22nd, 2013 at 10:42am
Print Post  
Great, thanks !
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint