LookupTable.UpdateLookupTables 方法

创建、 修改或删除自定义域查阅表格中的数据。UpdateLookupTables创建查阅表格和对应的代码掩码,如果LookupTableDataSet包括新的查阅表格,修改现有的查阅表格,并删除不在LookupTableDataSet的查阅表格。

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

语法

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

instance.UpdateLookupTables(ltds, validateOnly, _
    autoCheckIn, language)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/LookupTable/UpdateLookupTables", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/LookupTable/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/LookupTable/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void UpdateLookupTables(
    LookupTableDataSet ltds,
    bool validateOnly,
    bool autoCheckIn,
    int language
)

参数

备注

UpdateLookupTables更新现有查阅表格中的数据。若要创建或删除查阅表格,还可以使用CreateLookupTablesDeleteLookupTables

若要删除查阅表格值,首先使用ReadLookupTablesByUids方法获取完整LookupTableDataSet,然后使用LookupTableDataSet.LookupTableTrees.Rows[index].Delete方法,将标记为删除的行。请参阅示例部分。

若要更新一个或多个查阅表格,使用ReadLookupTablesByUids获取所有模拟运算表需要对每个查阅表格,然后修改返回的LookupTableDataSet用于UpdateLookupTables中的ltds参数。

您可以为xmlFilter参数与空引用(无 在 Visual Basic 中)使用ReadLookupTables 。在以下示例中, lookupTableLookupTableWebService.LookupTable类的实例,并且lookupTableDataSetLookupTableDataSet的实例。

bool autoCheckOut = false;
string xmlFilter = null;
int language = 0;
lookupDataSet = lookupTable.ReadLookupTables(xmlFilter, autoCheckOut, language);
// Add, delete, or modify lookup table rows 
bool validateOnly = false;
autoCheckOut = true;
lookupTable.UpdateLookupTables(lookupTableDataSet, validateOnly, autoCheckOut, language);
// Call lookupTable.CheckInLookupTables

备注

如果您使用ReadLookupTables并指定xmlfilter值时,您可能无法获得的所有表所必需的更新。在这种情况下, UpdateLookupTables导致一般未经处理的异常。

警告

当您使用 PSI 创建或更新的号码的查阅表格时,不要添加具有两个以上小数位的值。

UpdateLookupTables方法,可以保存的两个以上小数位的数字。创建使用号码的查阅表格的自定义字段时, Project Professional 2010舍入为两个小数位的数字自定义域值,并显示它们以在下拉列表中选择一个值的字符串。选择一个值时, Project Professional 2010将字符串转换回数字。进程显示错误,因为不存在的只有两个小数位的数字值。

Project Server 权限

权限

说明

ManageEnterpriseCustomFields

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

示例

The following example reads a specified lookup table and deletes a specified row in the table. The lookupTable parameter in the DeleteLookupTableRow sample method is a LookupTable object with valid Url and Credentials properties. The language parameter is an integer for the LCID; for example, 1033 is U.S. English. LookupTableWebSvc is an arbitrary reference name to the LookupTable.asmx Web service. For more information about using the code sample, see Project 2013 中基于 ASMX 的代码示例的先决条件.

public string DeleteLookupTableRow(SvcLookupTable.LookupTable lookupTable,
    Guid lutGuid, int row, int language)
{
    string result = "";
    string fmtResult = "Lookup table: {0}. ";
    string tableName = "[unknown]";
    string rowName = "";

    SvcLookupTable.LookupTableDataSet lutDs = new SvcLookupTable.LookupTableDataSet();

    Guid[] lutList = new Guid[] { lutGuid };
    bool autoCheckOut = false;

    lutDs = lookupTable.ReadLookupTablesByUids(lutList, autoCheckOut, language);
    int numRows = lutDs.LookupTableTrees.Rows.Count;

    foreach (DataRow lutRow in lutDs.LookupTables)
    {
        if ((Guid)lutRow[lutDs.LookupTables.LT_UIDColumn] == lutGuid)
        {
            tableName = (string)lutRow[lutDs.LookupTables.LT_NAMEColumn];
            break;
        }
    }

    if (row < numRows)
    {
        rowName = lutDs.LookupTableTrees[row].LT_VALUE_TEXT;
        lutDs.LookupTableTrees.Rows[row].Delete();

        lookupTable.CheckOutLookupTables(lutList);
        bool validateOnly = false;
        lookupTable.UpdateLookupTables(lutDs, validateOnly, autoCheckOut, language);
        bool forceCheckIn = false;
        lookupTable.CheckInLookupTables(lutList, forceCheckIn);

        fmtResult += "Row {1} deleted: {2}";
        result = string.Format(fmtResult, tableName, row, rowName);
    }
    else
    {
        fmtResult += "Requested row {1} greater than number of rows {2}.";
        result = string.Format(fmtResult, tableName, row, numRows);
    }
    return result;
}

另请参阅

引用

LookupTable 类

LookupTable 成员

WebSvcLookupTable 命名空间

其他资源

Locale ID (LCID) Chart

Walkthrough: Creating a Hierarchical Lookup Table