ParentKey: Integer;
The ParentKey property determines parent task key.
Parent task is used to merge child tasks and set of other parent tasks within the meaning. The execution period for parent task is built when the first child task execution starts till the last child task ends.
NOTE. Parent task is not used as predecessor task for own child tasks on setting the links between them.
To execute the example, add a link to the ProjectPlanning system assembly.
Sub UserProc;
Var
Project: IPrjProject;
Tasks: IPrjTaskCollection;
Task: IPrjTask;
Depend: IPrjTaskDependency;
Fact, FPeriod: IPrjTaskPeriod;
i: Integer;
Begin
Project := New PrjProject.Create;
// Get collection of project tasks
Tasks := Project.Tasks;
// Add the first task (parent)
Task := Tasks.Add;
Task.Key := 1;
Task.Name := "№1";
// Set planned date of task start
Task.PlanPeriod.StartDate := DateTime.Parse("07.02.2020");
// Add the second task (child)
Task := Tasks.Add;
Task.Key := 2;
Task.Name := "№2";
Task.ParentKey := 1;
// Set actual period of task execution
Fact := Task.FactPeriod;
Fact.StartDate := DateTime.Parse("21.02.2020");
Fact.FinishDate := DateTime.Parse("28.02.2020");
// Add the third task (child)
Task := Tasks.Add;
Task.Key := 3;
Task.Name := "№3";
Task.ParentKey := 1;
// Set task duration
Task.PlanPeriod.Duration := 12;
// Set type of link with the second task
Depend := Task.Dependencies.Add;
Depend.PredecessorTaskKey := 2;
Depend.Type := PrjTaskDependencyType.StartToFinish;
// Run calculation
Project.Plan;
For i := 0 To Tasks.Count - 1 Do
Task := Tasks.Item(i);
FPeriod := Task.ForecastPeriod;
Debug.WriteLine("Task execution " + Task.Name + " from " +
FPeriod.StartDate.ToString + " to " + FPeriod.FinishDate.ToString +
" (duration: " + FPeriod.Duration.ToString + " days)");
End For;
End Sub UserProc;
After executing the example, the project will be calculated considering the specified conditions:
The first task is a parent for the second and third tasks.
The first task execution period includes execution period for the second and third tasks.
The forecasted execution period for the second task matches the specified actual period.
The third task end date depends on the second task start date.
The console displays the calculation result:
The first task execution from 09.02.2020 00:00:00 to 28.02.2020 00:00:00 (duration: 20 days)
The second task execution from 21.02.2020 00:00:00 to 28.02.2020 00:00:00 (duration: 8 days)
The third task execution from 09.02.2020 00:00:00 to 20.02.2020 00:00:00 (duration: 12 days)
See also: