0

我正在尝试使用我的 MSDN 提供的代码通过 PSI 在现有项目中创建任务:http: //msdn.microsoft.com/en-us/library/office/ms487478 (v=office.12).aspx#pj12_PDSPSIExamples_Task

问题是我在尝试调用 projectClient.QueueUpdateProject(jobId, sessionId, project, false); 时收到错误“GeneralOnlyUpdatesAllowed”;

有什么想法吗?

 Guid sessionId = Guid.NewGuid();
            Guid jobId = Guid.NewGuid();
            string SESSION_DESC = "MSP-DAX Synchronization";                
            backendProject.ProjectDataSet project = projectClient.ReadProject(task.ProjectId, backendProject.DataStoreEnum.WorkingStore);                   
            projectClient.CheckOutProject(task.ProjectId, sessionId, SESSION_DESC);
            backendProject.ProjectDataSet.TaskRow taskRow = project.Task.NewTaskRow();
            taskRow.PROJ_UID = task.ProjectId;
            taskRow.TASK_UID = Guid.NewGuid();
            taskRow.TASK_NAME = task.Subject;
            taskRow.CREATED_DATE = task.Date;
            taskRow.TASK_DUR_FMT = (int)PSLibrary.Task.DurationFormat.Hour;          
            project.Task.AddTaskRow(taskRow);                            
            projectClient.QueueUpdateProject(jobId, sessionId, project, false);//here is the error
            //projectClient.QueueAddToProject(jobId, sessionId, project, false);
            WaitForQueue(queueSystemClient, jobId);
            jobId = Guid.NewGuid();
            projectClient.QueueCheckInProject(jobId, task.ProjectId, false, sessionId, SESSION_DESC);
            WaitForQueue(queueSystemClient, jobId);
4

1 回答 1

0

奇怪的行为,但无论如何。我更改了以下行:

backendProject.ProjectDataSet project = projectClient.ReadProject(task.ProjectId,            backendProject.DataStoreEnum.WorkingStore);
projectClient.QueueUpdateProject(jobId, sessionId, project, false);

与这些:

backendProject.ProjectDataSet project = new backendProject.ProjectDataSet();
projectClient.QueueAddToProject(jobId, sessionId, project, false);

一切正常。看起来您只能将任务添加到未初始化的项目中。

于 2013-09-09T10:42:59.953 回答