Import Project with the specified UID from a Database Introduction
This example explains how to import Project with the specified UID from a MS Project Database specified by a connection string and saves 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/importfromdb
PUT
Imports project from database with the specified connection string and saves it to specified file with the specified format
PutImportProjectFromDb
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 response = await TasksApi.PutImportProjectFromDbAsync(new PutImportProjectFromDbRequest
{
ConnectionString = "Data Source=db.contoso.com;Initial Catalog=ProjectServer;Persist Security Info=True;User ID=sa;Password=pwd;",
DatabaseType = ProjectDatabaseType.Msp,
Folder = this.DataFolder,
Filename = "imported_from_db.xml",
ProjectUid = "E6426C44-D6CB-4B9C-AF16-48910ACE0F54",
DatabaseSchema = "dbo",
Format = 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/
static::markTestSkipped('Ignored because SQL instance in required in order to run test');
$response = $this->tasks->putImportProjectFromDb(new PutImportProjectFromDbRequest
(Model\ProjectDatabaseType::MSP,
"E6426C44-D6CB-4B9C-AF16-48910ACE0F54",
"imported_from_db.xml",
'Data Source=db.contoso.com;Initial Catalog=ProjectServer;Persist Security Info=True;User ID=sa;Password=pwd;',
Model\ProjectFileFormat::P6XML,
self::$baseTestPath,
"dbo"));
Assert::assertEquals(200, $response->getCode());
$response = $this->tasks->getProjectIds(new GetProjectIdsRequest("imported_from_db.xml", null, self::$baseTestPath));
Assert::assertEquals(200, $response->getCode());
Assert::assertEquals(1, count($response->getProjectIds()));
Assert::assertEquals("0", $response->getProjectIds()[0]);
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
put_request = PutImportProjectFromDbRequest()
put_request.connection_string = "Data Source=db.contoso.com;Initial Catalog=ProjectServer;Persist Security Info=True;User ID=sa;Password=pwd;"
put_request.database_type = ProjectDatabaseType.MSP
put_request.filename = "imported_from_db.xml"
put_request.project_uid = "E6426C44-D6CB-4B9C-AF16-48910ACE0F54"
put_request.database_schema = "dbo"
put_request.format = ProjectFileFormat.P6XML
put_result = self.tasks_api.put_import_project_from_db(put_request)
self.assertIsNotNone(put_result)
self.assertIsInstance(put_result, AsposeResponse)
get_request = GetProjectIdsRequest("imported_from_db")
get_result = self.tasks_api.get_project_ids(get_request)
self.assertIsNotNone(get_result)
self.assertIsInstance(get_result, ProjectIdsResponse)
self.assertEqual(["1"], get_result.project_ids)
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 request = new PutImportProjectFromDbRequest();
request.connectionString = "Data Source=db.contoso.com;Initial Catalog=ProjectServer;Persist Security Info=True;User ID=sa;Password=pwd;"
request.databaseType = ProjectDatabaseType.Msp;
request.filename = "imported_from_db.xml";
request.folder = "Temp/Data";
request.projectUid = "E6426C44-D6CB-4B9C-AF16-48910ACE0F54";
request.databaseSchema = "dbo";
request.format = ProjectFileFormat.P6xml;
const result = await tasksApi.putImportProjectFromDb(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 := PrepareTest(t, config)
putOptions := &requests.PutImportProjectFromDbOpts{
ConnectionString: "Data Source=db.contoso.com;Initial Catalog=ProjectServer;Persist Security Info=True;User ID=sa;Password=pwd;",
DatabaseType: string(models.MSP_ProjectDatabaseType),
Filename: "imported_from_db.xml",
Folder: optional.NewString(remoteBaseTestDataFolder),
ProjectUid: "E6426C44-D6CB-4B9C-AF16-48910ACE0F54",
DatabaseSchema: optional.NewString("dbo"),
Format: optional.NewString(string(models.P6XML_ProjectFileFormat)),
}
putProjectResult, _, err := client.TasksApi.PutImportProjectFromDb(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/
PutImportProjectFromDbRequest request1 = new PutImportProjectFromDbRequest(ProjectDatabaseType.MSP.getValue(), "Data Source=db.contoso.com;Initial Catalog=ProjectServer;Persist Security Info=True;User ID=sa;Password=pwd;", "E6426C44-D6CB-4B9C-AF16-48910ACE0F54", "imported_from_db.xml", ProjectFileFormat.P6XML.getValue(), null, null, "dbo");
AsposeResponse result1 = TestInitializer.tasksApi.putImportProjectFromDb(request1);
assertNotNull(result1);
assertEquals(200, result1.getCode().intValue());
GetProjectIdsRequest request2 = new GetProjectIdsRequest(request1.getfilename(), null, null);
TestInitializer.uploadedFiles.add(request1.getfilename());
ProjectIdsResponse result2 = TestInitializer.tasksApi.getProjectIds(request2);
assertNotNull(result2);
assertEquals(200, result2.getCode().intValue());
assertEquals(Collections.singletonList("1"), result2.getProjectIds());