Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic appointment conflicts (Read 1452 times)
fabiogiustini
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 17
Joined: Sep 26th, 2007
appointment conflicts
Oct 3rd, 2007 at 5:49am
Print Post  
How can I manage the conflicts between appointments?

Fabio
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: appointment conflicts
Reply #1 - Oct 3rd, 2007 at 7:14am
Print Post  
You have to write your own method in order to detect appointment conflicts (collisions). This method will have O(n2) complexity, where n specifies the number of appointments in your schedule. The following method, for example, detects whether there are any collisions in a specified schedule:

Code
Select All
public bool DetectCollisions(Calendar calendar)
{
	foreach (Item i in calendar.Schedule.Items)
	{
		foreach (Item j in calendar.Schedule.Items)
		{
			if (j.StartTime <= i.StartTime && i.StartTime < j.EndTime ||
				j.StartTime < i.EndTime && i.EndTime <= j.EndTime)
				return true;
		}
	}

	return false;
} 


I haven't tested this one, so it might not work precisely as intended, but it can give you an idea.

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