public void CreateProjectInProjectServer() { // ExStart:CreateProjectInProjectServer // ExFor: ProjectOnlineException // ExFor: ProjectOnlineException.#ctor(SerializationInfo,StreamingContext) // ExSummary: Shows how to catch exception while reading a project from MS Project Online. try { const string URL = "https://project_server.local/sites/pwa"; const string Domain = "CONTOSO.COM"; const string UserName = "******"; const string Password = "******"; var project = new Project(DataDir + @"Project1.mpp"); var windowsCredentials = new NetworkCredential(UserName, Password, Domain); var projectServerCredentials = new ProjectServerCredentials(URL, windowsCredentials); var manager = new ProjectServerManager(projectServerCredentials); manager.CreateNewProject(project); } catch (ProjectOnlineException ex) { Console.WriteLine(ex.Message); } // ExEnd:CreateProjectInProjectServer 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 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 ProjectServerManagerCreateNewProject() { // ExStart:ProjectServerManagerCreateNewProject // ExFor: ProjectServerManager.CreateNewProject(Project) // ExSummary: Shows how to use Project Server manager to create a new project on 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 project = new Project(DataDir + @"Project1.mpp"); var manager = new ProjectServerManager(credentials); manager.CreateNewProject(project); } catch (ProjectOnlineException ex) { Console.WriteLine(ex.Message); } // ExEnd:ProjectServerManagerCreateNewProject }
public void ProjectServerManager() { // ExStart:CreateProjectOnline // ExFor: ProjectServerManager // ExFor: ProjectServerManager.CreateNewProject(Project,ProjectServerSaveOptions) // ExSummary: Shows how to use Project Server manager to create a new project with predefined save options on 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 project = new Project(DataDir + @"Project1.mpp"); var manager = new ProjectServerManager(credentials); var options = new ProjectServerSaveOptions { Timeout = TimeSpan.FromSeconds(10) }; manager.CreateNewProject(project, options); } catch (ProjectOnlineException ex) { Console.WriteLine(ex.Message); } // ExEnd:CreateProjectOnline }
public static void Run() { // ExStart:CreateProjectOnline string sharepointDomainAddress = "https://contoso.sharepoint.com"; string userName = "******"; string password = "******"; var credentials = new ProjectServerCredentials(sharepointDomainAddress, userName, password); var project = new Project(@"sample.mpp"); ProjectServerManager manager = new ProjectServerManager(credentials); manager.CreateNewProject(project); // ExEnd:CreateProjectOnline }
public void CreateProjectInProjectServer2() { // ExStart // ExFor: ProjectServerCredentials.#ctor(String,String) // ExFor: ProjectServerCredentials.AuthToken // ExFor: ProjectServerCredentials.SiteUrl // ExFor: ProjectServerCredentials.UserName // ExSummary: Shows how to use Project Server credentials with SharePointOnlineCredentials to create project in Microsoft Project Online. try { const string Username = "******"; const string SecuredPassword = "******"; var url = new Uri("https://contoso.sharepoint.com/sites/pwa"); var project = new Project(DataDir + "Project1.mpp"); var password = new SecureString(); foreach (var c in SecuredPassword) { password.AppendChar(c); } var onlineCredentials = new SharePointOnlineCredentials(Username, password); var projectServerCredentials = new ProjectServerCredentials(url.ToString(), onlineCredentials.GetAuthenticationCookie(url, true)); Console.WriteLine("Project Server Auth Token: " + projectServerCredentials.AuthToken); Console.WriteLine("Project Server Site Url: " + projectServerCredentials.SiteUrl); Console.WriteLine("Project Server User Name: " + projectServerCredentials.UserName); var manager = new ProjectServerManager(projectServerCredentials); manager.CreateNewProject(project); } catch (ProjectOnlineException ex) { Console.WriteLine(ex.Message); } // ExEnd 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."); } catch (WebException ex) { Console.WriteLine(ex.Message); } }
public static void CreateProjectInProjectServer() { // ExStart:CreateProjectInProjectServer string url = "https://contoso.sharepoint.com"; string domain = "CONTOSO.COM"; string userName = "******"; string password = "******"; var project = new Project(@"sample.mpp"); var windowsCredentials = new NetworkCredential(userName, password, domain); var projectServerCredentials = new ProjectServerCredentials(url, windowsCredentials); ProjectServerManager manager = new ProjectServerManager(projectServerCredentials); manager.CreateNewProject(project); // ExEnd:CreateProjectInProjectServer }
public void CreateProjectInProjectServerWithOptions() { // ExStart:CreateProjectInProjectServerWithOptions // ExFor: ProjectServerSaveOptions // ExFor: ProjectServerSaveOptions.#ctor // ExFor: ProjectServerSaveOptions.ProjectGuid // ExFor: ProjectServerSaveOptions.ProjectName // ExFor: ProjectServerSaveOptions.PollingInterval // ExSummary: Shows how to use <see cref="Aspose.Tasks.ProjectServerSaveOptions" /> options to create a new project in on-premise instance of Project Server. try { const string URL = "https://project_server.local/sites/pwa"; const string Domain = "CONTOSO.COM"; const string UserName = "******"; const string Password = "******"; var project = new Project(DataDir + @"Project1.mpp"); var windowsCredentials = new NetworkCredential(UserName, Password, Domain); var projectServerCredentials = new ProjectServerCredentials(URL, windowsCredentials); var manager = new ProjectServerManager(projectServerCredentials); var options = new ProjectServerSaveOptions { ProjectGuid = Guid.NewGuid(), ProjectName = "New project", Timeout = TimeSpan.FromMinutes(5), PollingInterval = TimeSpan.FromSeconds(3) }; manager.CreateNewProject(project, options); } catch (ProjectOnlineException ex) { Console.WriteLine(ex.Message); } // ExEnd:CreateProjectInProjectServerWithOptions 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."); } }