Delving Deeper into Notification Services - Creating an Event Class
(Page 3 of 4 )
An event class named StockWatchEvents is created in the CreateEventClass() method of Example 18-1. The code follows:
private static void CreateEventClass()
{
EventClass ec = new EventClass(a, "StockWatchEvents");
EventField ef;
ef = new EventField(ec, "Symbol");
ef.Type = "nvarchar(6)";
ec.EventFields.Add(ef);
ef = new EventField(ec, "Price");
ef.Type = "float";
ec.EventFields.Add(ef);
a.EventClasses.Add(ec);
Console.WriteLine("Added event class: " + ec.Name);
}
An event class represents a type of event used by a Notification Services application. The event class has two fields—Symbolof typenvarchar(6)andPriceof typefloat.
The NMO classes for managing event classes, fields, and chronicles are described inTable 18-4.
Table 18-4. NMO classes for managing events
| Class | Description |
| EventChronicle | Represents an event chronicle. |
| EventChronicleCollection | Represents a collection of event chronicles asEventChronicleobjects. TheEventChroniclesproperty of theEventClassclass returns the event chronicles for the event class. |
| EventChronicleRule | Represents an event chronicle maintenance query that the generator runs. |
| EventClass | Represents an event class. |
| EventClassCollection | Represents a collection of event classes asEventClassobjects. TheEvent-Classesproperty of theApplicationclass returns the event classes for the Notification Services application. |
| EventField | Represents a field in an event class schema. |
| EventFieldCollection | Represents a collection of event class schema fields asEventFieldobjects. The EventFieldsproperty of theEventClassclass returns the event fields for the event class. |
Next: Creating a Subscription Class and Subscription Event Rule >>
More MS SQL Server Articles
More By O'Reilly Media
|
This article is excerpted from chapter 18 of the book Programming SQL Server 2005, written by Bill Hamilton (O'Reilly, 2006; ISBN: 0596004796). Check it out today at your favorite bookstore. Buy this book now.
|
|