次の方法で共有


XML イベント ローダー API の使用

Notification Services アプリケーションに XML データを送信する場合は、XML イベント ローダー API を使用します。この API を使用して、単一の XML ドキュメントから通知のバッチを作成します。

XML イベント ローダー API には、EventLoader という 1 つのクラスがあります。

EventLoader クラスの作成および初期化

EventLoader オブジェクトの作成と初期化には、必要な Notification Services アプリケーションを表す NSApplication オブジェクトで受け渡すパラメータ化されたコンストラクタ、イベント プロバイダの名前、イベント クラスの名前、および XML ドキュメント構造のデータをイベント クラス構造にマップする SQL の注釈付き XML スキーマ ファイルの名前を使用します。

SQL の注釈付き XML スキーマ ファイルの作成の詳細については、Microsoft MSDN ライブラリの「カスタム スキーマの作成と使用に関する背景説明」を参照してください。

イベント データの送信

EventLoader オブジェクトを作成して初期化したら、LoadXml メソッドを使用して、XML データ ソースから Notification Services アプリケーション データベースに 1 つ以上のイベントから成るイベント バッチを書き込みます。

この例では、次の名前空間を使用します。

public bool Run()
{
    // These variables would normally be defined for
    // the class. They would be set based on the values
    // provided by the args argument of the Initialize method.
    string instanceName = "MyInstanceName";
    string applicationName = "MyApplicationName";
    string eventClassName = "MyEventClassName";
    string eventProviderName = "MyEventProviderName";
    string eventSchema = "MyEventSchemaPathAndName";
    string xmlDoc = "MyXMLDocPathAndName";

    bool returnValue = true;
    DateTime currentTime = DateTime.Now;

    try
    {
        // Get the Notification Services instance.
        NSInstance testInstance = new NSInstance(instanceName);

        // Get the Notification Services application.
        NSApplication testApplication =
            new NSApplication(testInstance, applicationName);

        // Create the EventLoader object.
        EventLoader testEventLoader =
            new EventLoader(testApplication, eventProviderName,
            eventClassName, eventSchema);

        // Write the event records from the XML data 
        // source to the application database.
        int eventsSubmitted = testEventLoader.LoadXml(xmlDoc);
    }
    catch(Exception e)
    {
        //Add code to handle errors here.
    }

    return returnValue;
}

参照

その他の技術情報

カスタム イベント プロバイダの開発
イベント プロバイダの定義

ヘルプおよび情報

SQL Server 2005 の参考資料の入手