将数据导入企业自定义字段/查找表

时间:2017-08-09 12:12:37

标签: c# project ms-project

我有问题。我想将数据从SQL / Excel导入到查找表中,让企业自定义字段查找。

我正在使用Microsoft Project 2016 Professional / Online。

我使用C#示例来读取表及其条目。但是我无法添加到表格中。也许有人对此类问题有建议/样本?

  SvcLookupTable.LookupTableDataSet lutDs = new SvcLookupTable.LookupTableDataSet();
        LookupEntryCreationInformation creationInfo = new LookupEntryCreationInformation();
        LookupEntryValue entryValue = new LookupEntryValue();
        Guid entryTableGuid = new Guid("417552b5-7877-e711-80ce-00155d40cd19");
        Console.WriteLine("---------------Lookup Tables---------------");
        LookupTableCollection lookupTables = projContext.LookupTables;
        projContext.Load(lookupTables);
        projContext.ExecuteQuery();

        entryValue.TextValue = "ITS";
        creationInfo.Value = entryValue;
        creationInfo.Id = entryTableGuid;

        LookupTableCollection lookupTablesColl = projContext.LookupTables;
        projContext.Load(lookupTables);
        projContext.ExecuteQuery();
        int numTables = projContext.LookupTables.Count;
        LookupTable lookTable = lookupTables[numTables-1];



        Guid rowGuid = new Guid();

        foreach (Microsoft.ProjectServer.Client.LookupTable lt in lookupTables)
        {

            Console.WriteLine(lt.Name + " {" + lt.Id + "}");


            ImportLookupTable importTable = new ImportLookupTable();
            importTable.AddLookupTableValues(lutDs, rowGuid, rowGuid,"ITS","Skyr");
            projContext.Load(lt.Entries);
            projContext.ExecuteQuery();

             foreach (LookupEntry entry in lt.Entries)
             {

                 Console.WriteLine("    " + entry.FullValue + " {" + entry.Id + "}");

             }
        }

0 个答案:

没有答案