【问题标题】:How to create New EPT by using CSOM如何使用 CSOM 创建新的 EPT
【发布时间】:2023-03-19 08:22:01
【问题描述】:

我尝试使用 C# CSOM 库创建一个新的 EPT(项目服务器 2013)。 但它发生了以下错误。

“PJClientCallableException:EnterpriseProjectTypeInvalidCreatePDPUid”

几篇文章告诉要更改“IsCreate=true”。但这对我来说并不成功。这是我所做的代码。

public void CreateEnterpriseProjectType(Guid eptGuid, string eptName, string eptDescription)
    {
        ProjectContext pwaContext = new ProjectContext(this.PWA_URL);

        EnterpriseProjectTypeCreationInformation eptData = new EnterpriseProjectTypeCreationInformation();

        eptData.Id = eptGuid;
        eptData.Name = eptName;
        eptData.Description = eptDescription;
        eptData.IsDefault = false;
        eptData.IsManaged = true;
        eptData.WorkspaceTemplateName = "PROJECTSITE#0";
        eptData.ProjectPlanTemplateId = Guid.Empty;
        eptData.WorkflowAssociationId = Guid.Empty;
        eptData.Order = 4;

        List<ProjectDetailPageCreationInformation> projectDetailPages = new
        List<ProjectDetailPageCreationInformation>() { 
            new ProjectDetailPageCreationInformation() { 
                Id = pwaContext.ProjectDetailPages[1].Id, IsCreate = true } 
        };
        eptData.ProjectDetailPages = projectDetailPages;

        pwaContext.Load(pwaContext.EnterpriseProjectTypes);
        pwaContext.ExecuteQuery();
        EnterpriseProjectType newEpt = pwaContext.EnterpriseProjectTypes.Add(eptData);
        pwaContext.EnterpriseProjectTypes.Update();
        pwaContext.ExecuteQuery();
    }

谁能解释这个问题或提供工作代码部分。

【问题讨论】:

    标签: c# sharepoint-2013 csom project-server ms-project-server-2013


    【解决方案1】:

    我想提出以下建议:

    定义企业项目类型:

    string basicEpt = "Enterprise Project"; // Basic enterprise project type.
    int timeoutSeconds = 10;  // The maximum wait time for a queue job, in seconds.
    

    然后,当你创建新项目时,像这样工作:

    ProjectCreationInformation newProj = new ProjectCreationInformation();
    
                newProj.Id = Guid.NewGuid();
                newProj.Name = "Project Name";
                newProj.Description = "Test creating a project with CSOM";
                newProj.Start = DateTime.Today.Date;
    
    
                // Setting the EPT GUID is optional. If no EPT is specified, Project Server  
                // uses the default EPT. 
                newProj.EnterpriseProjectTypeId = GetEptUid(basicEpt);
    
                PublishedProject newPublishedProj = projContext.Projects.Add(newProj);
                QueueJob qJob = projContext.Projects.Update();
    
                // Calling Load and ExecuteQuery for the queue job is optional.
                // projContext.Load(qJob);
                // projContext.ExecuteQuery();
                JobState jobState = projContext.WaitForQueue(qJob, timeoutSeconds);
    

    当那段代码的最后一行结束时,必须创建和发布项目才能定义任务或其他内容。

    我不知道你的代码发生了什么,看起来不错。

    希望对你有帮助,

    【讨论】:

    • 我发现使用您的代码,无论您指定什么basicEpt,项目仍然创建为企业项目......因此只有管理员可以使用该站点,直到手动更改它。你知道怎么改吗?
    • 我认为这是一个 SharePoint 问题。如果我理解你的问题,你的意思是让其他不同的用户而不是管理员访问 PWA?
    • 我在这里发布了一个问题来进一步解释我的意思:stackoverflow.com/questions/39953710/…,但基本上是的,当项目创建时,企业项目功能需要手动取消激活。我希望在创作时完成。 (PWA 设置 -> 连接的 Sharepoint 站点)是此选项所在的位置。也感谢回复
    猜你喜欢
    • 2015-11-03
    • 1970-01-01
    • 2014-10-17
    • 1970-01-01
    • 2017-10-25
    • 2016-06-19
    • 1970-01-01
    • 2017-04-04
    • 1970-01-01
    相关资源
    最近更新 更多