Importar y exportar datos del proyecto a formato Primavera
El formato de intercambio propietario de Primavera (XER), por Primavera Systems, Inc., se asocia principalmente con la gestión de proyectos de Primavera. Aspose.Task para C ++ proporciona la capacidad de exportar datos del proyecto de Microsoft a Primavera Xer, así como a los formatos XML. Este artículo demuestra cómo importar o exportar a una variedad de formatos compatibles con Primavera.
Importar datos del archivo Primavera
Aspose.Tasks para C ++ facilita la importación de datos del proyecto de los formatos PrimaverA XML o MPX.
Importar datos de formatos de archivo Primavera XML
Aspose.Task para C ++ puede importar Primavera XML similar a los formatos de Microsoft Project XML y MPP. La clase de proyecto proporciona la capacidad de cargar dicho tipo de archivo utilizando el mismo constructor que se usa para otros archivos de proyecto.
1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Project.xml");
2System::SharedPtr<ProjectFileInfo> info = Project::GetProjectFileInfo(dataDir + u"Project.xml");
3System::Console::WriteLine(System::ObjectExt::Box<FileFormat>(info->get_ProjectFileFormat()));
Importing Data from Primavera MPX File Formats
1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Primavera1.mpx");
2System::SharedPtr<ProjectFileInfo> info = Project::GetProjectFileInfo(dataDir + u"primavera1.mpx");
3System::Console::WriteLine(System::ObjectExt::Box<FileFormat>(info->get_ProjectFileFormat()));
Reading Project UIDs from Primavera XML file
A Primavera XML file may contain multiple projects, each having its own UID. Aspose.Tasks for C++ API provides the capability to read all such UIDs from the project and then load a project using a specific id from the list of UIDs.
1System::SharedPtr<PrimaveraXmlReader> reader = System::MakeObject<PrimaveraXmlReader>(dataDir + u"Project.xml");
2System::SharedPtr<System::Collections::Generic::List<int32_t>> listOpProjectUids = reader->GetProjectUids();
Reading Primavera XML file with Multiple Projects
1System::SharedPtr<PrimaveraXmlReadingOptions> options = System::MakeObject<PrimaveraXmlReadingOptions>();
2options->set_ProjectUid(4557);
3// Returns project with special Uid
4System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Project.xml", options);
Exporting Project Data in Primavera Formats
The SaveFileFormat enumerator is used to specifying the project export type as Primavera XML or XER.
Exporting Project Data to Primavera XML Format
1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Project1.mpp");
2
3// Save project in desired format
4project->Save(dataDir + u"ExportProjectDataToXMLFormat_out.xml", Aspose::Tasks::Saving::SaveFileFormat::PrimaveraP6XML);
Exporting Project Data to Primavera XER Format
1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Project1.mpp");
2
3// Save project in desired format
4project->Save(dataDir + u"ExportProjectDataToXERFormat_out.mpp", Aspose::Tasks::Saving::SaveFileFormat::PrimaveraXER);
Exporting Project Data to Primavera MPX Format
1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"Project1.mpp");
2
3// Save project in desired format
4project->Save(dataDir + u"ExportProjectDataToPrimaveraMPXFormat_out.xml", Aspose::Tasks::Saving::SaveFileFormat::MPX);
Primavera XML Save Options
If Primavera XML file doesn’t have any WBS inside (only Activities), Aspose.Tasks for C++ can’t read properly this type of file, because the API needs a root task to create a tree of tasks. In this case, the API creates a RootTask, even if it doesn’t exist in the file, to be able to read these particular files. If the user wants to save after reading, It’ll be saving with created RootTask, which did not exist before reading. This option helps to decide how to save into the file with created RootTask or not. By default, it is set to true.
1System::SharedPtr<Project> project = System::MakeObject<Project>(dataDir + u"project.xml");
2
3// Specify xml save options
4System::SharedPtr<PrimaveraXmlSaveOptions> options = System::MakeObject<PrimaveraXmlSaveOptions>();
5options->set_SaveRootTask(false);
6project->Save(u"UsingPrimaveraXMLSaveOptions_out.xml", options);