EventClass Class
Represents a event class for a Notification ServicesApplication.
Пространство имен: Microsoft.SqlServer.Management.Nmo
Сборка: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)
Синтаксис
'Декларация
Public NotInheritable Class EventClass
Inherits NamedSmoObject
public sealed class EventClass : NamedSmoObject
public ref class EventClass sealed : public NamedSmoObject
public final class EventClass extends NamedSmoObject
public final class EventClass extends NamedSmoObject
Замечания
An event class represents one type of event used by your Notification Services application. When you define your application, you define an event class for every type of event that you maintain in the application database.
If you remove an event class from an application, updating the application deletes the underlying tables and indexes in the application database. Any data existing in the original event class tables is permanently deleted.
You can have 0 to 64 event classes in a single Notification Services application. If you maintain events in external databases and query those databases in your subscription rules, you do not define event classes for these events.
Inheritance Hierarchy
System.Object
Microsoft.SqlServer.Management.Smo.SmoObjectBase
Microsoft.SqlServer.Management.Smo.SqlSmoObject
Microsoft.SqlServer.Management.Smo.NamedSmoObject
Microsoft.SqlServer.Management.Nmo.EventClass
Пример
The following examples show event class definitions using all event class properties and using all methods for adding fields to the event class:
EventClass flightEvents =
new EventClass(myApplication, "FlightEvents");
flightEvents.FileGroup = "PRIMARY";
// Add an orgin field to the end of the field collection
EventField eventOrgin =
new EventField(flightEvents, "LeavingFrom");
eventOrgin.Type = "nvarchar(6)";
eventOrgin.TypeModifier = "not null";
flightEvents.EventFields.Add(eventOrgin);
// Define a price field and add it at position 1
EventField eventPrice = new EventField(flightEvents, "Price");
eventPrice.Type = "float";
flightEvents.EventFields.Add(eventPrice, 1);
// Define a destination field and add it before the Price field
EventField eventDestination =
new EventField(flightEvents, "GoingTo");
eventDestination.Type = "nvarchar(6)";
flightEvents.EventFields.Add(eventDestination, "Price");
// Add the event class to the application
myApplication.EventClasses.Add(flightEvents);
// Add an index to the event class to help improve performance
flightEvents.IndexSqlStatements.Add(
"CREATE INDEX FlightEventsIndex ON MyAppSchema.FlightEvents " +
"( LeavingFrom, GoingTo );");
// Define a chronicle for the class
EventChronicle ec1 =
new EventChronicle(flightEvents, "FlightEventChonicle");
ec1.SqlStatements.Add(
"CREATE TABLE MyAppSchema.FlightEventChronicle " +
" (LeavingFrom nvarchar(6), GoingTo nvarchar(6), " +
" Price float);");
ec1.SqlStatements.Add(
"CREATE INDEX FlightEventChronicleIndex " +
"ON MyAppSchema.FlightEventChronicle " +
"( LeavingFrom, GoingTo );");
flightEvents.EventChronicles.Add(ec1);
// Define the event chronicle rule
EventChronicleRule ec1Rule =
new EventChronicleRule(flightEvents,
"FlightEventChronicleRule");
ec1Rule.Action = "INSERT MyAppSchema.FlightEventChronicle " +
" (LeavingFrom, GoingTo, Price) " +
" SELECT LeavingFrom, GoingTo, Price " +
" FROM MyAppSchema.FlightEvents;";
ec1Rule.ActionTimeout = new TimeSpan(0, 1, 20);
flightEvents.EventChronicleRule = ec1Rule;
Dim flightEvents As EventClass = _
New EventClass(myApplication, "FlightEvents")
flightEvents.FileGroup = "PRIMARY"
' Add an orgin field to the end of the field collection.
Dim eventOrgin As EventField = _
New EventField(flightEvents, "LeavingFrom")
eventOrgin.Type = "nvarchar(6)"
eventOrgin.TypeModifier = "not null"
flightEvents.EventFields.Add(eventOrgin)
' Define a price field and add it at position 1.
Dim eventPrice As EventField = _
New EventField(flightEvents, "Price")
eventPrice.Type = "float"
flightEvents.EventFields.Add(eventPrice, 1)
' Define a destination field and add it before the Price field.
Dim eventDestination As EventField = _
New EventField(flightEvents, "GoingTo")
eventDestination.Type = "nvarchar(6)"
flightEvents.EventFields.Add(eventDestination, "Price")
' Add the event class to the application
myApplication.EventClasses.Add(flightEvents)
' Add an index to the event class to help improve performance.
flightEvents.IndexSqlStatements.Add( _
"CREATE INDEX FlightEventsIndex " + _
"ON MyAppSchema.FlightEvents " + _
"( LeavingFrom, GoingTo );")
' Define a chronicle for the class.
Dim ec1 As EventChronicle = _
New EventChronicle(flightEvents, "FlightEventChonicle")
ec1.SqlStatements.Add( _
"CREATE TABLE MyAppSchema.FlightEventChronicle " + _
" (LeavingFrom nvarchar(6), GoingTo nvarchar(6), " + _
" Price float);")
ec1.SqlStatements.Add( _
"CREATE INDEX FlightEventChronicleIndex " + _
"ON MyAppSchema.FlightEventChronicle " + _
"( LeavingFrom, GoingTo );")
flightEvents.EventChronicles.Add(ec1)
' Define the event chronicle rule
Dim ec1Rule As EventChronicleRule = _
New EventChronicleRule(flightEvents, _
"FlightEventChronicleRule")
ec1Rule.Action = _
"INSERT MyAppSchema.FlightEventChronicle " + _
" (LeavingFrom, GoingTo, Price) " + _
" SELECT LeavingFrom, GoingTo, Price " + _
" FROM MyAppSchema.FlightEvents;"
ec1Rule.ActionTimeout = New TimeSpan(0, 1, 20)
flightEvents.EventChronicleRule = ec1Rule
Синхронизация потоков
Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Платформы
Платформы разработки
Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.
Целевые платформы
Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.
См. также
Справочник
EventClass Members
Microsoft.SqlServer.Management.Nmo Namespace