Version

Task Duration Adjustment

The value of the TaskWorkingHourMode property determines whether non-working hours/non-working days should be included in the duration for a task, when calculating its end-date time. When set to its default value, ‘Manual’, non-working hours and non-working days are not skipped. When set to ‘AutoAdjust’, non-working hours and non-working days are skipped and the end-date time is pushed to the closest working hour or working day. For example, a task set up with ‘AutoAdjust’ that starts on a Friday and has duration of two days would end on Monday rather than on Saturday (assuming that Saturday and Sunday are both designated as non-working days).

When the end user expresses the unit of time for duration in days, with the TaskWorkingHourMode property set to ‘AutoAdjust’, the effective duration is “converted” to working hours, with the length of the workday. Setting the duration to a value of (for example) 2 days with ‘8hours’ of working hours results in a conversion to (2 x 8hours) = 16hours, and the effective duration resolves to 16 hours. Since tasks skip over non-working hours when determining the end-date time of the task, the task spans two working days.

When the end user expresses the duration value in hours or minutes the duration is interpreted as a literal assignment of the working hours. For example if the duration value is set to ’48 hours’ the task spans 6 working days, with ‘8 hours’ working hours per day.

The unit of time for the duration can be set using the SetDuration method, which accepts a TimeSpanFormat parameter.

A TaskDurationWorkingTimePerDay property is exposed by the UltraCalendarInfo object, which provides a way to specify the number of working hours in a workday.

The CalendarDateSettings collection object provides ways to customize the workday status and working hours for a particular date.

The following code example shows you how the duration accounts for non-working days and non-working hours and the end-date time is adjusted accordingly.

In Visual Basic:

' Create a Project and add Tasks to it
CreateTasks()
' Set the TaskWorkingHourMode to AutoAdjust to make the duration account for non-working hours
Me.ultraCalendarInfo1.TaskWorkingHourMode = Infragistics.Win.UltraWinSchedule.TaskWorkingHourMode.AutoAdjust
' Set the TaskDurationWorkingTimePerDay property to define the length of the workday as 8 hours.
Me.ultraCalendarInfo1.TaskDurationWorkingTimePerDay = TimeSpan.FromHours(8)
Dim enumValues As Array = [Enum].GetValues(GetType(System.DayOfWeek))
For Each enumValue As Object In enumValues
Dim dayOfWeek As DayOfWeekEnum = DirectCast(enumValue, DayOfWeekEnum)
' Add a time range for 8AM to 12PM for the morning part of the workday.
Dim morning As New TimeRange(TimeSpan.FromHours(8), TimeSpan.FromHours(12))
    Me.ultraCalendarInfo1.DaysOfWeek(dayOfWeek).WorkingHours.Add(morning)
' Add a time range for 1PM to 5PM for the afternoon part of the workday.
Dim afternoon As New TimeRange(TimeSpan.FromHours(13), TimeSpan.FromHours(17))
    Me.ultraCalendarInfo1.DaysOfWeek(dayOfWeek).WorkingHours.Add(afternoon)
Next
' Assign UltraCalendarInfo to the GanttView calendarInfo property
Me.ultraGanttView1.CalendarInfo = Me.ultraCalendarInfo1
' Assign the new Project to GanttView.
Me.ultraGanttView1.Project = Me.ultraGanttView1.CalendarInfo.Projects(1)

In C#:

