Import Project with the specified UID from File Introduction
This example explains shows how to import project from primavera db formats (Primavera SQLite .db or Primavera xml) and save it to specified file with the specified format, using Aspose.Tasks Cloud. Aspose.Tasks Cloud is a REST API which can be used with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.
API
Type
Description
Resource Link
/tasks/{name}/import
PUT
Imports project from primavera db formats (Primavera SQLite .db or Primavera xml) and saves it to specified file with the specified format
PutImportProjectFromFile
cURL Example
SDKs
The Aspose.Tasks Cloud SDKs can be downloaded from the following page: Available SDKs
SDK Examples
C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-dotnet/
var remote = await UploadFileToStorageAsync("p6_multiproject.xml");
var response = await TasksApi.PutImportProjectFromFileAsync(new PutImportProjectFromFileRequest
{
Name = remote,
Folder = this.DataFolder,
Filename = "imported_from_primavera.xml",
ProjectUid = "111",
FileType = ImportedProjectType.PrimaveraXml,
OutputFileFormat = ProjectFileFormat.P6xml
});
Assert.AreEqual((int)HttpStatusCode.OK, response.Code);
PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-php/
$remoteName = "ImportFromPrimaveraFile.xml";
$folder = $this->uploadFile("p6_multiproject.xml", $remoteName, '');
$response = $this->tasks->putImportProjectFromFile(new Requests\PutImportProjectFromFileRequest($remoteName,
"111",
"imported_from_primavera.xml",
Model\ImportedProjectType::PRIMAVERA_XML,
$folder,
Model\ProjectFileFormat::P6XML));
Assert::assertEquals(200, $response->getCode());
$response = $this->tasks->getTasks(new Requests\GetTasksRequest("imported_from_primavera.xml", self::$storageName, $folder));
Assert::assertEquals(200, $response->getCode());
Assert::assertEquals(12, count($response->getTasks()->getTaskItem()));
Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-python
filename = 'p6_multiproject.xml'
self.upload_file(filename)
put_request = PutImportProjectFromFileRequest(filename, "111", 'imported_from_primavera.xml',
ImportedProjectType.PRIMAVERAXML,
output_file_format=ProjectFileFormat.P6XML)
put_result = self.tasks_api.put_import_project_from_file(put_request)
self.assertIsNotNone(put_result)
self.assertIsInstance(put_result, AsposeResponse)
get_request = GetTasksRequest('imported_from_primavera.xml')
get_result = self.tasks_api.get_tasks(get_request)
self.assertIsNotNone(get_result)
self.assertIsInstance(get_result, TaskItemsResponse)
self.assertEqual(12, len(get_result.tasks.task_item))
Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-node
const fileName = "p6_multiproject.xml";
const localPath = "./Data/" + fileName;
const remotePath = "Temp/Data";
const remoteFullPath = remotePath + "/" + fileName;
await tasksApi.uploadFileToStorage(remoteFullPath, localPath);
const request = new PutImportProjectFromFileRequest();
request.name = fileName;
request.folder = remotePath;
request.filename = "imported_from_primavera.xml";
request.projectUid = "111";
request.fileType = ImportedProjectType.PrimaveraXml;
request.outputFileFormat = ProjectFileFormat.P6xml
const result = await tasksApi.putImportProjectFromFile(request);
expect(result.response.statusCode).to.equal(200);
Go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/
client, ctx := UploadTestFileToStorage(t, localFileName, remoteBaseTestDataFolder+"/"+remoteFileName)
putOptions := &requests.PutImportProjectFromFileOpts{
Name: remoteFileName,
ProjectUid: "111",
Filename: "imported_from_primavera.xml",
Folder: optional.NewString(remoteBaseTestDataFolder),
FileType: optional.NewString(string(models.PRIMAVERA_XML_ImportedProjectType)),
OutputFileFormat: optional.NewString(string(models.P6XML_ProjectFileFormat)),
}
putProjectResult, _, err := client.TasksApi.PutImportProjectFromFile(ctx, putOptions)
if err != nil {
t.Error(err)
}
assert.Equal(t, int32(200), putProjectResult.Code)
Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-tasks-cloud/aspose-tasks-cloud-java/
String localFileName = "p6_multiproject.xml";
String remoteFileName = TestInitializer.UploadFile(localFileName);
PutImportProjectFromFileRequest request1 = new PutImportProjectFromFileRequest(remoteFileName, "111", "imported_from_primavera.xml", ImportedProjectType.PRIMAVERAXML.getValue(), null, null, ProjectFileFormat.P6XML.getValue());
AsposeResponse result1 = TestInitializer.tasksApi.putImportProjectFromFile(request1);
assertNotNull(result1);
assertEquals(200, result1.getCode().intValue());
GetTasksRequest request2 = new GetTasksRequest(request1.getfilename(), null, null);
TestInitializer.uploadedFiles.add(request1.getfilename());
TaskItemsResponse result2 = TestInitializer.tasksApi.getTasks(request2);
assertNotNull(result2);
assertEquals(200, result2.getCode().intValue());
assertEquals(12, result2.getTasks().getTaskItem().size());