Class Task

Task class

Represents a task in a project.

public class Task : IEquatable<Task>

Properties

NameDescription
ActivityId { get; set; }Represents activity id field - a task’s unique identifier used by Primavera. (only applicable to Primavera projects).
ActualCost { get; set; }Gets or sets a value of ActualCost.
ActualDuration { get; set; }Gets or sets a value of ActualDuration.
ActualFinish { get; set; }Gets or sets a value of ActualFinish.
ActualOvertimeCost { get; set; }Gets or sets a value of ActualOvertimeCost.
ActualOvertimeWork { get; set; }Gets or sets a value of ActualOvertimeWork.
ActualOvertimeWorkProtected { get; set; }Gets or sets a value of ActualOvertimeWorkProtected.
ActualStart { get; set; }Gets or sets a value of ActualStart.
ActualWork { get; set; }Gets or sets a value of ActualWork.
ActualWorkProtected { get; set; }Gets or sets a value of ActualWorkProtected.
ACWP { get; set; }Gets or sets a value of ACWP.
Assignments { get; }Gets a collection of resource assignments for this object.
Baselines { get; set; }Gets or sets the collection of baseline values of the task.
BCWP { get; set; }Gets or sets a value of BCWP.
BCWS { get; set; }Gets or sets a value of BCWS.
BudgetCost { get; set; }Gets or sets a value of BudgetCost.
BudgetWork { get; set; }Gets or sets a value of BudgetWork.
Calendar { get; set; }Gets or sets a value of Calendar.
Children { get; }Gets a child task collection of this object. TaskCollection object which represents children tasks.
CommitmentFinish { get; set; }Gets or sets a value of CommitmentFinish.
CommitmentStart { get; set; }Gets or sets a value of CommitmentStart.
CommitmentType { get; set; }Gets or sets a value of CommitmentType.
ConstraintDate { get; set; }Gets or sets a value of ConstraintDate.
ConstraintType { get; set; }Gets or sets a value of ConstraintType.
Contact { get; set; }Gets or sets a value of Contact.
Cost { get; set; }Gets or sets a value of Cost.
CostVariance { get; set; }Gets or sets a value of CostVariance.
Created { get; set; }Gets or sets a value of Created.
CV { get; set; }Gets or sets a value of CV.
Deadline { get; set; }Gets or sets a value of Deadline.
DisplayAsSummary { get; set; }Gets or sets a value indicating whether DisplayAsSummary is set or not.
DisplayOnTimeline { get; set; }Gets or sets a value indicating whether DisplayOnTimeline is set or not.
Duration { get; set; }Gets or sets a value of Duration.
DurationText { get; set; }Gets or sets a value of DurationText.
DurationVariance { get; set; }Gets or sets a value of DurationVariance.
EarlyFinish { get; set; }Gets or sets a value of EarlyFinish.
EarlyStart { get; set; }Gets or sets a value of EarlyStart.
EarnedValueMethod { get; set; }Gets or sets a value of EarnedValueMethod.
ExtendedAttributes { get; }Gets ExtendedAttributeCollection object containing the values of an extended attribute.
ExternalId { get; set; }Gets or sets a value of ExternalId.
ExternalTaskProject { get; set; }Gets or sets a value of ExternalTaskProject.
ExternalUid { get; set; }Gets or set the external task’s Unique identifier when the task is external.
Finish { get; set; }Gets or sets a value of Finish.
FinishSlack { get; set; }Gets or sets a value of FinishSlack.
FinishText { get; set; }Gets or sets a value of FinishText.
FinishVariance { get; set; }Gets or sets a value of FinishVariance.
FixedCost { get; set; }Gets or sets a value of FixedCost.
FixedCostAccrual { get; set; }Gets or sets a value of FixedCostAccrual.
FreeSlack { get; set; }Gets or sets a value of FreeSlack.
Guid { get; set; }Gets or sets a value of Guid.
HideBar { get; set; }Gets or sets a value indicating whether HideBar is set or not.
Hyperlink { get; set; }Gets or sets the title or explanatory text for a hyperlink associated with a task.
HyperlinkAddress { get; set; }Gets or sets the address for a hyperlink associated with a task.
HyperlinkSubAddress { get; set; }Gets or sets the specific location in a document in a hyperlink associated with a task.
Id { get; set; }Gets or sets a value of Id.
IgnoreResourceCalendar { get; set; }Gets or sets a value indicating whether IgnoreResourceCalendar is set or not.
IgnoreWarnings { get; set; }Gets or sets a value indicating whether IgnoreWarnings is set or not.
IsActive { get; set; }Gets or sets a value indicating whether IsActive is set or not.
IsCritical { get; set; }Gets or sets a value indicating whether IsCritical is set or not.
IsEffortDriven { get; set; }Gets or sets a value indicating whether IsEffortDriven is set or not.
IsEstimated { get; set; }Gets or sets a value indicating whether IsEstimated is set or not.
IsExpanded { get; set; }Gets or sets a value indicating whether IsExpanded is set or not.
IsExternalTask { get; set; }Gets or sets a value indicating whether IsExternalTask is set or not.
IsManual { get; set; }Gets or sets a value indicating whether IsManual is set or not.
IsMarked { get; set; }Gets or sets a value indicating whether IsMarked is set or not.
IsMilestone { get; set; }Gets or sets a value indicating whether IsMilestone is set or not.
IsNull { get; set; }Gets or sets a value indicating whether IsNull is set or not.
IsOverallocated { get; set; }Gets or sets a value indicating whether IsOverallocated is set or not.
IsPublished { get; set; }Gets or sets a value indicating whether IsPublished is set or not.
IsRecurring { get; set; }Gets or sets a value indicating whether IsRecurring is set or not.
IsResumeValid { get; set; }Gets or sets a value indicating whether IsResumeValid is set or not.
IsRollup { get; set; }Gets or sets a value indicating whether IsRollup is set or not.
IsSubproject { get; set; }Gets or sets a value indicating whether IsSubproject is set or not.
IsSubprojectReadOnly { get; set; }Gets or sets a value indicating whether IsSubprojectReadOnly is set or not.
IsSummary { get; set; }Gets or sets a value indicating whether IsSummary is set or not.
LateFinish { get; set; }Gets or sets a value of LateFinish.
LateStart { get; set; }Gets or sets a value of LateStart.
LevelAssignments { get; set; }Gets or sets a value indicating whether LevelAssignments is set or not.
LevelingCanSplit { get; set; }Gets or sets a value indicating whether LevelingCanSplit is set or not.
LevelingDelay { get; set; }Gets or sets a value of LevelingDelay.
ManualDuration { get; set; }Gets or sets a value of ManualDuration.
ManualFinish { get; set; }Gets or sets a value of ManualFinish.
ManualStart { get; set; }Gets or sets a value of ManualStart.
Name { get; set; }Gets or sets a value of Name.
NotesRTF { get; set; }Gets or sets a value of NotesRTF.
NotesText { get; set; }Gets or sets a value of NotesText.
OutlineCodes { get; set; }Gets or sets OutlineCodeCollection object.
OutlineLevel { get; set; }Gets or sets a value of OutlineLevel.
OutlineNumber { get; set; }Gets or sets a value of OutlineNumber.
OvertimeCost { get; set; }Gets or sets a value of OvertimeCost.
OvertimeWork { get; set; }Gets or sets a value of OvertimeWork.
ParentProject { get; }Gets the parent project of a task.
ParentTask { get; }Gets the parent task of a task.
PercentComplete { get; set; }Gets or sets a value of PercentComplete.
PercentWorkComplete { get; set; }Gets or sets a value of PercentWorkComplete.
PhysicalPercentComplete { get; set; }Gets or sets a value of PhysicalPercentComplete.
Predecessors { get; }Gets a TaskCollection object which contains all predecessors of this Task object.
PreleveledFinish { get; set; }Gets or sets a value of PreleveledFinish.
PreleveledStart { get; set; }Gets or sets a value of PreleveledStart.
PrimaveraProperties { get; }Gets an object containing Primavera-specific properties for a task read from Primavera file.
Priority { get; set; }Gets or sets a value of Priority.
RecurringInfo { get; }Gets the instance of RecurringTaskInfo class for the task which is a recurring task; if the task is not a recurring one then returns null; The info for the instance of RecurringTaskInfo is present in mpp file format only.
RegularWork { get; set; }Gets or sets a value of RegularWork.
RemainingCost { get; set; }Gets or sets a value of RemainingCost.
RemainingDuration { get; set; }Gets or sets a value of RemainingDuration.
RemainingOvertimeCost { get; set; }Gets or sets a value of RemainingOvertimeCost.
RemainingOvertimeWork { get; set; }Gets or sets a value of RemainingOvertimeWork.
RemainingWork { get; set; }Gets or sets a value of RemainingWork.
Resume { get; set; }Gets or sets a value of Resume.
SplitParts { get; }Gets a SplitPart collection that represents the portions of a task.
Start { get; set; }Gets or sets a value of Start.
StartSlack { get; set; }Gets or sets a value of StartSlack.
StartText { get; set; }Gets or sets a value of StartText.
StartVariance { get; set; }Gets or sets a value of StartVariance.
Status { get; }Gets task status.
StatusManager { get; set; }Gets or sets a value of StatusManager.
Stop { get; set; }Gets or sets a value of Stop.
SubprojectName { get; set; }Gets or sets a value of SubprojectName.
Successors { get; }Gets a TaskCollection object which contains all successors of this Task object.
SV { get; set; }The earned value schedule variance, through the project status date. Schedule variance (SV) is the difference between the BCWP and the BCWS.
TimephasedData { get; set; }Gets or sets a TimephasedDataCollection object of this task. The time phased data block associated with a task.
TotalSlack { get; set; }Gets or sets a value of TotalSlack.
Type { get; set; }Gets or sets a value of Type.
Uid { get; set; }Gets or sets a value of Uid.
Warning { get; set; }Gets or sets a value indicating whether Warning is set or not.
WBS { get; set; }Gets or sets a value of WBS.
WBSLevel { get; set; }Gets or sets a value of WBSLevel.
Work { get; set; }Gets or sets a value of Work.
WorkVariance { get; set; }Gets or sets a value of WorkVariance.

