Handling Task Constraints
Working with Constraints
The ConstraintDate and ConstraintType properties are exposed by the Task class to handle constraints:
- ConstraintDate accepts and returns the Date data type.
- ConstraintType accepts and returns one of the values of the ConstraintType enumeration.
Setting Constraints in Microsoft Project
To set constraints in Microsoft Project:
- On the View menu, select More Views and then Task Entry Form.
- Double click a task on the Task Entry Form.
- Select the Advance tab.
- Set a constraint by selecting an option from the Constraint type list and a date for the Constraint date list.
Setting constraints in Microsoft Project
Setting Constraints with Aspose.Tasks
The constraint date is NA when the constraint type is As Soon As Possible or As Late As Possible. For date values equal to NA, Aspose.Tasks uses the value “1/1/2000” in the evaluation version, and DateTime.MinValue for the licensed product. In the below case, we take a source project file as an input and apply different types of constraints on various tasks in each case. The following code samples show the application of different Constraint types and the accompanied snapshot of the result for each case.
The input file
The code samples below set the constraint type set to Start No Earlier Than.
Output file with Start No Earlier Than constraint
The code samples below set the constraint type set to Finish No Earlier Than.
Output file showing Finish No Earlier Than constraint
The code samples below set the constraint type set to Must Start On.
Output file showing Must Start On constraint
The code samples below set the constraint type set to As Late As Possible.
Output file showing As Late As Possible constraint
The code sample below shows the constraint type set to Must Finish On.
Output file showing Must Finish On constraint
This code sample displays any constraints found when traversing the tasks in the project to a command window.