RadiantQ WPF Gantt
Task Level Schedules
Previous Topic  Next Topic 

Tasks with custom schedules


Special tasks could occasionally be associated with a custom schedule that dictates when (time of the day and working days) the task could be performed. This could be different from the overall project schedule.


Tasks with custom schedules will then follow these rules:

- Start and End times will be restricted to fall within this schedule.

- When rendered within a "day header", the beginning of the time unit will be the start of the schedule in that day and end of the time unit will be the end of the schedule in that day.


Your task objects could contain information about their custom schedules that can be bound to the gantt. This information could be in any format, but should eventually be converted to a WorkTimeSchedule instance.


a)

There are some built-in utilities that can convert a string representation of this custom schedule (in a predefined format) into a WorkTimeSchedule instance.


So, for example, if your tasks are defined as follows with a "Schedule" property indicating it's custom schedule:


this.ganttControl.ItemsSource = new ObservableCollection<CustomTask>

            {

                new CustomTask { TaskName = "Summary 1",Schedule = String.Empty, TaskID = "9", SortOrder=1, StartTime = TimeComputingUtils.ToUtcKind(DateTime.Today),RequiredEffort=TimeSpan.Parse("08:00:00"), Description = "Description of Task 1"},

                new CustomTask { TaskName = "Task 1", IndentLevel = 1, Schedule = String.Empty, TaskID = "10", SortOrder=2,PredecessorIndices="9", StartTime = TimeComputingUtils.ToUtcKind(DateTime.Today),RequiredEffort=TimeSpan.Parse("16:00:00"), Description = "Description of Task 2"},

                new CustomTask { TaskName = "Task 2", IndentLevel = 1, ScheduleDesc="9AM to 5PM, Sun to Thu", Schedule = "sun 09:00:00 17:00:00; mon 09:00:00 17:00:00; tue 09:00:00 17:00:00; wed 09:00:00 17:00:00; thu 09:00:00 17:00:00;",  TaskID = "11", SortOrder=3,StartTime = TimeComputingUtils.ToUtcKind(DateTime.Today),RequiredEffort = TimeSpan.Parse("12:30:00"), CompletedEffort=TimeSpan.Parse("5:00:00"), Description = "Description of Task 3"},

                new CustomTask { TaskName = "Summary 2", ScheduleDesc="8AM to 4PM, Mon to Fri", Schedule = "mon 08:00:00 16:00:00; tue 08:00:00 16:00:00; wed 08:00:00 16:00:00; thu 08:00:00 16:00:00; fri 08:00:00 16:00:00;",TaskID = "12",SortOrder=4, StartTime = TimeComputingUtils.ToUtcKind(DateTime.Today),AssignedResources="Resource 1 , Resource 2",RequiredEffort = TimeSpan.Parse("08:00:00"), CompletedEffort=TimeSpan.Parse("2:00:00"), Description = "Description of Task 3/Child Task 1"},

                new CustomTask { TaskName = "Task 3", ScheduleDesc="1PM to 5PM, Tue to Sat", Schedule = "tue 13:00:00 17:00:00; wed 13:00:00 17:00:00; thu 13:00:00 17:00:00; fri 13:00:00 17:00:00; sat 13:00:00 17:00:00;",TaskID = "13", IndentLevel = 1, SortOrder=5,StartTime = TimeComputingUtils.ToUtcKind(DateTime.Today), RequiredEffort=TimeSpan.Parse("16:00:00"), CompletedEffort=TimeSpan.Parse("4:00:00"), PredecessorIndices="12+8", Description = "Description of Task 3/Child Task 2"},

                new CustomTask { TaskName = "Task 4", ScheduleDesc="7AM to 3PM, Mon, Wed, Fri", AssignedResources="Resource 1 , Resource 2", Schedule = "mon 07:00:00 15:00:00; wed 07:00:00 15:00:00; fri 07:00:00 15:00:00;",TaskID = "14", IndentLevel = 1, SortOrder=6,StartTime = TimeComputingUtils.ToUtcKind(DateTime.Today), RequiredEffort = TimeSpan.Parse("08:00:00"), CompletedEffort=TimeSpan.Parse("4:00:00"), Description = "Description of Task 3/Child Task 1/Grand Child 1"}


            };


Then you can setup this binding in the GanttControl:


<Grid.Resources>

            <gantt:StringToWorkTimeScheduleConverter x:Key="stringToScheduleConverter"/>

</Grid.Resources>


        <gantt:GanttControl .........

                           ScheduleBinding="{Binding Schedule, Converter={StaticResource stringToScheduleConverter}}"

                         >


The gantt will then use this custom schedule for the tasks.


Tasks rendered to fit their schedules


This is illustrated in the Samples\ProjectGantt\Scheduling\TaskLevelSchedules sample.


b)

Alternatively if you have a property that exposes a WorkTimeSchedule instance, that can be directly bound to the gantt as follows:


new CustomTask { TaskName = "Task 4", ScheduleDesc=new WorkTimeSchedule("Custom Schedule", MainWindow.CustomScheduleForATask), AssignedResources="Resource 1 , Resource 2", Schedule = "mon 07:00:00 15:00:00; wed 07:00:00 15:00:00; fri 07:00:00 15:00:00;",TaskID = "14", IndentLevel = 1, SortOrder=6,StartTime = TimeComputingUtils.ToUtcKind(DateTime.Today), RequiredEffort = TimeSpan.Parse("08:00:00"), CompletedEffort=TimeSpan.Parse("4:00:00"), Description = "Description of Task 3/Child Task 1/Grand Child 1"}



// In your MainWindow:

        public static TimePeriodCollection CustomScheduleForATask(DateTime date)

        {

            // You can choose to take into account holidays here.


            // For better performance cache the intervals for dates instead of creating a new collection every time.

            if ((date.DayOfWeek != DayOfWeek.Saturday) && (date.DayOfWeek != DayOfWeek.Sunday) && (date.DayOfWeek != DayOfWeek.Friday))

            {

                TimePeriodCollection intervals = new TimePeriodCollection();

                intervals.Add(new TimePeriod(date.AddHours(8.0), TimeSpan.FromHours(8)));

                return intervals;

            }

            else

            {

                return null;

            }

        }


<gantt:GanttControl .........

                           ScheduleBinding="{Binding Schedule}"

                         >




� RadiantQ 2009 - 2019. All Rights Reserved.