Export (0) Print
Expand All

Lesson 3: Adding an Event Class

SQL Server 2005

In this lesson you will add an event class to the application definition file (ADF) and then update the instance of Notification Services to apply the changes to the application database. You can then review the changes made to the application database.

An event class represents one type of event used by your Notification Services application. When you define an event class, you define a type of event that can be submitted to your application and used to generate notifications. The event class definition includes the event field names, data types, and type modifiers.

An event class can define other information, such as indexes on the event data and supplemental tables. You can learn more about event classes by reading Defining Event Classes.

When you create the application, Notification Services uses the event class definition to create tables, views, indexes, and stored procedures for storing, collecting, and managing event data.

For this application, you will add a WeatherData event class to the ADF. This event class has five event fields, City, Date, Low, High, and Forecast. These describe the event data you will later submit to the application. For each event field, the event class defines the field name, data type, and field modifiers.

To improve performance for notification generation, the event class also specifies an index on the City field of the WeatherData event class.

The XML in this section defines the event class. Examine the XML and then follow the instructions to copy the XML to the ADF.

  1. Click Copy Code to copy the XML to the Windows Clipboard.

    <!-- Event Classes -->
    <EventClasses>
      <EventClass>
        <EventClassName>WeatherData</EventClassName>
        <Schema>
          <Field>
            <FieldName>City</FieldName>
            <FieldType>nvarchar(35)</FieldType>
            <FieldTypeMods>not null</FieldTypeMods>
          </Field>
          <Field>
            <FieldName>Date</FieldName>
            <FieldType>datetime</FieldType>
            <FieldTypeMods>not null</FieldTypeMods>
          </Field>
          <Field>
            <FieldName>Low</FieldName>
            <FieldType>float</FieldType>
            <FieldTypeMods>not null</FieldTypeMods>
          </Field>
          <Field>
            <FieldName>High</FieldName>
            <FieldType>float</FieldType>
            <FieldTypeMods>not null</FieldTypeMods>
          </Field>
          <Field>
            <FieldName>Forecast</FieldName>
            <FieldType>nvarchar(3500)</FieldType>
            <FieldTypeMods>not null</FieldTypeMods>
          </Field>
        </Schema>
        <IndexSqlSchema>
          <SqlStatement>CREATE INDEX myIndex 
          ON WeatherData ( City );
          </SqlStatement>
        </IndexSqlSchema>
      </EventClass>
    </EventClasses>
    
    
  2. In Solution Explorer, open WeatherADF.xml.

  3. Replace the following comment with the XML you just copied.

    <!-- Replace with EventClasses XML -->

  4. On the File menu, select Save WeatherADF.xml.

After you modify the ADF, you update the instance of Notification Services to add event class objects to the application database.

  1. In Object Explorer, expand Notification Services.

  2. Right-click Tutorial, point to Tasks, and then select Update.

  3. In the Update Instance dialog box, click Browse, locate and select the TutorialICF.xml file, and then click Open.

  4. In the Parameters grid, review the values for the parameters.

    The values should be correct because you modified them as needed in Lesson 2. If you must edit these values, return to Lesson 2 to learn how to edit parameter defaults in the ICF.

  5. Click OK.

  6. Review the Notification Services - Update Summary dialog box, and then click Update.

  7. When the update actions are complete, click Close.

When you update the instance, Notification Services adds tables, views, and stored procedures for the event class in the TutorialWeather application database.

  • The dbo.WeatherData event view is the current set of events being processed by the application. When you later write notification generation queries, you select data from this view.
  • The dbo.NSWeatherDataEvents table is the underlying table that contains event data for the event class. Event data stays in this table until it is removed by the vacuumer data removal process.
    ms167346.Caution(en-US,SQL.90).gifCaution:
    Do not directly modify data in the application and instance databases. To add event data, you must use one of the supported event submission methods, such as the built-in event providers, event submission stored procedures, or the API. For more information, see Defining Event Providers.

You can use Object Explorer to examine these objects in the TutorialWeather database. You may have to refresh Object Explorer to see the new objects.

Community Additions

ADD
Show:
© 2014 Microsoft