Project

Project class

Represents a project.

public class Project

Constructors

Name Description
Project() Initializes a new instance of the Project class.
Project(DbSettings) Initializes a new instance of the Project class to read data from a database which is specified by the instance of the DbSettings class.
Project(Stream) Initializes a new instance of the Project class from a stream.
Project(StreamReader) Initializes a new instance of the Project class from a StreamReader instance.
Project(string) Initializes a new instance of the Project class from a template (existent mpp or mpt file).
Project(Stream, LoadOptions) Initializes a new instance of the Project class from the Stream with the specified instance of the LoadOptions class.
Project(Stream, ParseErrorCallback) Initializes a new instance of the Project class from a template(existent mpp or mpt file).
Project(Stream, PrimaveraReadOptions) Initializes a new instance of the Project class from the Stream with the specified instance of the PrimaveraReadOptions class.
Project(Stream, string) Initializes a new instance of the Project class from a template(existent mpp or mpt file).
Project(string, LoadOptions) Initializes a new instance of the Project class from a template (existent mpp or mpt file) with the specified instance of the LoadOptions class.
Project(string, ParseErrorCallback) Initializes a new instance of the Project class from a template (existent mpp or mpt file).
Project(string, PrimaveraReadOptions) Initializes a new instance of the Project class from a template (existent MPP or MPT file) with the specified instance of the PrimaveraReadOptions class.
Project(string, string) Initializes a new instance of the Project class from a password protected template (existent mpp or mpt file).

Properties