Methods

NameDescription
Clone()Creates full copy of a task without subtasks.
Delete()Deletes a task from parent project tasks collection and all its assignments.
override Equals(object)Returns a value indicating whether this instance is equal to a specified object.
Equals(Task)Returns a value indicating whether this instance is equal to a specified task.
Get<T>(Key<T, TaskKey>)Returns the value to which the property is mapped in this container.
override GetHashCode()Returns a hash code value for this Task.
GetTimephasedData(DateTime, DateTime)Returns TimephasedDataCollection object with TimephasedData values within given start and end dates.
GetTimephasedData(DateTime, DateTime, TimephasedDataType)Returns TimephasedDataCollection object with TimephasedData values within given start and end dates of specified time-phased data type.
MoveToSibling(int)Moves the current task at the same Outline Level before a task with the specified Id. If ParentProject.CalculationMode is None user should invoke Project.Recalculate() after using this method (It will reschedule all project tasks (start/finish dates, sets early/late dates) and calculate the dependent fields such as slacks, work and cost fields, outline levels). If ParentProject.CalculationMode is Manual the method will calculate only task id, outline level and outline numbers automatically. If ParentProject.CalculationMode is Automatic the method reschedules all project’s tasks automatically (start/finish dates, sets early/late dates, calculates slacks, work and cost fields, recalculates ids and outline levels).
MoveToSibling(Task)Moves the current task at the same Outline Level before the specified task. If ParentProject.CalculationMode is None user should invoke Project.Recalculate() after using this method (It will reschedule all project tasks (start/finish dates, sets early/late dates) and calculate the dependent fields such as slacks, work and cost fields, outline levels). If ParentProject.CalculationMode is Manual the method will calculate only task id, outline level and outline numbers automatically. If ParentProject.CalculationMode is Automatic the method reschedules all project’s tasks automatically (start/finish dates, sets early/late dates, calculates slacks, work and cost fields, recalculates ids and outline levels).
OutlineIndent()Indents a task in the outline.
OutlineOutdent()Promotes a task in the outline.
SelectAllChildTasks()Recursively collects all child tasks of this task.
Set<T>(Key<T, TaskKey>, T)Maps the specified property to the specified value in this container.
override ToString()Returns short string representation of a task. The exact details of the representation are unspecified and subject to change.

