ResourceAssignment.SplitTask

ResourceAssignment.SplitTask method

Splits task into two parts.

public void SplitTask(DateTime start, DateTime finish, Calendar calendar)
ParameterTypeDescription
startDateTimeThe beginning of work interruption to split based on.
finishDateTimeThe end of work interruption to split based on.
calendarCalendarThe calendar to split based on.

Exceptions

exceptioncondition
ArgumentOutOfRangeExceptionThrows when start date is less than the assignment start date.
ArgumentOutOfRangeExceptionThrows when finish date is greater than the assignment finish date.

Examples

Shows how to add a split for a task.

var project = new Project();

// Get a standard calendar
var calendar = project.Get(Prj.Calendar);

// Set project's calendar settings
project.Set(Prj.StartDate, new DateTime(2000, 3, 15, 8, 0, 0));
project.Set(Prj.FinishDate, new DateTime(2000, 4, 21, 17, 0, 0));

// Add a new task to root task
var task = project.RootTask.Children.Add("Task1");
task.Set(Tsk.Duration, project.GetDuration(3));

// Create a new resource assignment and generate timephased data
var assignment = project.ResourceAssignments.Add(task, null);
assignment.TimephasedDataFromTaskDuration(calendar);

// Split the task into 3 parts.
// Provide start date and finish date arguments to SplitTask method which will be used for split
assignment.SplitTask(new DateTime(2000, 3, 16, 8, 0, 0), new DateTime(2000, 3, 16, 17, 0, 0), calendar);
assignment.SplitTask(new DateTime(2000, 3, 18, 8, 0, 0), new DateTime(2000, 3, 18, 17, 0, 0), calendar);
assignment.Set(Asn.WorkContour, WorkContourType.Contoured);

project.Save(OutDir + "CreateSplitTasks_out.xml", SaveFileFormat.Xml);

See Also