Name Description
ActualsInSync { get; set; } Gets or sets a value indicating whether ActualsInSync is set or not.
AdminProject { get; set; } Gets or sets a value indicating whether AdminProject is set or not.
AreEditableActualCosts { get; set; } Gets or sets a value indicating whether AreEditableActualCosts is set or not.
Author { get; set; } Gets or sets a value of Author.
AutoAddNewResourcesAndTasks { get; set; } Gets or sets a value indicating whether AutoAddNewResourcesAndTasks is set or not.
Autolink { get; set; } Gets or sets a value indicating whether Autolink is set or not.
BaselineForEarnedValue { get; set; } Gets or sets a value of BaselineForEarnedValue.
BuiltInProps { get; } Gets project’s built-in properties collection.
CalculationMode { get; set; } Gets or sets calculation mode of a project. Can be one of the values of CalculationMode enumeration.
Calendar { get; set; } Gets or sets a value of Calendar.
Calendars { get; } Gets CalendarCollection object of this Project instance.
Category { get; set; } Gets or sets a value of Category.
Comments { get; set; } Gets or sets a value of Comments.
Company { get; set; } Gets or sets a value of Company.
CreationDate { get; set; } Gets or sets a value of CreationDate.
CriticalPath { get; } Gets a collection which contains a list of Critical tasks which comprise Critical Path of this project. This is an O(n) operation, where n is the number of tasks in the project.
CriticalSlackLimit { get; set; } Gets or sets a value of CriticalSlackLimit.
CurrencyCode { get; set; } Gets or sets a value of CurrencyCode.
CurrencyDigits { get; set; } Gets or sets a value of CurrencyDigits.
CurrencySymbol { get; set; } Gets or sets a value of CurrencySymbol.
CurrencySymbolPosition { get; set; } Gets or sets a value of CurrencySymbolPosition.
CurrentDate { get; set; } Gets or sets a value of CurrentDate.
CustomDateFormat { get; set; } Gets or sets a value of CustomDateFormat.
CustomProps { get; } Gets project’s custom properties collection.
DateFormat { get; set; } Gets or sets a value of DateFormat.
DaysPerMonth { get; set; } Gets or sets a value of DaysPerMonth.
DefaultFinishTime { get; set; } Gets or sets a value of DefaultFinishTime.
DefaultFixedCostAccrual { get; set; } Gets or sets a value of DefaultFixedCostAccrual.
DefaultOvertimeRate { get; set; } Gets or sets a value of DefaultOvertimeRate.
DefaultStandardRate { get; set; } Gets or sets a value of DefaultStandardRate.
DefaultStartTime { get; set; } Gets or sets a value of DefaultStartTime.
DefaultTaskEVMethod { get; set; } Gets or sets a value of DefaultTaskEVMethod.
DefaultTaskType { get; set; } Gets or sets a value of DefaultTaskType.
DefaultView { get; set; } Gets or sets default view of the project.
DefaultWeekWorkingDays { get; } Gets the instance of WeekDayCollection class which represents a collection of project default week working days and working times.
DisplayOptions { get; } Gets an instance of the ProjectDisplayOptions class.
DurationFormat { get; set; } Gets or sets a value of DurationFormat.
EarnedValueMethod { get; set; } Gets or sets a value of EarnedValueMethod.
ExtendedAttributes { get; } Gets ExtendedAttributeDefinitionCollection object. The collection of extended attribute (custom fields) definitions associated with a project.
ExtendedCreationDate { get; set; } Gets or sets a value of ExtendedCreationDate.
FinishDate { get; set; } Gets or sets a value of FinishDate.
FiscalYearStart { get; set; } Gets or sets a value indicating whether FiscalYearStart is set or not.
FyStartDate { get; set; } Gets or sets a value of FyStartDate.
Guid { get; set; } Gets or sets a value of Guid.
HonorConstraints { get; set; } Gets or sets a value indicating whether HonorConstraints is set or not.
HyperlinkBase { get; set; } Gets or sets a value of HyperlinkBase.
InsertedProjectsLikeSummary { get; set; } Gets or sets a value indicating whether InsertedProjectsLikeSummary is set or not.
KeepTaskOnNearestWorkingTimeWhenMadeAutoScheduled { get; set; } Gets or sets a value indicating whether KeepTaskOnNearestWorkingTimeWhenMadeAutoScheduled is set or not.
Keywords { get; set; } Gets or sets a value of Keywords.
LastAuthor { get; set; } Gets or sets a value of LastAuthor.
LastPrinted { get; set; } Gets or sets a value of LastPrinted.
LastSaved { get; set; } Gets or sets a value of LastSaved.
Manager { get; set; } Gets or sets a value of Manager.
MicrosoftProjectServerURL { get; set; } Gets or sets a value indicating whether MicrosoftProjectServerURL is set or not.
MinutesPerDay { get; set; } Gets or sets a value of MinutesPerDay.
MinutesPerWeek { get; set; } Gets or sets a value of MinutesPerWeek.
MoveCompletedEndsBack { get; set; } Gets or sets a value indicating whether MoveCompletedEndsBack is set or not.
MoveCompletedEndsForward { get; set; } Gets or sets a value indicating whether MoveCompletedEndsForward is set or not.
MoveRemainingStartsBack { get; set; } Gets or sets a value indicating whether MoveRemainingStartsBack is set or not.
MoveRemainingStartsForward { get; set; } Gets or sets a value indicating whether MoveRemainingStartsForward is set or not.
MultipleCriticalPaths { get; set; } Gets or sets a value indicating whether MultipleCriticalPaths is set or not.
Name { get; set; } Gets or sets a value of Name.
NewTasksAreManual { get; set; } Gets or sets a value indicating whether NewTasksAreManual is set or not.
NewTasksEffortDriven { get; set; } Gets or sets a value indicating whether NewTasksEffortDriven is set or not.
NewTasksEstimated { get; set; } Gets or sets a value indicating whether NewTasksEstimated is set or not.
NewTaskStartDate { get; set; } Gets or sets a value of NewTaskStartDate.
OleObjects { get; } Gets a collection containing the instances of the OleObject class which are linked or embedded to this project file. Available for mpp file format only. This collection is read-only except for ‘Clear’ operation.
OutlineCodes { get; } Gets OutlineCodeDefinitionCollection object. The collection of outline code definitions associated with a project.
ProjectExternallyEdited { get; set; } Gets or sets a value indicating whether ProjectExternallyEdited is set or not.
RemoveFileProperties { get; set; } Gets or sets a value indicating whether RemoveFileProperties is set or not.
ResourceAssignments { get; } Gets ResourceAssignmentCollection object.
ResourceFilters { get; } Gets all the resource-based filter definitions. ResourceFilters is a collection of Filter objects.
ResourceGroups { get; } Gets all of the resource-based group definitions. ResourceGroups is a collection of Group objects.
Resources { get; } Gets ResourceCollection object.
Revision { get; set; } Gets or sets a value of Revision.
RootTask { get; } Gets the root of the tree of tasks.
SaveVersion { get; set; } Gets or sets a value of SaveVersion.
ScheduleFromStart { get; set; } Gets or sets a value indicating whether ScheduleFromStart is set or not.
ShowProjectSummaryTask { get; set; } Gets or sets a value indicating whether ShowProjectSummaryTask is set or not.
SplitsInProgressTasks { get; set; } Gets or sets a value indicating whether SplitsInProgressTasks is set or not.
SpreadActualCost { get; set; } Gets or sets a value indicating whether SpreadActualCost is set or not.
SpreadPercentComplete { get; set; } Gets or sets a value indicating whether SpreadPercentComplete is set or not.
StartDate { get; set; } Gets or sets a value of StartDate.
StatusDate { get; set; } Gets or sets a value of StatusDate.
Subject { get; set; } Gets or sets a value of Subject.
Tables { get; } Gets a list of Table objects.
TaskFilters { get; } Gets all the task-based filter definitions. TaskFilters is a collection of Filter objects.
TaskGroups { get; } Gets all the task-based group definitions. TaskGroups is a collection of Group objects.
TaskLinks { get; } Gets TaskLinkCollection object.
TaskUpdatesResource { get; set; } Gets or sets a value indicating whether TaskUpdatesResource is set or not.
Template { get; set; } Gets or sets a value of Template.
TimescaleFinish { get; set; } Gets or sets a value of TimescaleFinish.
TimescaleStart { get; set; } Gets or sets a value of TimescaleStart.
Title { get; set; } Gets or sets a value of Title.
Uid { get; set; } Gets or sets a value of Uid.
UpdateManuallyScheduledTasksWhenEditingLinks { get; set; } Gets or sets a value indicating whether UpdateManuallyScheduledTasksWhenEditingLinks is set or not.
VbaProject { get; } Gets an instance of VbaProject class.
Views { get; } Gets a list of View objects.
WBSCodeDefinition { get; set; } Gets or sets WBS Code Definition for the project.
WeekStartDay { get; set; } Gets or sets a value of WeekStartDay.
WorkFormat { get; set; } Gets or sets a value of WorkFormat.

