Class ProjectServerManager
Namespace: Aspose.Tasks
Assembly: Aspose.Tasks.dll (25.2.0)
The class which provides the methods to read and to perform operations on projects in the specified Project Online account or in the specified on-premise Project Server instance (Project Server’s versions 2016 and 2019 are supported).
public sealed class ProjectServerManager
Inheritance
Inherited Members
object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
ProjectServerManager(ProjectServerCredentials)
Initializes a new instance of the Aspose.Tasks.ProjectServerManager class.
public ProjectServerManager(ProjectServerCredentials credentials)
Parameters
credentials
ProjectServerCredentials
Credentials used to connect to Project Online account.
Examples
This example shows how to create instance of ProjectServerManager to access on-premise instance of Project Server.
csharp
[C#]
string site = "http://project_server_instance.local/";
var windowsCredentials = new NetworkCredential("Administrator", "my_password", "DOMAIN");
var projectServerCredentials = new ProjectServerCredentials(site, windowsCredentials);
ProjectServerManager manager = new ProjectServerManager(projectServerCredentials);
This example shows how to create instance of ProjectServerManager to access account in Project Online service.
csharp
[C#]
var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
ProjectServerManager manager = new ProjectServerManager(projectServerCredentials);
Methods
CreateNewProject(Project)
Creates new project in Project Server\Project Online instance using default save options.
public void CreateNewProject(Project project)
Parameters
project
Project
The project to save to Project Server\Project Online instance.
Examples
In this example the project is loaded from .mpp file and saved to Project Online account.
csharp
[C#]
var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
var project = new Project(@"sample.mpp");
ProjectServerManager manager = new ProjectServerManager(credentials);
manager.CreateNewProject(project);
Exceptions
In case of communication error or error returned by a server.
CreateNewProject(Project, ProjectServerSaveOptions)
Creates new project in Project Server\Project Online instance using the specified save options.
public void CreateNewProject(Project project, ProjectServerSaveOptions saveOptions)
Parameters
project
Project
The project to save to Project Server\Project Online instance.
saveOptions
ProjectServerSaveOptions
Instance of Aspose.Tasks.ProjectServerSaveOptions class.
Examples
In this example the project is loaded from .mpp file and saved to Project Online account.
csharp
[C#]
var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
var project = new Project(@"sample.mpp");
ProjectServerManager manager = new ProjectServerManager(credentials);
manager.CreateNewProject(project, new ProjectServerSaveOptions
{
ProjectName = "My new project"
});
Exceptions
In case of communication error or error returned by a server.
GetProject(Guid)
Gets the project with the specified guid from the Project Online account \ Project Server instance.
public Project GetProject(Guid projectGuid)
Parameters
projectGuid
Guid
The Guid of the project to read.
Returns
Instance of Aspose.Tasks.Project class which represents project read from Project Online \ Project Server.
GetProjectList()
Gets the list of projects from ‘Working’ store of the current Project Online account \ Project Server instance.
public IEnumerable<projectinfo> GetProjectList()
Returns
An enumeration of projects in the current Project Online account \ Project Server instance.
GetProjectRawData(Guid)
Gets the project’s binary data for troubleshooting purposes.
public Stream GetProjectRawData(Guid projectGuid)
Parameters
projectGuid
Guid
The Guid of the project to read.
Returns
Stream containing raw project’s data.
Examples
csharp
In this example the debug info for the specific project is retrieved. You can pass the resulting "debug.zip" to the support team for troubleshooting purposes.
[C#]
var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
// Guid of project you are trying to get.
var projectGuid = new Guid("e0294bfb-5657-45c8-9cc5-82169fb95d69");
ProjectServerManager manager = new ProjectServerManager(credentials);
using (var fileStream = File.OpenWrite(@"c:\debug.zip"))
{
using (var stream = manager.GetProjectRawData(projectGuid))
{
stream.CopyTo(fileStream);
}
}
UpdateProject(Project)
Updates existing project in Project Server\Project Online instance using default save options. The existing project will be overwritten.
public void UpdateProject(Project project)
Parameters
project
Project
The project to save to Project Server\Project Online instance.
Examples
In this example the project is loaded from Project Online account, modified and saved back to Project Online account.
csharp
[C#]
var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
ProjectServerManager manager = new ProjectServerManager(credentials);
var projectList = manager.GetProjectList();
var projectGuid = projectList.First().Id;
var project = manager.GetProject(projectGuid);
var task = project.RootTask.Children.Add("New task");
manager.UpdateProject(project);
Remarks
Project’s property ‘project.Get(Prj.Guid)’ should be a valid guid of a project which exists in Project Server account \ Project Online instance.
Exceptions
In case of communication error or error returned by a server.
UpdateProject(Project, ProjectServerSaveOptions)
Updates existing project in Project Server\Project Online instance using the specified save options. The existing project will be overwritten.
public void UpdateProject(Project project, ProjectServerSaveOptions saveOptions)
Parameters
project
Project
The project to save to Project Server\Project Online instance.
saveOptions
ProjectServerSaveOptions
Instance of Aspose.Tasks.ProjectServerSaveOptions class.
Examples
In this example the project is loaded from Project Online account, modified and saved back to Project Online account.
csharp
[C#]
var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
ProjectServerManager manager = new ProjectServerManager(credentials);
var projectList = manager.GetProjectList();
var projectGuid = projectList.First().Id;
var project = manager.GetProject(projectGuid);
var task = project.RootTask.Children.Add("New task");
manager.UpdateProject(project, new ProjectServerSaveOptions
{
ProjectGuid = projectGuid
});
Remarks
saveOptions.ProjectGuid should be set to a guid of a project which exists on Project Server\ Project Online instance.
Exceptions
In case of communication error or error returned by a server.
ExecutingWebRequest
An event that is raised when the web request is sent to Project Server’s web API.
public event EventHandler<webrequesteventargs> ExecutingWebRequest