search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Conflict detector ignore Recurring Events event in the DataTable?

Asked by Anonymous
7 years ago.

The Conflict detector ignores the Recurring events in the Table.

"Shift Scheduling Tutorial".
http://code.daypilot.org/file/download/wysc7wviangzhhsa4i5wstozou/TutorialShiftScheduling.v3.zip

Let say I have a event for Agent John on 11/4 Sunday, 11AM-4PM. Another Event for Agent John on 11/5 Monday,11AM-4PM.

Then I edit the " 11/4 Sunday" event, so that repeat daily for 1 time. Now, there 're conflict schedule for Agent John on 11/5 Monday.

The algorithm in "Shift Scheduling Tutorial" has expanded recurrent event, so expanded recurrent event are inside DataTable for conflict detection.

I have also look at the DataTable, and it did have the three events in there, in which there are conflict
schedule on 11/5 Monday

But somehow conflict detection is ignoring it and return zero for detector.Count.

If the conflict event are not recurring events, then the conflict detection works perfectly.

The conflict events are stored in the Table, but conflict detector ignores it if it is a recurring event.

I tried it with "Shift Scheduling Tutorial". It did the same thing.
See picture for detail.

Is there any way to make the Conflict detector see the recurrence event in the DataTable?

Answer posted by Dan Letecky [DayPilot]
7 years ago.

The ConflictDetector API has been extended to handle recurring events in 7.1 release.

http://www.daypilot.org/daypilot-pro-for-asp-net-webforms-7-1.html

It's not used in the tutorial yet (the tutorial has been released prior to 7.1).

Example:

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=");

        GridView1.DataSource = new ConflictDetector()
            .Add(normal(), "start", "end", null)
            .AddRecurring(recurring(), "start", "end", null, "recurrence", "id", "master")
            .ForRange(DateTime.Today, DateTime.Today.AddYears(1))
            .List;

        DataBind();
    }


    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));

        DataRow dr;

        dr = dt.NewRow();
        dr["id"] = 1;
        dr["start"] = Convert.ToDateTime("11:00");
        dr["end"] = Convert.ToDateTime("12:00");
        dr["name"] = "Event 1";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr["id"] = 2;
        dr["start"] = Convert.ToDateTime("11:00");
        dr["end"] = Convert.ToDateTime("12:00");
        dr["name"] = "Event 2";
        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));

        DataRow dr;

        dr = dt.NewRow();
        dr["id"] = 309;
        dr["start"] = Convert.ToDateTime("11:00").AddDays(-3);
        dr["end"] = Convert.ToDateTime("12:00").AddDays(-3);
        dr["name"] = "Recurring";
        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;
    }
}
This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.