Hello Reader,
The following code is used to create a new Enterprise Project Type(EPT):
public void CreateEnterpriseProjectType(Guid eptGuid, string eptName, string eptDescription)
{
ProjectContext projectContext = new ProjectContext("http://serverName/pwaName");
// for project online authentication
SecureString securePassword = new SecureString();
foreach (char ch in "adminPassword")
securePassword.AppendChar(ch);
SharePointOnlineCredentials sharePointOnlineCredentials = new SharePointOnlineCredentials("adminUsername", securePassword);
projectContext.Credentials = sharePointOnlineCredentials;
projectContext.Load(projectContext.EnterpriseProjectTypes);
projectContext.Load(projectContext.ProjectDetailPages);
projectContext.ExecuteQuery();
EnterpriseProjectTypeCreationInformation eptInfo = new EnterpriseProjectTypeCreationInformation();
eptInfo.Id = eptGuid;
eptInfo.Name = eptName;
eptInfo.Description = eptDescription;
eptInfo.IsDefault = true;
eptInfo.WorkspaceTemplateName = "PROJECTSITE#0";
eptInfo.ProjectPlanTemplateId = Guid.Empty;
eptInfo.WorkflowAssociationId = Guid.Empty;
eptInfo.Order = 1;
List<ProjectDetailPageCreationInformation> projectDetailPages = new List<ProjectDetailPageCreationInformation>() {new ProjectDetailPageCreationInformation() { Id = projectContext.ProjectDetailPages[1].Id, IsCreate = false }};
eptData.ProjectDetailPages = projectDetailPages;
EnterpriseProjectType newEpt = projectContext.EnterpriseProjectTypes.Add(eptInfo);
projectContext.EnterpriseProjectTypes.Update();
projectContext.ExecuteQuery();
}
I hope, it helps.
2 Comment(s)