Поделиться через


SubscriptionEventRule Constructor (SubscriptionClass, String)

Initializes a new instance of the SubscriptionEventRule class with a parent SubscriptionClass and a name.

Пространство имен: Microsoft.SqlServer.Management.Nmo
Сборка: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)

Синтаксис

'Декларация
Public Sub New ( _
    subscriptionClass As SubscriptionClass, _
    name As String _
)
public SubscriptionEventRule (
    SubscriptionClass subscriptionClass,
    string name
)
public:
SubscriptionEventRule (
    SubscriptionClass^ subscriptionClass, 
    String^ name
)
public SubscriptionEventRule (
    SubscriptionClass subscriptionClass, 
    String name
)
public function SubscriptionEventRule (
    subscriptionClass : SubscriptionClass, 
    name : String
)

Параметры

  • name
    A String, between 1 and 255 characters in length, that specifies the name of the event rule.

    You cannot change the name. To rename a rule, you must remove the rule and the add a new rule with the new name.

Замечания

Each event rule must have a name, and it must be unique within the application.

This constructor sets a default ActionTimeout value of 30 minutes.

Пример

The following examples show how to define an event rule and then add it to a subscription class:

// Add a rule to generate basic event-triggered notifications
SubscriptionEventRule flightEventRule = 
    new SubscriptionEventRule(flightSubscriptions, 
    "FlightSubscriptionsEventRule");
flightEventRule.Action = "INSERT INTO FlightNotifications " + 
    "(SubscriberId, DeviceName, SubscriberLocale, " + 
    "LeavingFrom, GoingTo, Price) " + 
    "SELECT S.SubscriberId, S.DeviceName, S.SubscriberLocale, " + 
    "E.LeavingFrom, E.GoingTo, E.Price " + 
    "FROM FlightEvents E, FlightSubscriptions S " + 
    "WHERE     E.LeavingFrom     = S.LeavingFrom " + 
    "AND    E.GoingTo    = S.GoingTo " + 
    "AND    E.Price    < S.Price";
flightEventRule.ActionTimeout = new TimeSpan(0, 1, 0);
flightEventRule.EventClassName = "FlightEvents";
flightSubscriptions.SubscriptionEventRules.Add(flightEventRule);
' Add a rule to generate basic event-triggered notifications
Dim flightEventRule As SubscriptionEventRule = _
    New SubscriptionEventRule(flightSubscriptions, _
        "FlightSubscriptionsEventRule")
flightEventRule.Action = _
    "INSERT INTO FlightNotifications " + _
    "(SubscriberId, DeviceName, SubscriberLocale, " + _
    "LeavingFrom, GoingTo, Price) " + _
    "SELECT S.SubscriberId, S.DeviceName, S.SubscriberLocale, " + _
    "E.LeavingFrom, E.GoingTo, E.Price " + _
    "FROM FlightEvents E, FlightSubscriptions S " + _
    "WHERE E.LeavingFrom = S.LeavingFrom " + _
    "AND E.GoingTo = S.GoingTo " + _
    "AND E.Price < S.Price"
flightEventRule.ActionTimeout = New TimeSpan(0, 1, 0)
flightEventRule.EventClassName = "FlightEvents"
flightSubscriptions.SubscriptionEventRules.Add(flightEventRule)

Платформы

Платформы разработки

Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.

Целевые платформы

Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.

См. также

Справочник

SubscriptionEventRule Class
SubscriptionEventRule Members
Microsoft.SqlServer.Management.Nmo Namespace

Другие ресурсы

Определение правил событий
RuleName Element for EventRule (ADF)
EventRule Element (ADF)