0

您好,我想实用地编辑 Project Server 2010 的自定义字段,但我不知道我在哪里做错了。以下是代码,

请在这方面帮助我

ProjectSoapClient projectSvc = new ProjectSoapClient();
            CustomFieldsSoapClient customfieldSvc = new CustomFieldsSoapClient();
            CustomFieldDataSet fieldDefs = customfieldSvc.ReadCustomFields(string.Empty, false);

Guid projectId = new Guid(projGuid);
            ProjectDataSet projectDs = projectSvc.ReadProject(projectId, ListProjects.Project.DataStoreEnum.WorkingStore);

        foreach (ProjectDataSet.ProjectCustomFieldsRow cfRow in projectDs.ProjectCustomFields.Rows)
        {
            CustomFieldDataSet.CustomFieldsRow fieldDefinition = fieldDefs.CustomFields.Single(
                    cfd => cfd.MD_PROP_UID == cfRow.MD_PROP_UID);

            //if (cfRow.FIELD_TYPE_ENUM == 21 || cfRow.FIELD_TYPE_ENUM == 15) //if it is a choice field
            //{
                if (fieldDefinition.MD_PROP_NAME == "ProductCategory")
                {
                    cfRow.TEXT_VALUE = newValue;
                }
            //}
        }
        Guid sessionUid = Guid.NewGuid();
        Guid jobUid = Guid.NewGuid();
        if (!IsProjectCheckedOut(projectId))
        {
            projectSvc.CheckOutProject(projectId, sessionUid, "Updating CF");
            jobUid = Guid.NewGuid();
            projectSvc.QueueUpdateProject(jobUid, sessionUid, projectDs, false);
        }
        jobUid = Guid.NewGuid();
        projectSvc.QueuePublish(jobUid, projectId, true, SPContext.Current.Site.Url);
        projectSvc.QueueCheckInProject(jobUid, projectId, true, sessionUid, "Updating CF");
4

1 回答 1

0

也许是因为你先发布了项目。它也仅适用于 QueueCheckInProject 函数。

另一个原因可能是,您在迭代中搜索的行尚不可用,您必须先将其添加到项目数据集中!

您应该等待完成结帐、更新和签入!

查看我的博客文章了解更多详情: http ://www.geeklife.ch/dev/update-project-server-2010-customfields-over-psi/

或者我在这个线程中的回答: 使用 PSI 设置自定义字段 - Microsoft Project Server

于 2013-07-10T13:29:39.570 回答