Work with Project Online or Project Server

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. Aspose.Tasks for Java API 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.

 1String sharepointDomainAddress = "https://contoso.sharepoint.com";
 2String userName = "admin@contoso.onmicrosoft.com";
 3String password = "MyPassword";
 4
 5ProjectServerCredentials credentials = new ProjectServerCredentials(sharepointDomainAddress, userName, password);
 6ProjectServerManager reader = new ProjectServerManager(credentials);
 7
 8for (ProjectInfo p : (Iterable<ProjectInfo>)reader.getProjectList())
 9{
10    System.out.println("Project Name:" + p.getName());
11    System.out.println("Project Created Date:" + p.getCreatedDate());
12    System.out.println("Project Last Saved Date:" + p.getLastSavedDate());
13}
14
15for (ProjectInfo p : (Iterable<ProjectInfo>)reader.getProjectList())
16{
17    Project project = reader.getProject(p.getId());
18    System.out.println("Project " + p.getName() + " loaded.");
19    System.out.println("Resources count:" + project.getResources().size());
20}

Create a Project Online

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

1String sharepointDomainAddress = "https://contoso.sharepoint.com";
2String userName = "admin@contoso.onmicrosoft.com";
3String password = "MyPassword";
4        
5ProjectServerCredentials credentials = new ProjectServerCredentials(sharepointDomainAddress, userName, password);
6Project project = new Project("sample.mpp");
7 
8ProjectServerManager manager = new ProjectServerManager(credentials);
9manager.createNewProject(project);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.