public void ProjectServerCredentials() { // ExStart:CreateProjectOnline // ExFor: ProjectServerCredentials // ExFor: ProjectServerCredentials.#ctor(String,String,String) // ExSummary: Shows how to use project server credentials to retrieve list of project from Microsoft Project Online. try { const string SharepointDomainAddress = "https://contoso.sharepoint.com/sites/pwa"; const string UserName = "******"; const string Password = "******"; var credentials = new ProjectServerCredentials(SharepointDomainAddress, UserName, Password); var newProject = new Project(DataDir + @"Project1.mpp"); var manager = new ProjectServerManager(credentials); manager.CreateNewProject(newProject); IEnumerable <ProjectInfo> list = manager.GetProjectList(); foreach (var info in list) { var project = manager.GetProject(info.Id); Console.WriteLine("{0} - {1} - {2}", info.Name, info.CreatedDate, info.LastSavedDate); Console.WriteLine("Resources count: {0}", project.Resources.Count); } } catch (ProjectOnlineException ex) { Console.WriteLine(ex.Message); } // ExEnd:CreateProjectOnline }
public void UpdateProjectInProjectOnlineWithOptions() { // ExStart:UpdateProjectOnlineWithOptions // ExFor: ProjectServerSaveOptions.Timeout // ExSummary: Shows how to update project on Microsoft Project Online and control save timeout value. const string SharepointDomainAddress = "https://contoso.sharepoint.com/sites/pwa"; const string UserName = "******"; const string Password = "******"; var credentials = new ProjectServerCredentials(SharepointDomainAddress, UserName, Password); try { var manager = new ProjectServerManager(credentials); ProjectInfo projectInfo = null; foreach (var info in manager.GetProjectList()) { if (info.Name == "My project") { projectInfo = info; } } if (projectInfo == null) { Console.WriteLine("Project 'My project' not found in working store of Project Online account."); return; } var project = manager.GetProject(projectInfo.Id); project.Set(Prj.FinishDate, new DateTime(2020, 03, 01)); var task = project.RootTask.Children.Add("New task"); task.Set(Tsk.Start, new DateTime(2020, 02, 26)); task.Set(Tsk.Duration, project.GetDuration(2, TimeUnitType.Day)); var options = new ProjectServerSaveOptions { Timeout = TimeSpan.FromMinutes(5) }; manager.UpdateProject(project, options); } catch (ProjectOnlineException ex) { Console.WriteLine("Failed to update the project. Error: " + ex); } // ExEnd:UpdateProjectOnlineWithOptions catch (NotSupportedException ex) { Console.WriteLine( ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx."); } }
public void UpdateProjectServer() { // ExStart:UpdateProjectServer // ExFor: ProjectServerManager.UpdateProject(Project) // ExSummary: Shows how to update project on Microsoft Project Online. const string URL = "https://contoso.sharepoint.com/sites/pwa"; const string Domain = "CONTOSO.COM"; const string UserName = "******"; const string Password = "******"; var windowsCredentials = new NetworkCredential(UserName, Password, Domain); var projectServerCredentials = new ProjectServerCredentials(URL, windowsCredentials); try { var manager = new ProjectServerManager(projectServerCredentials); ProjectInfo projectInfo = null; foreach (var info in manager.GetProjectList()) { if (info.Name == "My project") { projectInfo = info; } } if (projectInfo == null) { Console.WriteLine("Project 'My project' not found in working store of Project Online account."); return; } var project = manager.GetProject(projectInfo.Id); project.Set(Prj.FinishDate, new DateTime(2020, 03, 01)); var task = project.RootTask.Children.Add("New task"); task.Set(Tsk.Start, new DateTime(2020, 02, 26)); task.Set(Tsk.Duration, project.GetDuration(2, TimeUnitType.Day)); manager.UpdateProject(project); } catch (ProjectOnlineException ex) { Console.WriteLine("Failed to update the project. Error: " + ex); } // ExEnd:UpdateProjectServer catch (NotSupportedException ex) { Console.WriteLine( ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http://www.aspose.com/purchase/default.aspx."); } }
public static void Run() { //ExStart:ReadingProjectOnline string sharepointDomainAddress = "https://contoso.sharepoint.com"; string userName = "******"; string password = "******"; var credentials = new ProjectServerCredentials(sharepointDomainAddress, userName, password); var reader = new ProjectServerManager(credentials); var list = reader.GetProjectList(); foreach (var p in list) { var project = reader.GetProject(p.Id); Console.WriteLine("{0} - {1} - {2}", p.Name, p.CreatedDate, p.LastSavedDate); Console.WriteLine("Resources count: {0}", project.Resources.Count); } //ExEnd:ReadingProjectOnline }
public void ReadingProjectOnline() { try { // ExStart:ReadingProjectOnline // ExFor: ProjectServerManager.#ctor(ProjectServerCredentials) // ExFor: ProjectServerManager.GetProjectList // ExFor: ProjectServerManager.GetProject(Guid) // ExFor: ProjectServerManager.GetProjectRawData(Guid) // ExSummary: Shows how to read a project from Microsoft Project Online. const string SharepointDomainAddress = "https://contoso.sharepoint.com/sites/pwa"; const string UserName = "******"; const string Password = "******"; var credentials = new ProjectServerCredentials(SharepointDomainAddress, UserName, Password); var manager = new ProjectServerManager(credentials); IEnumerable <ProjectInfo> list = manager.GetProjectList(); foreach (var info in list) { var project = manager.GetProject(info.Id); Console.WriteLine("{0} - {1} - {2}", info.Name, info.CreatedDate, info.LastSavedDate); Console.WriteLine("Resources count: {0}", project.Resources.Count); // an user can read the project as raw data stream var stream = manager.GetProjectRawData(info.Id); // work with raw project data } // ExEnd:ReadingProjectOnline } catch (ProjectOnlineException ex) { Console.WriteLine(ex.Message); } }