1

我尝试使用 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();
    }

任何人都可以解释这个问题或提供工作代码部分。

4

1 回答 1

0

我想提出以下建议:

定义企业项目类型:

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);

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

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

希望对你有帮助

于 2016-07-11T07:56:21.367 回答