Aspose.Tasks for C++
ProjectServerManager.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="ProjectServerManager.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2024 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/object.h>
9 #include <system/eventhandler.h>
10 
11 #include "aspose.tasks.cpp/IO/Pwa/WebRequestEventArgs.h"
12 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
13 
14 namespace Aspose
15 {
16 namespace Tasks
17 {
18 class ILogger;
19 namespace IO
20 {
21 namespace Pwa
22 {
23 class IProjectServerConnection;
24 } // namespace Pwa
25 } // namespace IO
26 class Project;
27 class ProjectInfo;
28 class ProjectServerCredentials;
29 class ProjectServerSaveOptions;
30 } // namespace Tasks
31 } // namespace Aspose
32 namespace System
33 {
34 namespace Collections
35 {
36 namespace Generic
37 {
38 template <typename> class IEnumerable;
39 } // namespace Generic
40 } // namespace Collections
41 class Guid;
42 namespace IO
43 {
44 class Stream;
45 } // namespace IO
46 } // namespace System
47 
48 namespace Aspose {
49 
50 namespace Tasks {
51 
52 /// <summary>
53 /// The class which provides the methods to read and to perform operations on projects in the specified Project Online account or
54 /// in the specified on-premise Project Server instance (Project Server's versions 2016 and 2019 are supported).
55 /// </summary>
56 class ASPOSE_TASKS_SHARED_CLASS ProjectServerManager final : public System::Object
57 {
59  typedef System::Object BaseType;
60 
61  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
62  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
63 
64 public:
65 
66  /// <summary>
67  /// An event that is raised when the web request is sent to Project Server's web API.
68  /// </summary>
69  System::EventHandler<System::SharedPtr<WebRequestEventArgs>> ExecutingWebRequest;
70 
71  /// <summary>
72  /// Initializes a new instance of the <see cref="ProjectServerManager"></see> class.
73  /// </summary>
74  /// <param name="credentials">Credentials used to connect to Project Online account.</param>
75  /// <example>
76  /// This example shows how to create instance of ProjectServerManager to access on-premise instance of Project Server.
77  /// <code>
78  /// [C#]
79  /// string site = "http://project_server_instance.local/";
80  /// var windowsCredentials = new NetworkCredential("Administrator", "my_password", "DOMAIN");
81  /// var projectServerCredentials = new ProjectServerCredentials(site, windowsCredentials);
82  /// ProjectServerManager manager = new ProjectServerManager(projectServerCredentials);
83  /// </code>
84  /// </example>
85  /// <example>
86  /// This example shows how to create instance of ProjectServerManager to access account in Project Online service.
87  /// <code>
88  /// [C#]
89  /// var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
90  /// ProjectServerManager manager = new ProjectServerManager(projectServerCredentials);
91  /// </code>
92  /// </example>
93  ASPOSE_TASKS_SHARED_API ProjectServerManager(const System::SharedPtr<ProjectServerCredentials>& credentials);
94 
95  /// <summary>
96  /// Gets the project with the specified guid from the Project Online account \ Project Server instance.
97  /// </summary>
98  /// <returns>Instance of <see cref="Project"></see> class which represents project read from Project Online \ Project Server.</returns>
99  /// <param name="projectGuid">The Guid of the project to read.</param>
100  ASPOSE_TASKS_SHARED_API System::SharedPtr<Project> GetProject(System::Guid projectGuid);
101  /// <summary>
102  /// Gets the project's binary data for troubleshooting purposes.
103  /// </summary>
104  /// <returns>Stream containing raw project's data.</returns>
105  /// <param name="projectGuid">The Guid of the project to read.</param>
106  /// <example>
107  /// <code>
108  /// 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.
109  /// [C#]
110  /// var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
111  /// // Guid of project you are trying to get.
112  /// var projectGuid = new Guid("e0294bfb-5657-45c8-9cc5-82169fb95d69");
113  /// ProjectServerManager manager = new ProjectServerManager(credentials);
114  /// using (var fileStream = File.OpenWrite(@"c:\debug.zip"))
115  /// {
116  /// using (var stream = manager.GetProjectRawData(projectGuid))
117  /// {
118  /// stream.CopyTo(fileStream);
119  /// }
120  /// }
121  /// </code>
122  /// </example>
123  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::IO::Stream> GetProjectRawData(System::Guid projectGuid);
124  /// <summary>
125  /// Gets the list of projects from 'Working' store of the current Project Online account \ Project Server instance.
126  /// </summary>
127  /// <returns>An enumeration of projects in the current Project Online account \ Project Server instance.</returns>
128  ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<ProjectInfo>>> GetProjectList();
129  /// <summary>
130  /// Updates existing project in Project Server\Project Online instance using default save options. The existing project will be overwritten.
131  /// </summary>
132  /// <param name="project">The project to save to Project Server\Project Online instance.</param>
133  /// <exception cref="ProjectOnlineException">In case of communication error or error returned by a server.</exception>
134  /// <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.</remarks>
135  /// <example>
136  /// In this example the project is loaded from Project Online account, modified and saved back to Project Online account.
137  /// <code>
138  /// [C#]
139  /// var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
140  /// ProjectServerManager manager = new ProjectServerManager(credentials);
141  /// var projectList = manager.GetProjectList();
142  /// var projectGuid = projectList.First().Id;
143  /// var project = manager.GetProject(projectGuid);
144  /// var task = project.RootTask.Children.Add("New task");
145  /// manager.UpdateProject(project);
146  /// </code>
147  /// </example>
148  ASPOSE_TASKS_SHARED_API void UpdateProject(const System::SharedPtr<Project>& project);
149  /// <summary>
150  /// Updates existing project in Project Server\Project Online instance using the specified save options. The existing project will be overwritten.
151  /// </summary>
152  /// <param name="project">The project to save to Project Server\Project Online instance.</param>
153  /// <param name="saveOptions"> Instance of <see cref="ProjectServerSaveOptions"></see> class.</param>
154  /// <exception cref="ProjectOnlineException">In case of communication error or error returned by a server.</exception>
155  /// <remarks>saveOptions.ProjectGuid should be set to a guid of a project which exists on Project Server\ Project Online instance.</remarks>
156  /// <example>
157  /// In this example the project is loaded from Project Online account, modified and saved back to Project Online account.
158  /// <code>
159  /// [C#]
160  /// var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
161  /// ProjectServerManager manager = new ProjectServerManager(credentials);
162  /// var projectList = manager.GetProjectList();
163  /// var projectGuid = projectList.First().Id;
164  /// var project = manager.GetProject(projectGuid);
165  /// var task = project.RootTask.Children.Add("New task");
166  /// manager.UpdateProject(project, new ProjectServerSaveOptions
167  /// {
168  /// ProjectGuid = projectGuid
169  /// });
170  /// </code>
171  /// </example>
172  ASPOSE_TASKS_SHARED_API void UpdateProject(const System::SharedPtr<Project>& project, const System::SharedPtr<ProjectServerSaveOptions>& saveOptions);
173  /// <summary>
174  /// Creates new project in Project Server\Project Online instance using default save options.
175  /// </summary>
176  /// <param name="project">The project to save to Project Server\Project Online instance.</param>
177  /// <exception cref="ProjectOnlineException">In case of communication error or error returned by a server.</exception>
178  /// <example>
179  /// In this example the project is loaded from .mpp file and saved to Project Online account.
180  /// <code>
181  /// [C#]
182  /// var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
183  /// var project = new Project(@"sample.mpp");
184  /// ProjectServerManager manager = new ProjectServerManager(credentials);
185  /// manager.CreateNewProject(project);
186  /// </code>
187  /// </example>
188  ASPOSE_TASKS_SHARED_API void CreateNewProject(const System::SharedPtr<Project>& project);
189  /// <summary>
190  /// Creates new project in Project Server\Project Online instance using the specified save options.
191  /// </summary>
192  /// <param name="project">The project to save to Project Server\Project Online instance.</param>
193  /// <param name="saveOptions"> Instance of <see cref="ProjectServerSaveOptions"></see> class.</param>
194  /// <exception cref="ProjectOnlineException">In case of communication error or error returned by a server.</exception>
195  /// <example>
196  /// In this example the project is loaded from .mpp file and saved to Project Online account.
197  /// <code>
198  /// [C#]
199  /// var credentials = new ProjectServerCredentials("https://xxxxxx.sharepoint.com", "yyyyy@xxxxxxx.onmicrosoft.com", "password");
200  /// var project = new Project(@"sample.mpp");
201  /// ProjectServerManager manager = new ProjectServerManager(credentials);
202  /// manager.CreateNewProject(project, new ProjectServerSaveOptions
203  /// {
204  /// ProjectName = "My new project"
205  /// });
206  /// </code>
207  /// </example>
208  ASPOSE_TASKS_SHARED_API void CreateNewProject(const System::SharedPtr<Project>& project, const System::SharedPtr<ProjectServerSaveOptions>& saveOptions);
209 
210 protected:
211 
212  ASPOSE_TASKS_SHARED_API ProjectServerManager(const System::SharedPtr<IO::Pwa::IProjectServerConnection>& connection);
213 
214  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(ProjectServerManager, CODEPORTING_ARGS(const System::SharedPtr<IO::Pwa::IProjectServerConnection>& connection));
215  ASPOSE_TASKS_SHARED_API void DeleteProject(System::Guid projectGuid);
216 
217  virtual ASPOSE_TASKS_SHARED_API ~ProjectServerManager();
218 
219  #ifdef ASPOSE_GET_SHARED_MEMBERS
220  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
221  #endif
222 
223 
224 private:
225 
226  System::SharedPtr<IO::Pwa::IProjectServerConnection> connection;
227  System::SharedPtr<ILogger> logger;
228 
229  void ConnectionOnExecutingWebRequest(const System::SharedPtr<System::Object>& sender, const System::SharedPtr<WebRequestEventArgs>& e);
230 
231 };
232 
233 } // namespace Tasks
234 } // namespace Aspose
235 
236 
The class which provides the methods to read and to perform operations on projects in the specified P...
Definition: ProjectServerManager.h:57
System::SharedPtr< System::IO::Stream > GetProjectRawData(System::Guid projectGuid)
Gets the project's binary data for troubleshooting purposes.
void CreateNewProject(const System::SharedPtr< Project > &project)
Creates new project in Project Server\Project Online instance using default save options.
void UpdateProject(const System::SharedPtr< Project > &project, const System::SharedPtr< ProjectServerSaveOptions > &saveOptions)
Updates existing project in Project Server\Project Online instance using the specified save options....
void UpdateProject(const System::SharedPtr< Project > &project)
Updates existing project in Project Server\Project Online instance using default save options....
void CreateNewProject(const System::SharedPtr< Project > &project, const System::SharedPtr< ProjectServerSaveOptions > &saveOptions)
Creates new project in Project Server\Project Online instance using the specified save options.
System::SharedPtr< Project > GetProject(System::Guid projectGuid)
Gets the project with the specified guid from the Project Online account \ Project Server instance.
ProjectServerManager(const System::SharedPtr< ProjectServerCredentials > &credentials)
Initializes a new instance of the ProjectServerManager class.
System::EventHandler< System::SharedPtr< WebRequestEventArgs > > ExecutingWebRequest
An event that is raised when the web request is sent to Project Server's web API.
Definition: ProjectServerManager.h:69
System::SharedPtr< System::Collections::Generic::IEnumerable< System::SharedPtr< ProjectInfo > > > GetProjectList()
Gets the list of projects from 'Working' store of the current Project Online account \ Project Server...
Definition: Asn.h:13