IPrjProject.Contradictions

Syntax

Contradictions: IPrjContradictionsCollection;

Description

The Contradictions property returns the collection of task completion time contradictions.

Example

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

Sub UserProc;
Var
    Project: IPrjProject;
    Tasks: IPrjTaskCollection;
    Task: IPrjTask;
    Depend: IPrjTaskDependency;
    Plan, FPeriod: IPrjTaskPeriod;
    i: Integer;
    Contradiction: IPrjContradiction;
    Collection: IPrjContradictionsCollection;
    Dependency: String;
Begin
    Project := 
New PrjProject.Create;
    
// Get collection of project tasks
    Tasks := Project.Tasks;
    
// Add the first task
    Task := Project.Tasks.Add;
    Task.Key := 
1;
    Task.Name := 
"Task №1";
    
// Set the scheduled task execution period
    Plan := Task.PlanPeriod;
    Plan.Duration := 
3;
    Plan.StartDate := DateTime.Parse(
"08.02.2020");
    Plan.FinishDate := DateTime.Parse(
"10.02.2020");
    
// Set a time constraint for task execution
    Task.ConstraintType := PrjTaskConstraintType.MustFinishOn;
    Task.ConstraintDate := DateTime.Parse(
"10.02.2020");
    
// Add the second task
    Task := Project.Tasks.Add;
    Task.Key := 
2;
    Task.Name := 
"Task №2";
    
// Set the scheduled task execution period
    Plan := Task.PlanPeriod;
    Plan.Duration := 
3;
    Plan.StartDate := DateTime.Parse(
"11.02.2020");
    Plan.FinishDate := DateTime.Parse(
"13.02.2020");
    
// Set a time constraint for task execution
    Task.ConstraintType := PrjTaskConstraintType.MustStartOn;
    Task.ConstraintDate := DateTime.Parse(
"17.02.2020");
    
// Set link between tasks
    Depend := Task.Dependencies.Add;
    Depend.PredecessorTaskKey := 
1;
    Depend.Type := PrjTaskDependencyType.FinishToStart;
    
// Run calculation
    Project.Plan;
    
// Display planned and forecasted periods of tasks execution to the console
    For i := 0 To Tasks.Count - 1 Do
        Task := Tasks.Item(i);
        FPeriod := Task.ForecastPeriod;
        Plan := Task.PlanPeriod;
        Debug.WriteLine(Task.Name + 
":");
        Debug.WriteLine(
"  Plan: " + Plan.StartDate.ToString + " - " + Plan.FinishDate.ToString);
        Debug.WriteLine(
"  Forecast: " + FPeriod.StartDate.ToString + " - " + FPeriod.FinishDate.ToString);
    
End For;
    Debug.WriteLine(
"=========");
    
// Determine contradiction in task execution period
    Collection := Project.Contradictions;
    
If Collection.Count <> 0 Then
        
For i := 0 To Project.Contradictions.Count - 1 Do
            Contradiction := Collection.Item(i);
            
Select Case  Contradiction.Dependency.Type As Integer
                
Case 0: Dependency := "end-start";
                
Case 1: Dependency := "start-start";
                
Case 2:  Dependency := "end-end";
                
Case 3: Dependency := "start-end";
            
End Select;
            Debug.WriteLine(
"Predecessor task: " + Contradiction.Predecessor.Name);
            Debug.WriteLine(
"Link between tasks: " + Dependency);
            Debug.WriteLine(
"Linked task: " + Contradiction.Follower.Name);
            Debug.WriteLine(
"Period contradiction: " + Contradiction.Difference.ToString + " days");
        
End For;
    
End If;
End Sub UserProc;

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

The console displays scheduled and forecasted task execution periods and parameters for period contradiction:

Task 1:

  Plan: 08.02.2020 00:00:00 - 10.02.2020 00:00:00

  Forecast: 08.02.2020 00:00:00 - 10.02.2020 00:00:00

Task 2:

  Plan: 11.02.2020 00:00:00 - 13.02.2020 00:00:00

  Forecast: 17.02.2020 00:00:00 - 19.02.2020 00:00:00

=========

Predecessor task: Task 1

Link between tasks: start-end

Linked task: Task 2

Period contradiction: 6 days

See also:

IPrjProject