How to created Project Server in Sharepoint Project Server
Nghia Song - Microsoft Dynamics 365 Technical Consultant
Nghia Song
Tel - WhatsApp: +84967324794
Email: songnghia.uit@gmail.com
Nghia Song
Tel - WhatsApp: +84967324794
Email: songnghia.uit@gmail.com
private void createproject_Click (object sender, EventArgs e) { // create PWA context projContext = new ProjectContext(pwaPath); // Access with default logged in credentials projContext.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; try { ProjectCreationInformation newProj = new ProjectCreationInformation(); newProj.Id = Guid.NewGuid(); newProj.Name = txtProjectName.Text; newProj.Description = txtProjectDesc.Text; newProj.Start = DateTime.Today.Date; newProj.EnterpriseProjectTypeId = GetEptUid(basicEpt); PublishedProject newPublishedProj = projContext.Projects.Add(newProj); QueueJob qJob = projContext.Projects.Update(); projContext.Load(qJob); projContext.Load(projContext.Projects); projContext.ExecuteQuery(); JobState jobState = projContext.WaitForQueue(qJob, timeoutSeconds); label1.ForeColor = Color.Green; label1.Text = "Successfully created project-" + txtProjectName.Text; txtProjectDesc.Text = ""; txtProjectName.Text = ""; //LoadProjects(projContext); } catch (Exception ex) { label1.ForeColor = Color.Red; label1.Text = ex.Message.ToString(); } } //Get/Read the GUID of the specified enterprise project type. private static Guid GetEptUid(string eptName) { Guid eptUid = Guid.Empty; try { projContext.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; var eptList = projContext.LoadQuery( projContext.EnterpriseProjectTypes.Where( ept => ept.Name == eptName)); projContext.ExecuteQuery(); eptUid = eptList.First().Id; } catch (Exception ex) { string msg = string.Format("GetEptUid: eptName = \"{0}\"\n\n{1}",eptName, ex.GetBaseException().ToString()); throw new ArgumentException(msg); } return eptUid; }