Subscription.RuleName Property

Gets or sets the subscription rule name for a rule-based subscription. This class is used for subscription classes that contain condition actions.

命名空間: Microsoft.SqlServer.NotificationServices
組件: Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)

語法

'宣告
Public Property RuleName As String
public string RuleName { get; set; }
public:
property String^ RuleName {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_RuleName ()

/** @property */
public void set_RuleName (String value)
public function get RuleName () : String

public function set RuleName (value : String)

屬性值

A string containing the name of a subscription rule, either event-driven or scheduled, that uses condition actions.

備註

In SQL Server 2000 Notification Services, subscribers create subscriptions by defining parameter values for pre-defined queries. In SQL Server 2005 Notification Services, your subscription classes can have condition actions, which allow subscribers to define more complex conditions.

If your application uses condition actions, your subscription management application must provide a Condition property and must also specify the RuleName for the condition.

The RuleName property specifies which subscription rule the subscription is for. This property is required for condition-based subscriptions so that the condition evaluator runs the conditions against the correct view.

For more information about conditions, see 定義條件動作.

範例

The following example shows how to define a condition for a subscription:

' Create the NSInstance object.
Dim testInstance As New NSInstance("InventoryTrackerInstance")
 
' Create the NSApplication object.
Dim testApplication As _
    New NSApplication(testInstance, "InventoryTracker")
 
' Create Subscription object.
Dim s As New Subscription(testApplication, _
    "InventoryTrackerSubscriptions")
 
' Define subscription properties
s.SubscriberId = "TestUser1"
s.Enabled = True
s.RuleName = "InventoryTrackerRule"
s("DeviceName") = "Work e-mail"
s("SubscriberLocale") = "en-US"
 
' Define OrCondition
s.Condition = New AndCondition( _
    New SimpleLeafCondition( _
        New FieldValue("ProductName"), _
        SimpleOperator.Equals, _
        "Road-250 Black, 48"), _
    New SimpleLeafCondition( _
        New FieldValue("LocationName"), _
        SimpleOperator.Equals, _
        "Final Assembly"), _
    New SimpleLeafCondition( _
        New FieldValue("Quantity"), _
        SimpleOperator.LessThanOrEqualTo, _
        35))
 
' Add subscription
s.Add()
// Create the NSInstance object.
NSInstance testInstance = 
    new NSInstance("InventoryTrackerInstance");

// Create the NSApplication object.
NSApplication testApplication =
    new NSApplication(testInstance, "InventoryTracker");

// Create Subscription object.
Subscription s = new Subscription(testApplication, 
    "InventoryTrackerSubscriptions");

// Define subscription properties
s.SubscriberId = "TestUser1";
s.Enabled = true;
s.RuleName = "InventoryTrackerRule";
s["DeviceName"] = "Work e-mail";
s["SubscriberLocale"] = "en-US";

// Define OrCondition
s.Condition = new AndCondition(
    new SimpleLeafCondition(new FieldValue("ProductName"),
                    SimpleOperator.Equals,
                    "Road-250 Black, 48"),
    new SimpleLeafCondition(new FieldValue("LocationName"),
                    SimpleOperator.Equals,
                    "Final Assembly"),
    new SimpleLeafCondition(new FieldValue("Quantity"),
                    SimpleOperator.LessThanOrEqualTo,
                    35)
);

// Add subscription
s.Add();

執行緒安全性

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.

平台

開發平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

目標平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

請參閱

參考

Subscription Class
Subscription Members
Microsoft.SqlServer.NotificationServices Namespace