Project Class

Represents a project.
Inheritance Hierarchy
SystemObject
  Aspose.TasksProject

Namespace:  Aspose.Tasks
Assembly:  Aspose.Tasks (in Aspose.Tasks.dll) Version: 21.5
Syntax
public class Project

The Project type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleProject
Initializes a new instance of the Project class.
Public methodCode exampleProject(Stream)
Initializes a new instance of the Project class from a stream.
Public methodCode exampleProject(StreamReader)
Initializes a new instance of the Project class from a StreamReader instance.
Public methodCode exampleProject(String)
Initializes a new instance of the Project class from a template (existent mpp or mpt file).
Public methodCode exampleProject(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.
Public methodCode exampleProject(Stream, LoadOptions)
Initializes a new instance of the Project class from the Stream with the specified instance of the LoadOptions class.
Public methodCode exampleProject(Stream, ParseErrorCallback)
Initializes a new instance of the Project class from a template(existent mpp or mpt file).
Public methodCode exampleProject(Stream, PrimaveraXmlReadingOptions)
Initializes a new instance of the Project class from the Stream with the specified instance of the PrimaveraXmlReadingOptions class.
Public methodCode exampleProject(Stream, String)
Initializes a new instance of the Project class from a template(existent mpp or mpt file).
Public methodCode exampleProject(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.
Public methodCode exampleProject(String, ParseErrorCallback)
Initializes a new instance of the Project class from a template (existent mpp or mpt file).
Public methodCode exampleProject(String, PrimaveraXmlReadingOptions)
Initializes a new instance of the Project class from a template (existent MPP or MPT file) with the specified instance of the PrimaveraXmlReadingOptions class.
Public methodCode exampleProject(String, String)
Initializes a new instance of the Project class from a password protected template (existent mpp or mpt file).
Public methodCode exampleProject(Stream, ParseErrorCallback, PrimaveraXmlReadingOptions)
Initializes a new instance of the Project class from the Stream with the specified instance of the PrimaveraXmlReadingOptions class.
Public methodCode exampleProject(String, ParseErrorCallback, PrimaveraXmlReadingOptions)
Initializes a new instance of the Project class from a template (existent mpp or mpt file) with the specified instance of the PrimaveraXmlReadingOptions class.
Properties
  NameDescription
Public propertyCode exampleBuiltInProps
Gets project's built-in properties collection.
Public propertyCode exampleCalculationMode
Gets or sets calculation mode of a project. Can be one of the values of CalculationMode enumeration.
Public propertyCode exampleCalendars
Gets CalendarCollection object of this Project instance.
Public propertyCode exampleCriticalPath
Gets a collection which contains a list of Critical tasks which comprise Critical Path of this project.
Remarks
This is an O(n) operation, where n is the number of tasks in the project.
Public propertyCode exampleCustomProps
Gets project's custom properties collection.
Public propertyCode exampleDefaultView
Gets or sets default view of the project.
Public propertyCode exampleDefaultWeekWorkingDays
Gets the instance of WeekDayCollection class which represents a collection of project default week working days and working times.
Public propertyCode exampleDisplayOptions
Gets an instance of the ProjectDisplayOptions class.
Public propertyCode exampleExtendedAttributes
Gets ExtendedAttributeDefinitionCollection object. The collection of extended attribute (custom fields) definitions associated with a project.
Public propertyCode exampleOleObjects
Gets a collection containing the instances of the OleObject class which are linked or embedded to this project file.
Remarks
Available for mpp file format only. This collection is read-only except for 'Clear' operation.
Public propertyCode exampleOutlineCodes
Gets OutlineCodeDefinitionCollection object. The collection of outline code definitions associated with a project.
Public propertyCode exampleResourceAssignments
Gets ResourceAssignmentCollection object.
Public propertyCode exampleResourceFilters
Gets all the resource-based filter definitions. ResourceFilters is a collection of Filter objects.
Public propertyCode exampleResourceGroups
Gets all of the resource-based group definitions. ResourceGroups is a collection of Group objects.
Public propertyCode exampleResources
Gets ResourceCollection object.
Public propertyCode exampleRootTask
Gets the root of the tree of tasks.
Public propertyCode exampleTables
Gets a list of Table objects.
Public propertyCode exampleTaskFilters
Gets all the task-based filter definitions. TaskFilters is a collection of Filter objects.
Public propertyCode exampleTaskGroups
Gets all the task-based group definitions. TaskGroups is a collection of Group objects.
Public propertyCode exampleTaskLinks
Gets TaskLinkCollection object.
Public propertyCode exampleVbaProject
Gets an instance of VbaProject class.
Public propertyCode exampleViews
Gets a list of View objects.
Public propertyCode exampleWBSCodeDefinition
Gets or sets WBS Code Definition for the project.
Methods
  NameDescription
Public methodCode exampleCopyTo(Project)
Copies project's main data and properties to another project.
Public methodCode exampleCopyTo(Project, CopyToOptions)
Copies project's main data and properties to another project.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodCode exampleGetT
Returns the value to which the property is mapped in this container.
Public methodCode exampleGetBaselineSaveTime
Returns the baseline save time.
Public methodCode exampleGetDuration(Double)
Gets Duration object with the specified number of units and default duration format which is defined in project's settings DurationFormat.
Public methodCode exampleGetDuration(Double, TimeUnitType)
Gets Duration object with the specified number of TimeUnitType units.
Public methodGetDuration(TimeSpan, TimeUnitType)
Gets Duration object with the specified TimeSpan value and specified TimeUnitType value.
Public methodGetHashCode (Inherited from Object.)
Public methodCode exampleGetPageCount
Returns page count for the project to be rendered using default Timescale(Days).
Public methodCode exampleGetPageCount(PresentationFormat)
Returns page count for the project to be rendered using default Timescale(Days) and given PresentationFormat
Public methodCode exampleGetPageCount(SaveOptions)
Returns page count for the project to be rendered using given SaveOptions.
Public methodCode exampleGetPageCount(Timescale)
Returns page count for the project to be rendered using given Timescale.
Public methodCode exampleGetPageCount(PageSize, Timescale)
Returns page count for the project to be rendered using given Timescale and PageSize.
Public methodCode exampleGetPageCount(PresentationFormat, Timescale)
Returns page count for the project to be rendered using given Timescale and PresentationFormat.
Public methodCode exampleGetPageCount(PageSize, Timescale, DateTime, DateTime)
Returns page count for the project to be rendered using given Timescale, PresentationFormat and date range.
Public methodCode exampleGetPredecessors
Returns a collection of task links which are predecessors of the specified task.
Public methodStatic memberCode exampleGetProjectFileInfo(Stream)
Gets project file info from the stream.
Public methodStatic memberCode exampleGetProjectFileInfo(String)
Read project file info from the file.
Public methodGetType (Inherited from Object.)
Public methodCode exampleGetWork
Gets Duration object with the specified Double value and default work format.
Protected methodMemberwiseClone (Inherited from Object.)
Public methodCode examplePrint
Prints project to the default printer with default printer settings using the standard (no User Interface) print controller.
Public methodCode examplePrint(PrinterSettings)
Prints project according to the specified printer settings using the standard (no User Interface) print controller.
Public methodCode examplePrint(String)
Prints project to the specified printer with default printer settings using the standard (no User Interface) print controller.
Public methodCode examplePrint(PrintOptions)
Prints project to the default printer with default printer settings and custom save options using the standard (no User Interface) print controller.
Public methodCode examplePrint(PrinterSettings, PrintOptions)
Prints project according to the specified printer settings and custom save options using the standard (no User Interface) print controller.
Public methodCode examplePrint(PrinterSettings, String)
Prints project according to the specified printer settings using the standard (no User Interface) print controller.
Public methodCode examplePrint(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.
Public methodCode exampleRecalculate
Reschedules all project tasks ids, outline levels, start/finish dates, sets early/late dates, calculates slacks, work and cost fields.
Public methodCode exampleRecalculate(Boolean)
Reschedules all project tasks ids, outline levels, start/finish dates, sets early/late dates, calculates slacks, work and cost fields with optional validation.
Public methodCode exampleRecalculateResourceFields
Recalculates Id, Start and Finish of resources.
Public methodCode exampleRecalculateResourceStartFinish
Recalculates Start and Finish of resources.
Public methodCode exampleRemoveInvalidResourceAssignments
Eliminates invalid resource assignments from the project resource assignments list.
Public methodCode exampleRenumberWBSCode
Renumber WBS code of all tasks.
Public methodCode exampleRenumberWBSCode(ListInt32)
Renumber WBS code of passed tasks.
Public methodCode exampleRescheduleUncompletedWorkToStartAfter(DateTime)
Reschedules uncompleted project work to start after a specified date.
Public methodCode exampleRescheduleUncompletedWorkToStartAfter(DateTime, ListTask)
Reschedules uncompleted work for a specified list of tasks to start after a specified date.
Public methodSave(String)
Saves the project data to the file in mpp format.
Public methodCode exampleSave(Stream, MPPSaveOptions)
Saves the project to a stream using the specified save options.
Public methodCode exampleSave(Stream, SaveFileFormat)
Saves the project data to the stream.
Public methodCode exampleSave(Stream, SaveOptions)
Saves the project to a stream using the specified save options.
Public methodCode exampleSave(String, MPPSaveOptions)
Saves the document to mpp file format using the specified save options.
Public methodCode exampleSave(String, SaveFileFormat)
Saves the project data to the file.
Public methodCode exampleSave(String, SaveOptions)
Saves the document to a file using the specified save options.
Public methodCode exampleSaveAsTemplate(Stream)
Saves the project as a template to a specified stream.
Public methodCode exampleSaveAsTemplate(String)
Saves the project as a template to the specified file path.
Public methodCode exampleSaveAsTemplate(Stream, SaveTemplateOptions)
Saves the project as a template to a specified stream.
Public methodCode exampleSaveAsTemplate(String, SaveTemplateOptions)
Saves the project as a template.
Public methodCode exampleSaveReport(Stream)
Saves the project overview report to the stream.
Public methodCode exampleSaveReport(String)
Saves the project overview report to PDF file.
Public methodCode exampleSaveReport(Stream, ReportType)
Saves the project report of the specified type to the specified stream.
Public methodCode exampleSaveReport(String, ReportType)
Saves the project report of the specified type in PDF format to the specified file path.
Public methodCode exampleSelectAllChildTasks
Recursively collects all child tasks of the root task.
Public methodCode exampleSet(KeyDateTime, PrjKey, DateTime)
Maps the specified property to the specified value in this container.
Public methodCode exampleSetT(KeyT, PrjKey, T)
Maps the specified property to the specified value in this container.
Public methodCode exampleSetBaseline(BaselineType)
Saves baseline fields to the specified baseline for the entire project.
Public methodCode exampleSetBaseline(BaselineType, IEnumerableTask)
Saves baseline fields to the specified baseline for the selected tasks.
Public methodCode exampleSetBaselineSaveTime
Sets the baseline save time.
Public methodToString (Inherited from Object.)
Public methodCode exampleUpdateProjectWorkAsComplete(DateTime, Boolean)
Updates all work as complete through a specified date for the entire project.
Public methodCode exampleUpdateProjectWorkAsComplete(DateTime, Boolean, ListTask)
Updates all work as complete through a specified date for the specified list of tasks.
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