CustomFields.CreateCustomFields 方法

创建企业自定义域。

命名空间:  WebSvcCustomFields
程序集:  ProjectServerServices(位于 ProjectServerServices.dll 中)

语法

声明
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/CustomFields/CreateCustomFields", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/",  _
    ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub CreateCustomFields ( _
    cfds As CustomFieldDataSet, _
    validateOnly As Boolean, _
    autoCheckIn As Boolean _
)
用法
Dim instance As CustomFields
Dim cfds As CustomFieldDataSet
Dim validateOnly As Boolean
Dim autoCheckIn As Boolean

instance.CreateCustomFields(cfds, validateOnly, _
    autoCheckIn)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/CustomFields/CreateCustomFields", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/CustomFields/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void CreateCustomFields(
    CustomFieldDataSet cfds,
    bool validateOnly,
    bool autoCheckIn
)

参数

  • validateOnly
    类型:System.Boolean

    如果true,而无需创建自定义字段验证CustomFieldDataSet 。

  • autoCheckIn
    类型:System.Boolean

    如果true,签入后自己创建的自定义域。

备注

用于创建自定义字段的属性的说明,请参阅CustomFieldDataSet.CustomFieldsRow

警告

CreateCustomFields方法和CreateCustomFields2方法,以及Project Web App,所有允许您创建企业项目自定义域的类型标志,并设置将工作流控制的自定义字段。但是,Project Server 工作流无法控制标志自定义域。不应设置项目自定义域类型的工作流控制的标志。

提示

CreateCustomFields方法将忽略运行 Project Server 的计算机的区域设置。CreateCustomFields2方法可用于计算自定义域和图形指示器的公式的区域设置相关的值。

Project Server 权限

权限

说明

ManageEnterpriseCustomFields

允许用户修改企业自定义域和查阅表格值的定义。全局权限。

示例

下面的示例使用CustomFieldWS作为对Custom Fields web 服务 (https://ServerName/ProjectServerName/_vti_bin/psi/CustomFields.asmx) 的 web 引用的名称。btnCustomField_Click事件处理程序是一个 Windows 窗体应用程序,如LoginDemo Project SDK 下载中的按钮。

using PSLibrary = Microsoft.Office.Project.Server.Library;
. . .
private Guid customFieldUid;
. . .
private void btnCustomField_Click(object sender, EventArgs e)
{
    string cfName = "Test Task Cost";
    Guid entityTypeUid = new Guid(PSLibrary.EntityCollection.Entities.TaskEntity.UniqueId);
    lookupTableUid = Guid.Empty;
    ltRowDefaultUid = Guid.Empty;
    byte cfType = (byte)PSLibrary.CustomField.Type.COST;
    byte rollup = (byte)PSLibrary.CustomField.SummaryRollup.Sum;

    customFieldUid = CreateCustomField(
        customFields, cfName,
        entityTypeUid, lookupTableUid, ltRowDefaultUid,
        cfType, rollup);
}

// Test method for creating a custom field.
public Guid CreateCustomField(
    CustomFieldsWS.CustomFields customFields,
    string cfName,
    Guid entityTypeUid,
    Guid lookupTableUid,
    Guid ltRowDefaultUid,
    byte cfType,
    byte rollup
    )
{
    CustomFieldsWS.CustomFieldDataSet customFieldDataSet =
        new CustomFieldsWS.CustomFieldDataSet();
    CustomFieldsWS.CustomFieldDataSet.CustomFieldsRow cfRow =
        customFieldDataSet.CustomFields.NewCustomFieldsRow();
    Guid cfUid = Guid.NewGuid();

    cfRow.MD_PROP_UID = cfUid;
    cfRow.MD_AGGREGATION_TYPE_ENUM = rollup;
    cfRow.MD_ENT_TYPE_UID = entityTypeUid;
    cfRow.MD_PROP_NAME = cfName;
    cfRow.MD_PROP_IS_REQUIRED = false;
    cfRow.MD_PROP_IS_LEAF_NODE_ONLY = false;
    cfRow.MD_PROP_TYPE_ENUM = cfType;

    if (lookupTableUid == Guid.Empty)
        cfRow.SetMD_LOOKUP_TABLE_UIDNull();
    else
        cfRow.MD_LOOKUP_TABLE_UID = lookupTableUid;

    if (ltRowDefaultUid == Guid.Empty)
        cfRow.SetMD_PROP_DEFAULT_VALUENull();
    else
        cfRow.MD_PROP_DEFAULT_VALUE = ltRowDefaultUid;

    customFieldDataSet.CustomFields.Rows.Add(cfRow);

    try
    {
        bool validateOnly = false;
        bool autoCheckIn = true;
        customFields.CreateCustomFields(customFieldDataSet, validateOnly, autoCheckIn);
    }
    catch (SoapException ex)
    {
        // Add exception handler for ex.
        cfUid = Guid.Empty;
    }
tch (Exception ex)
    {
        // Add exception handler for ex.
        cfUid = Guid.Empty;
    }
    return cfUid;
}

另请参阅

引用

CustomFields 类

CustomFields 成员

WebSvcCustomFields 命名空间

CreateCustomFields2(CustomFieldDataSet, Boolean, Boolean)

其他资源

Local and Enterprise Custom Fields

How to: Create an Enterprise Custom Field