ReportingEventReceiver.OnCustomFieldCreated - Méthode

Un gestionnaire d'après l'événement dans le Service de données de rapport pour la création d'un champ personnalisé.

Espace de noms :  Microsoft.Office.Project.Server.Events
Assembly :  Microsoft.Office.Project.Server.Events.Receivers (dans Microsoft.Office.Project.Server.Events.Receivers.dll)

Syntaxe

'Déclaration
Public Overridable Sub OnCustomFieldCreated ( _
    contextInfo As PSContextInfo, _
    e As ReportingPostCustomFieldCreatedEventArgs _
)
'Utilisation
Dim instance As ReportingEventReceiver
Dim contextInfo As PSContextInfo
Dim e As ReportingPostCustomFieldCreatedEventArgs

instance.OnCustomFieldCreated(contextInfo, _
    e)
public virtual void OnCustomFieldCreated(
    PSContextInfo contextInfo,
    ReportingPostCustomFieldCreatedEventArgs e
)

Paramètres

Remarques

Le Service de données de rapport génère le champ personnalisé de création de rapports créé événement lorsque la base de données de création de rapports est mis à jour avec les informations de champ personnalisé. La PSI méthodes CreateCustomFields et CreateCustomFields2 génère un champ personnalisé créé des événements avant l'événement de création de rapports. Ces événements peuvent être très proches dans le temps.

ReportingCustomFieldMetadataDataSet fournit les métadonnées requises par le système de création de rapports lors du transfert des informations de champ personnalisé à l'objet RDS. La valeur du membre dataset CustomFieldTypeUID peut également se trouver dans l'événement e.CustomFieldTypeGUID de propriété d'argument.

Les noms de ces deux entités incluent le mot « Tapez « toutefois ces valeurs ne sont pas associés avec le type du champ personnalisé (coût, Date, durée, indicateur, nombre ou texte), plutôt que sur le type du GUID (champs personnalisés).

Pour plus d'informations sur les événements RDS pour la base de données de création de rapports, reportez-vous à la section d'événements pour la RDB.

Exemples

Voici un exemple d'un gestionnaire d'après l'événement de champ personnalisé créé. L'exemple de méthode OnCustomFieldCreated récupère des informations à partir des paramètres d'événement et les écrit dans un fichier XML.

using System;
using System.Data;
using System.IO;
using System.Text;
using Microsoft.Office.Project.Server.Events;
using PSLib = Microsoft.Office.Project.Server.Library;
using PSSchema = Microsoft.Office.Project.Server.Schema;

namespace Microsoft.SDK.Project.Samples.ReportingEvents
{
    public class TestCustomFieldCreated : ReportingEventReceiver
    {
        // Change the output directory for your computer.
        private const string OUTPUT_FILES = @"C:\Project\Samples\Output\";
        private static string outFilePath;
        
        public override void OnCustomFieldCreated(PSLib.PSContextInfo 
            contextInfo, ReportingPostCustomFieldCreatedEventArgs e)
        {
            // Record the time of the event.


            DateTime eventRaised = DateTime.Now;
            
            // Create the location for the output file.

            outFilePath = OUTPUT_FILES + "ReportingCustomFieldCreatedTestOutput.txt";
            
            // Write event argument information to the output file.

            string eventData = "\r\n\r\nCustom Field Created post-event handler: " + eventRaised.ToString();
            eventData += "\r\nPWA site Guid: " + contextInfo.SiteGuid.ToString();
            eventData += "\r\nUser name: " + contextInfo.UserName;
            eventData += "\r\nUser Guid: " + contextInfo.UserGuid;
            eventData += "\r\nCustom field type GUID: " + e.CustomFieldTypeGuid.ToString();

            // Include the reporting metadata for the custom field.
            PSSchema.ReportingCustomFieldMetadataDataSet projectDs = e.CustomFieldMetadataDataSet;
            projectDs.WriteXml(outFilePath);

            using (StreamWriter outputData = new StreamWriter(outFilePath, true))
            {
                outputData.WriteLine();
                outputData.WriteLine(eventData);
                outputData.Close();
            }
        }
    }
}

L'exemple suivant affiche le contenu du fichier ReportingCustomFieldCreatedTestOutput.txt qui est écrit par l'application.

Notes

Les informations de champ personnalisé dans l'exemple sont spécifiques à ce champ personnalisé qui est défini dans une instance de Project Web App .

<?xml version="1.0" standalone="yes"?>
<ReportingCustomFieldMetadataDataSet xmlns="https://schemas.microsoft.com/office/project/server/webservices/ReportingCustomFieldMetadataDataSet/">
  <CustomFieldMetadata>
    <CustomFieldTypeUID>1e1dfb97-b4fc-4d8a-aaa8-b1ad079a2013</CustomFieldTypeUID>
    <ParentEntityTypeGuid>cecfe271-6660-4abe-97ed-208d3c71fc18</ParentEntityTypeGuid>
    <CustomFieldName>Test Project Text CF - has LUT</CustomFieldName>
    <CustomFieldType>21</CustomFieldType>
    <LookupTableUID>cdff825e-8951-4ac7-ad0e-ba28a009dd1d</LookupTableUID>
    <IsMultiValueEnabled>false</IsMultiValueEnabled>
    <HasWeights>false</HasWeights>
    <AssignmentRollDown>false</AssignmentRollDown>
    <CreatedDate>2011-03-28T18:45:31.827-07:00</CreatedDate>
    <ModificationDate>2011-03-28T18:45:31.827-07:00</ModificationDate>
  </CustomFieldMetadata>
</ReportingCustomFieldMetadataDataSet>

Custom Field Created post-event handler: 3/28/2011 6:45:40 PM
PWA site GUID: 9f110f4a-3632-42d3-a1e5-21f9c43360c3
User name: DOMAIN\UserName
User GUID: 2e0fdcc1-85fc-4bde-9593-78a2789c66af
Custom field type GUID: 1e1dfb97-b4fc-4d8a-aaa8-b1ad079a2013

Voir aussi

Référence

ReportingEventReceiver classe

ReportingEventReceiver - Membres

Microsoft.Office.Project.Server.Events - Espace de noms