Methods

Name Description
CopyTo(Project) Copies project’s main data and properties to another project.
CopyTo(Project, CopyToOptions) Copies project’s main data and properties to another project.
EnumerateAllChildTasks() Recursively enumerates all project’s tasks including root task.
Get<T>(Key<T, PrjKey>) Returns the value to which the property is mapped in this container.
GetBaselineSaveTime(BaselineType) Returns the baseline save time.
GetDuration(double) Gets Duration object with the specified number of units and default duration format which is defined in project’s settings DurationFormat.
GetDuration(double, TimeUnitType) Gets Duration object with the specified number of TimeUnitType units.
GetDuration(TimeSpan, TimeUnitType) Gets Duration object with the specified TimeSpan value and specified TimeUnitType value.
GetPageCount() Returns page count for the project to be rendered using default Timescale(Days).
GetPageCount(PresentationFormat) Returns page count for the project to be rendered using default Timescale(Days) and given PresentationFormat
GetPageCount(SaveOptions) Returns page count for the project to be rendered using given SaveOptions.
GetPageCount(Timescale) Returns page count for the project to be rendered using given Timescale.
GetPageCount(PageSize, Timescale) Returns page count for the project to be rendered using given Timescale and PageSize.
GetPageCount(PresentationFormat, Timescale) Returns page count for the project to be rendered using given Timescale and PresentationFormat.
GetPageCount(PageSize, Timescale, DateTime, DateTime) Returns page count for the project to be rendered using given Timescale, PresentationFormat and date range.
GetPredecessors(Task) Returns a collection of task links which are predecessors of the specified task.
GetWork(double) Gets Duration object with the specified Double value and default work format.
Print() Prints project to the default printer with default printer settings using the standard (no User Interface) print controller.
Print(PrinterSettings) Prints project according to the specified printer settings using the standard (no User Interface) print controller.
Print(PrintOptions) Prints project to the default printer with default printer settings and custom save options using the standard (no User Interface) print controller.
Print(string) Prints project to the specified printer with default printer settings using the standard (no User Interface) print controller.
Print(PrinterSettings, PrintOptions) Prints project according to the specified printer settings and custom save options using the standard (no User Interface) print controller.
Print(PrinterSettings, string) Prints project according to the specified printer settings using the standard (no User Interface) print controller.
Print(PrinterSettings, PrintOptions, string) Prints project according to the specified printer settings, custom save options and the specified document name using the standard (no User Interface) print controller.
Recalculate() Reschedules all project tasks ids, outline levels, start/finish dates, sets early/late dates, calculates slacks, work and cost fields.
Recalculate(bool) Reschedules all project tasks ids, outline levels, start/finish dates, sets early/late dates, calculates slacks, work and cost fields with optional validation.
RecalculateResourceFields() Recalculates Id, Start and Finish of resources.
RecalculateResourceStartFinish() Recalculates Start and Finish of resources.
RemoveInvalidResourceAssignments() Eliminates invalid resource assignments from the project resource assignments list.
RenumberWBSCode() Renumber WBS code of all tasks.
RenumberWBSCode(List<int>) Renumber WBS code of passed tasks.
RescheduleUncompletedWorkToStartAfter(DateTime) Reschedules uncompleted project work to start after a specified date.
RescheduleUncompletedWorkToStartAfter(DateTime, List<Task>) Reschedules uncompleted work for a specified list of tasks to start after a specified date.
Save(string) Saves the project data to the file in mpp format.
Save(Stream, MPPSaveOptions) Saves the project to a stream using the specified save options.
Save(Stream, SaveFileFormat) Saves the project data to the stream.
Save(Stream, SaveOptions) Saves the project to a stream using the specified save options.
Save(string, MPPSaveOptions) Saves the document to mpp file format using the specified save options.
Save(string, SaveFileFormat) Saves the project data to the file.
Save(string, SaveOptions) Saves the document to a file using the specified save options.
SaveAsTemplate(Stream) Saves the project as a template to a specified stream.
SaveAsTemplate(string) Saves the project as a template to the specified file path.
SaveAsTemplate(Stream, SaveTemplateOptions) Saves the project as a template to a specified stream.
SaveAsTemplate(string, SaveTemplateOptions) Saves the project as a template.
SaveReport(Stream) Saves the project overview report to the stream.
SaveReport(string) Saves the project overview report to PDF file.
SaveReport(Stream, ReportType) Saves the project report of the specified type to the specified stream.
SaveReport(string, ReportType) Saves the project report of the specified type in PDF format to the specified file path.
SelectAllChildTasks() Recursively collects all child tasks of the root task.
Set(Key<DateTime, PrjKey>, DateTime) Maps the specified property to the specified value in this container.
Set<T>(Key<T, PrjKey>, T) Maps the specified property to the specified value in this container.
SetBaseline(BaselineType) Saves baseline fields to the specified baseline for the entire project.
SetBaseline(BaselineType, IEnumerable<Task>) Saves baseline fields to the specified baseline for the selected tasks.
SetBaselineSaveTime(BaselineType, DateTime) Sets the baseline save time.
UpdateProjectWorkAsComplete(DateTime, bool) Updates all work as complete through a specified date for the entire project.
UpdateProjectWorkAsComplete(DateTime, bool, List<Task>) Updates all work as complete through a specified date for the specified list of tasks.
static GetProjectFileInfo(Stream) Gets project file info from the stream.
static GetProjectFileInfo(string) Read project file info from the file.

