Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Block re-occurrence over 4 weeks (Read 3364 times)
alanmcgeough
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 34
Joined: Dec 17th, 2007
Block re-occurrence over 4 weeks
Nov 12th, 2009 at 12:40pm
Print Post  
Hi all, is it possible to take a block of items for say 4(or any number of weeks) weeks and have a re-occurence of that exact four week period in the next 4 weeks. I use the resource view. Basically im developing a work shedule application and with different locations and mechanics. Each mechanic spends a week in each location. each item represents a sheduled work day by the particular mechanic.

Thanks in Advance
Alan
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Block re-occurrence over 4 weeks
Reply #1 - Nov 12th, 2009 at 1:15pm
Print Post  
You can create clones of the items in the four weeks and reschedule the cloned items in the next four weeks. The code below illustrates this technique:

Code
Select All
DateTime from = calendar1.GetFirstDate();
DateTime to = from.AddDays(28);

ItemCollection items = calendar1.Schedule.GetAllItems(from, to);
if (items.Count == 0)
      return;

foreach (Item item in items)
{
      Appointment copy = item.Clone() as Appointment;
      copy.StartTime += TimeSpan.FromDays(28);
      copy.EndTime += TimeSpan.FromDays(28);
      calendar1.Schedule.Items.Add(copy);
} 


If you want to create a true recurrence based on this pattern, it is going to be more complicated. It could probably be achieved by specifying a daily recurrence pattern, then filtering out all items that do not match by using the ValidateOccurrence event of the Recurrence class.

Let me know if the copy method above works for you.

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


I love YaBB 1G - SP1!

Posts: 34
Joined: Dec 17th, 2007
Re: Block re-occurrence over 4 weeks
Reply #2 - Nov 13th, 2009 at 10:09am
Print Post  
Hi Meppy, thanks for that. it works fine. the thing is this 4 weeks(other time Span) may occur for 6 months or a year.

i was thinking of using the items collection to get all the items within a variable startDate and EndDate.

then running through the items and create a Recurrence of each item. the thing is i need to specify the time for the Recurrence.

if my individual item was to reoccur every 28 days can i use the

rec.Pattern = RecurrencePattern.ByTimeInterval and how does it work
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Block re-occurrence over 4 weeks
Reply #3 - Nov 16th, 2009 at 7:12am
Print Post  
I haven't thought about that pattern before, but now that you mention it, it looks like what you need. Use the following code to specify a 28 day recurrence for an item:

Code
Select All
Recurrence r = new Recurrence();
r.StartDate = item.StartTime;
r.Pattern = RecurrencePattern.ByTimeInterval;
r.Interval = TimeSpan.FromDays(28);
item.Recurrence = r; 


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


I love YaBB 1G - SP1!

Posts: 34
Joined: Dec 17th, 2007
Re: Block re-occurrence over 4 weeks
Reply #4 - Nov 16th, 2009 at 9:34am
Print Post  
when i create a reoccurrence is there an item created or is it just drawn on the control. I need to be able to save the items in the database so there would have to be an item. is there an easy way to do this.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Block re-occurrence over 4 weeks
Reply #5 - Nov 16th, 2009 at 11:03am
Print Post  
No real items are created for recurrences (otherwise infinite recurrences will cause problems). When a particular period of time is being displayed by the control, the recurring items in this period are temporarily generated and displayed. Therefore in your case it might be better to use the cloning technique.

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