Remarks

The Task is representing a one atomic chunk of work.

One can use Task to plan a project by creating tasks and assign appropriate resources onto them. Tasks in a project are organized as a rooted hierarchical tree structure, with a root task and subtrees of children tasks.

To build a tree of tasks one can use a specialized collection TaskCollection by accessing RootTask property e.g.:

Project project = new Project();

// add new tasks
Task task1 = project.RootTask.Children.Add(); // a parent task with empty name is added
Task childTask1 = task1.Children.Add("Child 1");
childTask1.Set(Tsk.Start, new DateTime(2020, 2, 12, 8, 0, 0))
childTask1.Set(Tsk.Duration, project.GetDuration(8, TimeUnitType.Hour));
childTask1.Set(Tsk.Finish, new DateTime(2020, 2, 12, 17, 0, 0));
Task childTask3 = task1.Children.Add("Child 3");
childTask3.Set(Tsk.Start, new DateTime(2020, 2, 13, 8, 0, 0))
childTask3.Set(Tsk.Duration, project.GetDuration(8, TimeUnitType.Hour));
childTask3.Set(Tsk.Finish, new DateTime(2020, 2, 13, 17, 0, 0));
Task childTask2 = task1.Children.Add("Child 2", 2); // inserts a task before the childTask3
childTask2.Set(Tsk.Start, new DateTime(2020, 2, 14, 8, 0, 0))
childTask2.Set(Tsk.Duration, project.GetDuration(8, TimeUnitType.Hour));
childTask2.Set(Tsk.Finish, new DateTime(2020, 2, 14, 17, 0, 0));

// save project in the one of available formats
project.Save("Filled project.xml", SaveFileFormat.MPP);

Examples

Shows how to add a task into a project.

var project = new Project();

var task = project.RootTask.Children.Add("Task1");
task.Set(Tsk.Start, new DateTime(2012, 8, 23, 8, 0, 0));
task.Set(Tsk.Duration, project.GetDuration(24, TimeUnitType.Hour));
task.Set(Tsk.ActualStart, new DateTime(2012, 8, 23, 8, 0, 0));

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

See Also