我正在尝试使用我的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);
答案 0 :(得分: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);
并且一切顺利。看起来您只能将任务添加到未初始化的项目中。