Work with Project Online

The ProjectServerManager class provides the methods to retrieve projects from the specified Project Online account. The ProjectServerCredentials class shall be used to provide credentials that are used to connect to Project Online. Previously, Microsoft.SharePoint.Client.Runtime assembly was used to retrieve AuthToken but now Aspose.Tasks provides an option to specify SiteUrl, username, and password in order to create a connection to Project Online.

Read Project from Project Online

The following lines of code demonstrate how to read a project online.

 1System::String sharepointDomainAddress = u"https://contoso.sharepoint.com";
 2System::String userName = u"admin@contoso.onmicrosoft.com";
 3System::String password = u"MyPassword";
 4
 5System::SharedPtr<ProjectServerCredentials> credentials = System::MakeObject<ProjectServerCredentials>(sharepointDomainAddress, userName, password);
 6
 7System::SharedPtr<ProjectServerManager> manager = System::MakeObject<ProjectServerManager>(credentials);
 8System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<ProjectInfo>>> list = manager->GetProjectList();
 9
10for (const auto& p : System::IterateOver(list))
11{
12    System::Console::WriteLine(u"Name : " + p->get_Name());
13    System::Console::WriteLine(u"CreatedDate : " + p->get_CreatedDate().ToString());
14    System::Console::WriteLine(u"Name : " + p->get_LastSavedDate().ToString());
15                            
16}

Create a Project Online

The following lines of code demonstrate how to create a project online.

 1System::String sharepointDomainAddress = u"https://contoso.sharepoint.com";
 2System::String userName = u"admin@contoso.onmicrosoft.com";
 3System::String password = u"MyPassword";
 4
 5System::SharedPtr<ProjectServerCredentials> credentials = System::MakeObject<ProjectServerCredentials>(sharepointDomainAddress, userName, password);
 6
 7System::SharedPtr<Project> project = System::MakeObject<Project>(u"sample.mpp");
 8
 9System::SharedPtr<ProjectServerManager> manager = System::MakeObject<ProjectServerManager>(credentials);
10manager->CreateNewProject(project);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.