LookupTableCollection-Klasse

Stellt eine Auflistung von LookupTable -Objekten dar.

Vererbungshierarchie

System.Object
  Microsoft.SharePoint.Client.ClientObject
    Microsoft.SharePoint.Client.ClientObjectCollection
      Microsoft.SharePoint.Client.ClientObjectCollection<LookupTable>
        Microsoft.ProjectServer.Client.LookupTableCollection

Namespace:  Microsoft.ProjectServer.Client
Assembly:  Microsoft.ProjectServer.Client (in Microsoft.ProjectServer.Client.dll)

Syntax

'Declaration
<ScriptTypeAttribute("PS.LookupTableCollection", ServerTypeId := "{95cc6d14-55c8-4357-9f21-8cc8f0c33c71}")> _
Public Class LookupTableCollection _
    Inherits ClientObjectCollection(Of LookupTable)
'Usage
Dim instance As LookupTableCollection
[ScriptTypeAttribute("PS.LookupTableCollection", ServerTypeId = "{95cc6d14-55c8-4357-9f21-8cc8f0c33c71}")]
public class LookupTableCollection : ClientObjectCollection<LookupTable>

Beispiele

Im folgenden Codebeispiel wird eine Konsolenanwendung, die fragt die Nachschlagetabellen in einer Instanz der Project Web App -Auflistung und zeigt Informationen zu den codeformaten und die Einträge für eine angegebene Nachschlagetabelle. Die Variable projLutCollection ist ein LookupTableCollection -Objekt.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ProjectServer.Client;

namespace ReadLookupTable
{
    class Program
    {
        // Change the path for your Project Web App instance.
        private const string PWA_PATH = "https://ServerName/pwa/";    
        private static string lutName = "Department";    // Default lookup table to read.

        // Set the Project Server client context.
        private static ProjectContext projContext;

        static void Main(string[] args)
        {

            if (!ParseCommandLine(args))
            {
                Usage();
                ExitApp();
            }
            projContext = new ProjectContext(PWA_PATH);

            var projLutCollection = projContext.LoadQuery(
                projContext.LookupTables
                    .Where(lut => lut.Name == lutName));

            projContext.ExecuteQuery();

            if (projLutCollection.Count() > 0)
            {
                foreach (LookupTable lut in projLutCollection)
                {
                    Console.WriteLine("'{0}' lookup table Id: {1}", lut.Name, lut.Id);
                    Console.WriteLine("\tField type: {0}", lut.FieldType);

                    // Get the lookup table mask data:
                    Console.WriteLine("\nNumber of '{0}' lookup table masks: {1}\n", lut.Name, lut.Masks.Count());

                    foreach (LookupMask lutMask in lut.Masks)
                    {
                        Console.WriteLine("\tMaskType: {0}\tLength: {1}\tSeparator: {2}", 
                            lutMask.MaskType, lutMask.Length, lutMask.Separator);
                    }

                    // Get the collection of lookup table entries.
                    projContext.Load(lut.Entries);
                    projContext.ExecuteQuery();

                    Console.WriteLine("\nNumber of '{0}' lookup table entries: {1}", lut.Name, lut.Entries.Count());

                    foreach (LookupEntry lutEntry in lut.Entries)
                    {
                        Console.WriteLine("\n\t{0}, SortIndex: {1}\n\tFullValue: {2}",
                            lutEntry.Id, lutEntry.SortIndex.ToString("F0"), lutEntry.FullValue);
                    }
                }
            }
            else
            {
                Console.WriteLine("No lookup table named '{0}'", lutName);
            }

            ExitApp();   
        }

        private static void ExitApp()
        {
            Console.Write("\nPress any key to exit... ");
            Console.ReadKey(true);
            Environment.Exit(0);
        }

        // Parse the command line. Return true if there are no errors.
        private static bool ParseCommandLine(string[] args)
        {
            bool error = false;
            int argsLen = args.Length;

            try
            {
                for (int i = 0; i < argsLen; i++)
                {
                    if (error) break;
                    if (args[i].StartsWith("-") || args[i].StartsWith("/"))
                        args[i] = "*" + args[i].Substring(1).ToLower();

                    switch (args[i])
                    {
                        case "*lookuptable":
                        case "*lut":
                            if (++i >= argsLen) return false;
                            lutName = args[i];
                            break;
                        case "*?":
                        default:
                            error = true;
                            break;
                    }
                }
            }
            catch (FormatException)
            {
                error = true;
            }
            return !error;
        }

        private static void Usage()
        {
            string example = "Usage: ReadLookupTable [/lookuptable | /lut \"LookupTable Name\"";
            example += "\n\nExample: ReadLookupTable /lut \"Department\"";
            Console.WriteLine(example);
        }
    }
}

Angenommen Sie, dass die Nachschlagetabelle Abteilung den folgenden Code Masken und Nachschlagetabellenwerte enthält:

Sequence              Length          Separator
_______________________________________________
Characters            Any             .
Uppercase Letters     2               .

Level              Value
______________________________
1                  Test Dept 1
1                  Test Dept 2
1                  Test Dept C
2                      CA
2                      CB

Es folgt die Ausgabe der ReadLookupTable Anwendung (die GUIDs für die Einträge würde unterscheiden).

Hinweis

Da die Nachschlagetabelle Abteilung integriert ist, ist die GUID der Nachschlagetabelle Abteilung in allen Project Web App Instanzen gleich. Die GUID ist der Wert des Felds Microsoft.Office.Project.Server.Library.LookupTables.DEPARTMENTS_LT_UID .

'Department' lookup table Id: e7397277-1ab0-4096-b2dd-57029a055ba4
        Field type: TEXT

Number of 'Department' lookup table masks: 2

        MaskType: CHARACTERS    Length: 0       Separator: .
        MaskType: UPPERCASE     Length: 2       Separator: .

Number of 'Department' lookup table entries: 5

        bbc07ff5-b06d-e211-93f4-0021704e28a0, SortIndex: 1
        FullValue: Test Dept 1

        bcc07ff5-b06d-e211-93f4-0021704e28a0, SortIndex: 2
        FullValue: Test Dept 2

        bdc07ff5-b06d-e211-93f4-0021704e28a0, SortIndex: 3
        FullValue: Test Dept C

        0a6ef8d8-6871-e211-93f4-0021704e28a0, SortIndex: 4
        FullValue: Test Dept C.CA

        0b6ef8d8-6871-e211-93f4-0021704e28a0, SortIndex: 5
        FullValue: Test Dept C.CB

Press any key to exit...

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic) Member dieses Typs sind threadsicher. Die Threadsicherheit von Instanzmembern ist nicht gewährleistet.

Siehe auch

Referenz

LookupTableCollection-Member

Microsoft.ProjectServer.Client-Namespace

LookupTable

LookupTableCreationInformation

LookupTables