Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Recurrence Exceptions - Mark deleted (Read 4708 times)
Gerardo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Jan 26th, 2007
Recurrence Exceptions - Mark deleted
Jan 26th, 2007 at 12:46pm
Print Post  
In my case is very common to have recurrent appointments with some instances deleted.

Is there a way to only pass the instance dates where the appointment is deleted to the recurrence object?
or Do I have always to generate the items and mark them as deleted?

Thanks in advance for your help.
  
Back to top
 
IP Logged
 
Gerardo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 3
Joined: Jan 26th, 2007
Re: Recurrence Exceptions - Mark deleted
Reply #1 - Jan 26th, 2007 at 12:51pm
Print Post  
The previous post is for the Pocket Planer (I forgot to mention it)
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Recurrence Exceptions - Mark deleted
Reply #2 - Jan 26th, 2007 at 1:52pm
Print Post  
Unfortunately, the only way to mark an item as deleted occurrence of a recurring pattern programatically, is by generating the item and calling Recurrence.MarkException passing a reference to the item and true as parameters. I am not sure what do you mean by 'passing the instance dates to the recurrence object'. If you can explain this a bit further we might be able to expand the public interface to support it.

Meppy
  
Back to top
 
IP Logged
 
gerardo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 27
Joined: Jan 26th, 2007
Re: Recurrence Exceptions - Mark deleted
Reply #3 - Jan 26th, 2007 at 2:51pm
Print Post  
It will be nice to pass an arraylist with the dates/times of all the instances deleted, instead of have to go and mark them one by one....

Just an idea !!
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Recurrence Exceptions - Mark deleted
Reply #4 - Jan 29th, 2007 at 6:36am
Print Post  
Here is a simple method that can help you to achieve the desired functionality:

Code
Select All
private void DeleteOccurrences(Item item, ArrayList toDelete)
{
    if (item.Recurrence == null)
	  return;

    // Find the interval in which to generate the items,
    // by inspecting the values passed in the second argument
    DateTime from = DateTime.MaxValue;
    DateTime to = DateTime.MinValue;

    foreach (DateTime date in toDelete)
    {
	  if (from > date)
		from = date;
	  if (to < date)
		to = date;
    }

    if (from == DateTime.MaxValue ||
	  to == DateTime.MinValue)
	  return;

    ItemCollection items = item.Recurrence.GenerateItems(from, to);

    foreach (Item occurrence in items)
    {
	  // Check if the item should be marked as deleted
	  bool delete = false;
	  foreach (DateTime date in toDelete)
	  {
		if (occurrence.StartTime <= date && date <= occurrence.EndTime)
		{
		    delete = true;
		    break;
		}
	  }

	  if (delete)
		item.Recurrence.MarkException(occurrence, true);
    }

    // Invalidate the calendar
    calendar1.Invalidate();
} 



The method accepts as first argument the master item whose occurrences should be marked as deleted and an array of DateTime objects, specifying the date and time of the occurrences of interest.

Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint