Partager via


LookupTable.ReadLookupTables - Méthode

Obtient les tables de choix de champs personnalisés et les masques de code correspondant. Le paramètre language est utilisé uniquement si xmlFilter est une chaîne vide.

Espace de noms :  WebSvcLookupTable
Assembly :  ProjectServerServices (dans ProjectServerServices.dll)

Syntaxe

'Déclaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/LookupTable/ReadLookupTables", 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 Function ReadLookupTables ( _
    xmlFilter As String, _
    autoCheckOut As Boolean, _
    language As Integer _
) As LookupTableDataSet
'Utilisation
Dim instance As LookupTable
Dim xmlFilter As String
Dim autoCheckOut As Boolean
Dim language As Integer
Dim returnValue As LookupTableDataSet

returnValue = instance.ReadLookupTables(xmlFilter, _
    autoCheckOut, language)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/LookupTable/ReadLookupTables", 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 LookupTableDataSet ReadLookupTables(
    string xmlFilter,
    bool autoCheckOut,
    int language
)

Paramètres

  • xmlFilter
    Type : System.String

    Filtre XML pour lire des données spécifiques. Une chaîne vide retourne toutes les données de table de choix.

  • autoCheckOut
    Type : System.Boolean

    Si true, extraction de fabrication change.

  • language
    Type : System.Int32

    ID de paramètres régionaux (LCID).

Valeur renvoyée

Type : WebSvcLookupTable.LookupTableDataSet

Remarques

La principale DataTable dans un LookupTableDataSet est le LookupTablesDataTable.

Notes

Le paramètre xmlFilter fonctionne avec les opérateurs Criteria pour filtrer les lignes dans le principal LookupTablesDataTableuniquement. Par exemple, vous ne pouvez pas utiliser filter avec la méthode ReadLookupTables pour filtrer les lignes dans le LookupTableTreesDataTable. Si vous essayez de filtrer les lignes dans un secondaire DataTable, PSI renvoie une exception FilterInvalid .

Toutefois, vous pouvez utiliser la méthode Fields.Add pour filtrer des colonnes dans le principal LookupTablesDataTable et secondaire en LookupTableTreesDataTable et LookupTableMasksDataTable.

For more information about the xmlFilter parameter, see How to: Use a Filter Parameter with PSI Methods.

Autorisations Project Server

Autorisation

Description

LogOnToProjectServerFromProjectProfessional

Permet à l'utilisateur de se connecter à la base de données Project Server depuis Project Professional. Autorisation globale.

ManageEnterpriseCustomFields

Permet à l'utilisateur de modifier les définitions des champs personnalisés d'entreprise et les valeurs de table de choix. Autorisation globale.

Exemples

L'exemple ReadCustomFieldsTest effectue les opérations suivantes :

  • Lit tous les champs personnalisés dans l'installation de Project Web App qui est spécifiée par l'adresse de point de terminaison dans le fichier app.config, puis écrit un fichier XML de la CustomFieldDataSet.

  • Lit les données de table de choix pour le LCID de la langue spécifiée, puis écrit un fichier XML de la LookupTableDataSet. Données XML de la table de choix contient des collections les tables suivantes : LookupTables, LookupTableMaskset LookupTableTrees.

For information about using the code sample in a Microsoft Visual Studio 2010 project and creating an app.config file for configuration of the WCF endpoints, see Prerequisites for WCF-Based Code Samples.

using System;
using System.Text;
using System.ServiceModel;
using System.Xml;
using PSLibrary = Microsoft.Office.Project.Server.Library;

namespace Microsoft.SDK.Project.Samples.ReadCustomFieldsTest
{
    class Program
    {
        private const string ENDPOINT_CUSTOMFIELDS = "basicHttp_CustomFields";
        private const string ENDPOINT_LOOKUPTABLE = "basicHttp_LookupTable";
        // Change the output directory for your computer.
        private const string OUTPUT_FILES = @"C:\Project\Samples\Output\";

        private static SvcCustomFields.CustomFieldsClient customFieldsClient;
        private static SvcLookupTable.LookupTable lookupTableClient;

        private static string outFileCustomFieldsDs;
        private static string outFileLookupTableDs;
        private static int language = 1033;         // Use the English LCID by default.

        static void Main(string[] args)
        {
            if (args.Length > 0 && args.Length < 3)
            {
                if (args[0].ToLower() == "-lcid")
                {
                    language = Convert.ToInt32(args[1]);
                }
            }

            outFileCustomFieldsDs = OUTPUT_FILES + "CustomFieldDataSet.xml";
            outFileLookupTableDs = OUTPUT_FILES + "LookupTableDataSet.xml";
            ConfigClientEndpoints(ENDPOINT_CUSTOMFIELDS);
            ConfigClientEndpoints(ENDPOINT_LOOKUPTABLE);

            try
            {
                Console.WriteLine("Reading custom fields...");
                SvcCustomFields.CustomFieldDataSet customFieldDs = 
                    customFieldsClient.ReadCustomFields2(string.Empty, false);

                Console.WriteLine(
                    "\nXML output of the CustomFieldDataSet:\n\t{0}",
                    outFileCustomFieldsDs);
                customFieldDs.WriteXml(outFileCustomFieldsDs);

                Console.WriteLine("Reading lookup tables...");
                SvcLookupTable.LookupTableDataSet lookupTableDs =
                    lookupTableClient.ReadLookupTables(string.Empty, false, language);

                Console.WriteLine(
                    "\nXML output of the LookupTableDataSet:\n\t{0}",
                    outFileCustomFieldsDs);
                lookupTableDs.WriteXml(outFileLookupTableDs);
            }
            catch (FaultException fault)
            {
                // Use the WCF FaultException, because the ASMX SoapException does not 
                // exist in a WCF-based application.
                WriteFaultOutput(fault);
            }
            catch (EndpointNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("\nInnerException: \n" + ex.InnerException.Message);
            }
            Console.Write("\nPress any key to exit... ");
            Console.ReadKey(true);
        }

