共用方式為


CustomFieldDataSet.CustomFieldsRow.MD_PROP_TYPE_ENUM 屬性

取得或設定自訂欄位的類型。

命名空間:  WebSvcCustomFields
組件:  ProjectServerServices (在 ProjectServerServices.dll 中)

語法

'宣告
Public Property MD_PROP_TYPE_ENUM As Byte
    Get
    Set
'用途
Dim instance As CustomFieldDataSet.CustomFieldsRow
Dim value As Byte

value = instance.MD_PROP_TYPE_ENUM

instance.MD_PROP_TYPE_ENUM = value
public byte MD_PROP_TYPE_ENUM { get; set; }

屬性值

類型:System.Byte
自訂欄位類型。

備註

**[MD_PROP_TYPE_ENUM]可以是下列其中一個下列的自訂欄位類型: 成本、 日期、 工期、 旗標、 數字或文字。文字類型的自訂欄位可以有階層式查閱表格。類型標幟] 自訂欄位無法使用查閱表格。設定[MD_PROP_TYPE_ENUM]**與Microsoft.Office.Project.Server.Library.CustomField.Type列舉。

範例

下列範例會使用CustomFieldWS為 web 參考 (英文) 至自訂欄位web 服務 (https://ServerName/ProjectServerName/_vti_bin/psi/CustomFields.asmx) 的名稱。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;
    }
    catch (Exception ex)
    {
        // Add exception handler for ex.
        cfUid = Guid.Empty;
    }
    return cfUid;
}

請參閱

參照

CustomFieldDataSet.CustomFieldsRow 類別

CustomFieldDataSet.CustomFieldsRow 成員

WebSvcCustomFields 命名空間

其他資源

How to: Create an Enterprise Custom Field