Remarks

The Project is a central class in the Aspose.Tasks library.

One can use Project to read one of supported project management formats: MPP, MPT, MPX, XML.

To load an existing document in any of the supported formats, pass a file name or a stream into one of the Project constructors. To create a blank project, call the parameterless constructor.

Use one of the Save method overloads to save the project in any of the SaveFileFormat formats: Primavera: P6 XML, PM XER; Microsoft Excel: XLSX, XML; Fixed Layout: PDF; Images: JPEG, PNG, BMP, TIFF, SVG; Text: TXT; Others: HTML.

To print the project, use one of the Print method overloads.

The Project stores project-wide information such as Views, BuiltInProps, CustomProps, and ExtendedAttributes. Most of these objects are accessible via the corresponding properties of the Project class.

The Project is a root entity that contains entry points to manipulate other project entities, such as Task, Resource, ResourceAssignment, ExtendedAttribute and Calendar.

The Project entities can be accessed via typed collections, for example Children, Resources, ResourceAssignments, etc.

Examples

Shows how to work with a <see cref=“Aspose.Tasks.Project”/> instance.

var project = new Project();
project.Set(Prj.WorkFormat, TimeUnitType.Hour); // set the desired project properties
project.Set(Prj.NewTasksAreManual, false);

// adding new tasks and set desired properties
var task1 = project.RootTask.Children.Add("Task 1");
task1.Set(Tsk.Start, new DateTime(2020, 2, 5, 8, 0, 0));
task1.Set(Tsk.Duration, project.GetDuration(8, TimeUnitType.Hour));
task1.Set(Tsk.Finish, new DateTime(2020, 2, 5, 17, 0, 0));
var task2 = project.RootTask.Children.Add("Task 2");
task2.Set(Tsk.Start, new DateTime(2020, 2, 6, 8, 0, 0));
task2.Set(Tsk.Duration, project.GetDuration(8, TimeUnitType.Hour));
task2.Set(Tsk.Finish, new DateTime(2020, 2, 6, 17, 0, 0));

// adding new resources
var workResource = project.Resources.Add("Work Resource");
workResource.Set(Rsc.Type, ResourceType.Work);
var costResource = project.Resources.Add("Cost Resource");
costResource.Set(Rsc.Type, ResourceType.Cost);

// adding new resource assignments
var workResourceAssignment = project.ResourceAssignments.Add(task1, workResource);
workResourceAssignment.Set(Asn.Start, new DateTime(2020, 2, 5, 8, 0, 0));
workResourceAssignment.Set(Asn.Work, project.GetWork(8));
workResourceAssignment.Set(Asn.Finish, new DateTime(2020, 2, 5, 17, 0, 0));
var costResourceAssignment = project.ResourceAssignments.Add(task2, costResource);
costResourceAssignment.Set(Asn.Start, new DateTime(2020, 2, 6, 8, 0, 0));
costResourceAssignment.Set(Asn.Work, project.GetWork(8));
costResourceAssignment.Set(Asn.Finish, new DateTime(2020, 2, 6, 17, 0, 0));

// save project in the one of available formats
// here we are saving it in Microsoft Project XML file format.
project.Save(OutDir + "ProjectCreation_out.xml", SaveFileFormat.Xml);

See Also