次の方法で共有


ReportingEventReceiver.OnCustomFieldCreated メソッド

ユーザー設定フィールドを作成するためのレポート データ サービスでのポスト イベント ハンドラーです。

名前空間:  Microsoft.Office.Project.Server.Events
アセンブリ:  Microsoft.Office.Project.Server.Events.Receivers (Microsoft.Office.Project.Server.Events.Receivers.dll 内)

構文

'宣言
Public Overridable Sub OnCustomFieldCreated ( _
    contextInfo As PSContextInfo, _
    e As ReportingPostCustomFieldCreatedEventArgs _
)
'使用
Dim instance As ReportingEventReceiver
Dim contextInfo As PSContextInfo
Dim e As ReportingPostCustomFieldCreatedEventArgs

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

パラメーター

注釈

カスタム フィールドの情報で、レポート データベースが更新されると、イベントの作成、レポートのユーザー設定フィールドをレポート データ サービスで発生します。PSI メソッドのCreateCustomFieldsとCreateCustomFields2では、レポートのイベントの前にイベントを作成したユーザー設定フィールドが発生します。これらのイベントは時間の非常に閉じることができます。

Rds. カスタム フィールドの情報を転送するときに、レポート システムで必要なメタデータを提供する ReportingCustomFieldMetadataDataSetCustomFieldTypeUID データセットのメンバーの値を参照して、イベント引数のプロパティの e.CustomFieldTypeGUID。

これら 2 つのエンティティの名前を入力] ただしこれらの値は GUID (ユーザー設定フィールド) の型の代わりにユーザー設定フィールド (コスト、日付、期間、フラグ、数値、またはテキスト) の種類に関連付けられている単語を含めます。

レポート データベースの RDS イベントに関する詳細については、 RDB のイベントを参照してください。

ユーザー設定フィールドの作成、ポスト イベント ハンドラーの例を次に示します。OnCustomFieldCreatedメソッドの例、イベント パラメーターからの情報を取得し、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();
            }
        }
    }
}

次の使用例は、アプリケーションが作成した ReportingCustomFieldCreatedTestOutput.txt ファイルの内容を一覧表示されます。

注意

カスタム フィールドの情報の例では、 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

関連項目

参照先

ReportingEventReceiver クラス

ReportingEventReceiver メンバー

Microsoft.Office.Project.Server.Events 名前空間