I have tried the code you posted few days ago.
The conflict detection still has some problems.
I mod the code post little bit just to make it easier to see.
Inside detector, there are 8 events.
_event 0 and _event 1 are from normal().
_event 2 to 7 are from recurring()
start end
_event 0: 2012-11-08 07:00 2012-11-08 12:00
_event 1: 2012-11-09 16:00 2012-11-09 22:00
_event 2:2012-11-08 07:00 2012-11-08 12:00
_event 3:2012-11-09 07:00 2012-11-09 12:00
_event 4:2012-11-10 07:00 2012-11-10 12:00
_event 5:2012-11-11 07:00 2012-11-11 12:00
_event 6:2012-11-12 07:00 2012-11-12 12:00
_event 7:2012-11-13 07:00 2012-11-13 12:00
_event 0 and event 2 are conflict schedule, but detector ignores them.
If I don't insert this new row in normal():
dr = dt.NewRow();
dr["id"] = 2;
dr["start"] = Convert.ToDateTime("2012-11-09 16:00");
dr["end"] = Convert.ToDateTime("2012-11-09 22:00");
dr["name"] = "Event 2";
dr["resourceid"] = 20;
dt.Rows.Add(dr);
Detection has 7 events and it works fine.
Maybe a bug or due to my inexperience?
The following is the code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DayPilot.Web.Ui.Conflict;
using DayPilot.Web.Ui.Recurrence;
public partial class Test_ConflictDetector : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
RecurrenceRule r = RecurrenceRule.Decode("MzA5#2#C#T#5#RCAqICo=");
DateTime Today = new DateTime(2012,11,01,10,10,00);
DateTime NextYearToday = new DateTime(2013,11,01,10,00,00);
var detector = new ConflictDetector();
detector.Add(normal(), "start", "end", "resourceid");
detector.AddRecurring(recurring(), "start", "end", "resourceid", "recurrence", "id", "master");
detector.ForRange(Today, NextYearToday);
GridView1.DataSource = detector.List;
DataBind();
if (detector.Count > 0)
{
Label1.Text =Convert.ToString(detector.Count);
}
}
private DataTable normal()
{
DataTable dt;
dt = new DataTable();
dt.Columns.Add("start", typeof(DateTime));
dt.Columns.Add("end", typeof(DateTime));
dt.Columns.Add("name", typeof(string));
dt.Columns.Add("id", typeof(string));
dt.Columns.Add("column", typeof(string));
dt.Columns.Add("resourceid", typeof(int));
DataRow dr;
dr = dt.NewRow();
dr["id"] = 1;
dr["start"] = Convert.ToDateTime("2012-11-08 07:00");
dr["end"] = Convert.ToDateTime("2012-11-08 12:00");
dr["name"] = "Event 1";
dr["resourceid"] = 20;
dt.Rows.Add(dr);
/*
dr = dt.NewRow();
dr["id"] = 2;
dr["start"] = Convert.ToDateTime("2012-11-09 16:00");
dr["end"] = Convert.ToDateTime("2012-11-09 22:00");
dr["name"] = "Event 2";
dr["resourceid"] = 20;
dt.Rows.Add(dr);
*/
return dt;
}
private DataTable recurring()
{
DataTable dt;
dt = new DataTable();
dt.Columns.Add("start", typeof(DateTime));
dt.Columns.Add("end", typeof(DateTime));
dt.Columns.Add("name", typeof(string));
dt.Columns.Add("id", typeof(string));
dt.Columns.Add("column", typeof(string));
dt.Columns.Add("recurrence", typeof(string));
dt.Columns.Add("resourceid", typeof(int));
DataRow dr;
dr = dt.NewRow();
dr["id"] = 309;
dr["start"] = Convert.ToDateTime("2012-11-08 07:00");
dr["end"] = Convert.ToDateTime("2012-11-08 12:00");
dr["name"] = "Recurring";
dr["resourceid"] = 20;
dr["recurrence"] = "MzA5#2#C#T#5#RCAqICo=";
//dr["recurrence"] = RecurrenceRule.FromDateTime("3", (DateTime) dr["start"]).Daily().Times(5).Encode();
dt.Rows.Add(dr);
return dt;
}
}