using Infragistics.Win.UltraWinSchedule;
...
// Create a Project and add Tasks to it
CreateTasks();
// Set the TaskWorkingHourMode to AutoAdjust to make the duration account for non-working hours
this.ultraCalendarInfo1.TaskWorkingHourMode = Infragistics.Win.UltraWinSchedule.TaskWorkingHourMode.AutoAdjust;
//  Set the TaskDurationWorkingTimePerDay property to define the length of the workday as 8 hours.
this.ultraCalendarInfo1.TaskDurationWorkingTimePerDay = TimeSpan.FromHours(8);
Array enumValues = Enum.GetValues(typeof(System.DayOfWeek));
foreach (object enumValue in enumValues)
{
DayOfWeekEnum dayOfWeek = (DayOfWeekEnum)enumValue;
//  Add a time range for 8AM to 12PM for the morning part of the workday.
TimeRange morning = new TimeRange(TimeSpan.FromHours(8), TimeSpan.FromHours(12));
this.ultraCalendarInfo1.DaysOfWeek[dayOfWeek].WorkingHours.Add(morning);
//  Add a time range for 1PM to 5PM for the afternoon part of the workday.
TimeRange afternoon = new TimeRange(TimeSpan.FromHours(13), TimeSpan.FromHours(17));
this.ultraCalendarInfo1.DaysOfWeek[dayOfWeek].WorkingHours.Add(afternoon);
}
// Assign UltraCalendarInfo to the GanttView calendarInfo property
this.ultraGanttView1.CalendarInfo = this.ultraCalendarInfo1;
// Assign the new Project to GanttView.
this.ultraGanttView1.Project = this.ultraGanttView1.CalendarInfo.Projects[1];

The following code creates a Project and adds Tasks to it. Note that the unit of time assigned for the duration varies for each task.

In Visual Basic:

Private Sub CreateTasks()
    ' Create a new Project other than the Unassigned Project
    Dim quarterlyProject As Project = Me.ultraCalendarInfo1.Projects.Add("QuartlerlyProject", DateTime.Today)
    quarterlyProject.Key = "projkey1"
    ' Create a Summary or Parent Task
    Dim requirementsTask As Task = Me.ultraCalendarInfo1.Tasks.Add(DateTime.Today, TimeSpan.FromDays(5), "Requirements", "projkey1")
    ' Create a child task
    Dim budgetTask As Task = requirementsTask.Tasks.Add(DateTime.Today, TimeSpan.FromDays(2), "Budget Analysis")
    Dim teamTask As Task = requirementsTask.Tasks.Add(DateTime.Today.AddDays(3), TimeSpan.FromDays(3), Infragistics.Win.TimeSpanFormat.Days, "Team Allocation")
    ' Create a Summary or Parent Task
    Dim implemetationTask As Task = Me.ultraCalendarInfo1.Tasks.Add(DateTime.Today.AddDays(5), TimeSpan.FromDays(1), "Implementation", "projkey1")
    ' Create a child task
    Dim frontendTask As Task = implemetationTask.Tasks.Add(DateTime.Today.AddDays(5), TimeSpan.FromDays(2), Infragistics.Win.TimeSpanFormat.Hours, "GUI Design")
End Sub

In C#:

private void CreateTasks()
{
// Create a new Project other than the Unassigned Project
Project quarterlyProject = this.ultraCalendarInfo1.Projects.Add("QuartlerlyProject", DateTime.Today);
quarterlyProject.Key = "projkey1";
// Create a Summary or Parent Task
Task requirementsTask = this.ultraCalendarInfo1.Tasks.Add(DateTime.Today, TimeSpan.FromDays(5), "Requirements", "projkey1");
// Create a child task
Task budgetTask = requirementsTask.Tasks.Add(DateTime.Today, TimeSpan.FromDays(2), "Budget Analysis");
Task teamTask = requirementsTask.Tasks.Add(DateTime.Today.AddDays(3), TimeSpan.FromDays(3), Infragistics.Win.TimeSpanFormat.Days, "Team Allocation");
// Create a Summary or Parent Task
Task implemetationTask = this.ultraCalendarInfo1.Tasks.Add(DateTime.Today.AddDays(5), TimeSpan.FromDays(1), "Implementation", "projkey1");
// Create a child task
Task frontendTask = implemetationTask.Tasks.Add(DateTime.Today.AddDays(5), TimeSpan.FromDays(2), Infragistics.Win.TimeSpanFormat.Hours, "GUI Design");
}