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."); } }