General Programming Principles Using the ProjectPlanning Assembly

The ProjectPlanning assembly is used to execute network scheduling.

The network scheduling execution process consists of the following stages:

At the project creation stage, the project implementation model is created based on calendar plan. At the project tasks adding stage, the structure of linked tasks, their duration and execution periods by calendar plan are specified. At the calculation stage, forecasted task execution time and optimization of project duration are determined.

To create a project, use the PrjProject.Create method.

To add a task, use the IPrjTaskCollection.Add method.

To calculate forecasted task execution time, use the IPrjProject.Plan method.

Example

See below the example how to create a project, add tasks and calculate forecasted task execution time.

To execute the example, add a link to the ProjectPlanning system assembly.

Sub UserProc;
Var
    Project: IPrjProject;
    Calendar: IPrjCalendarOptions;
    DTar: Array 
Of DateTime;
    Tasks: IPrjTaskCollection;
    Task: IPrjTask;
    Depend: IPrjTaskDependency;
    FPeriod: IPrjTaskPeriod;
    i: Integer;
Begin
    Project := 
New PrjProject.Create;
    
// Set project start date
    Project.StartDate := DateTime.Parse("20.02.2020");
    Project.UseStartDate := 
True;
    
// Get calendar settings
    Calendar := Project.CalendarOptions;
    Calendar.IncludeWeekend := 
False;
    // Set two holidays
    DTar := New DateTime[2];
    DTar[
0] := DateTime.Parse("23.02.2020");
    DTar[
1] := DateTime.Parse("08.03.2020");
    Calendar.ExcludedDates := DTar;
    
// Get collection of project tasks
    Tasks := Project.Tasks;
    
// Add the first task
    Task := Tasks.Add;
    Task.Key := 
1;
    Task.Name := 
"№1";
    Task.PlanPeriod.Duration := 
8;
    // Add the second task
    Task := Tasks.Add;
    Task.Key := 
2;
    Task.Name := 
"№2";
    Task.PlanPeriod.Duration := 
10;
    Depend := Task.Dependencies.Add;
    Depend.PredecessorTaskKey := 
3;
    Depend.Type := PrjTaskDependencyType.FinishToFinish;
    
// Add the third task
    Task := Tasks.Add;
    Task.Key := 
3;
    Task.Name := 
"№3";
    Task.PlanPeriod.Duration := 
12;
    Depend := Task.Dependencies.Add;
    Depend.PredecessorTaskKey := 
1;
    Depend.Type := PrjTaskDependencyType.FinishToStart;
    
// Run calculation
    Project.Plan;
    Debug.WriteLine(
"Project start date: " + Project.StartDate.ToString);
    
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;
    Debug.WriteLine(
"Forecasted project end date: " + Project.EndDate.ToString);
End Sub UserProc;

After executing the example, the project will be calculated considering the specified conditions:

The console displays the calculation result:

Project start date: 20.02.2020 00:00:00

  The first task execution from 20.02.2020 00:00:00 to 02.03.2020 00:00:00 (duration: 8 days)

  The second task execution from 05.03.2020 00:00:00 to 18.03.2020 00:00:00 (duration: 10 days)

  The third task execution from 03.03.2020 00:00:00 to 18.03.2020 00:00:00 (duration: 12 days)

The forecasted project end date: 18.03.2020 00:00:00

See also:

About the ProjectPlanning Assembly