        // Extract a PSClientError object from the WCF FaultException object, and
        // then display the exception details and each error in the PSClientError stack.
        private static void WriteFaultOutput(FaultException fault)
        {
            string errAttributeName;
            string errAttribute;
            string errOut;
            string errMess = "".PadRight(30, '=') + "\r\n"
                + "Error details: " + "\r\n";

            PSLibrary.PSClientError error = Helpers.GetPSClientError(fault, out errOut);
            errMess += errOut;

            if (error != null)
            {
                PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();
                PSLibrary.PSErrorInfo thisError;

                for (int i = 0; i < errors.Length; i++)
                {
                    thisError = errors[i];
                    errMess += "\r\n".PadRight(30, '=') + "\r\nPSClientError output:\r\n";
                    errMess += thisError.ErrId.ToString() + "\n";

                    for (int j = 0; j < thisError.ErrorAttributes.Length; j++)
                    {
                        errAttributeName = thisError.ErrorAttributeNames()[j];
                        errAttribute = thisError.ErrorAttributes[j];
                        errMess += "\r\n\t" + errAttributeName
                            + ": " + errAttribute;
                    }
                }
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(errMess);
            Console.ResetColor();
        }

        // Use the endpoints defined in app.config to configure the client.
        public static void ConfigClientEndpoints(string endpt)
        {
            if (endpt == ENDPOINT_CUSTOMFIELDS)
                customFieldsClient = new SvcCustomFields.CustomFieldsClient(endpt);
            else if (endpt == ENDPOINT_LOOKUPTABLE)
                lookupTableClient = new SvcLookupTable.LookupTableClient(endpt);
        }
    }

    // Helper methods
    class Helpers
    {
        /// <summary>
        /// Extract a PSClientError object from the ServiceModel.FaultException,
        /// for use in output of the GetPSClientError stack of errors.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="errOut">Shows that FaultException has more information 
        /// about the errors than PSClientError has. FaultException can also contain 
        /// other types of errors, such as failure to connect to the server.</param>
        /// <returns>PSClientError object, for enumerating errors.</returns>
        public static PSLibrary.PSClientError GetPSClientError(FaultException e,
                                                               out string errOut)
        {
            const string PREFIX = "GetPSClientError() returns null: ";
            errOut = string.Empty;
            PSLibrary.PSClientError psClientError = null;

            if (e == null)
            {
                errOut = PREFIX + "Null parameter (FaultException e) passed in.";
                psClientError = null;
            }
            else
            {
                // Get a ServiceModel.MessageFault object.
                var messageFault = e.CreateMessageFault();

                if (messageFault.HasDetail)
                {
                    using (var xmlReader = messageFault.GetReaderAtDetailContents())
                    {
                        var xml = new XmlDocument();
                        xml.Load(xmlReader);

                        var serverExecutionFault = xml["ServerExecutionFault"];
                        if (serverExecutionFault != null)
                        {
                            var exceptionDetails = serverExecutionFault["ExceptionDetails"];
                            if (exceptionDetails != null)
                            {
                                try
                                {
                                    errOut = exceptionDetails.InnerXml + "\r\n";
                                    psClientError =
                                        new PSLibrary.PSClientError(exceptionDetails.InnerXml);
                                }
                                catch (InvalidOperationException ex)
                                {
                                    errOut = PREFIX + "Unable to convert fault exception info ";
                                    errOut += "a valid Project Server error message. Message: \n\t";
                                    errOut += ex.Message;
                                    psClientError = null;
                                }
                            }
                            else
                            {
                                errOut = PREFIX + "The FaultException e is a ServerExecutionFault, "
                                    + "but does not have ExceptionDetails.";
                            }
                        }
                        else
                        {
                            errOut = PREFIX + "The FaultException e is not a ServerExecutionFault.";
                        }
                    }
                }
                else // No detail in the MessageFault.
                {
                    errOut = PREFIX + "The FaultException e does not have any detail.";
                }
            }
            errOut += "\r\n" + e.ToString() + "\r\n";
            return psClientError;
        }
    }
}

Voir aussi

Référence

LookupTable classe

LookupTable - Membres

WebSvcLookupTable - Espace de noms

Autres ressources

How to: Use a Filter Parameter with PSI Methods

Locale ID (LCID) Chart