Subscriber.GetSubscriptions Method
Gets all of the subscriber's subscriptions for the specified subscription class in the specified Notification Services application.
命名空间: Microsoft.SqlServer.NotificationServices
程序集: Microsoft.SqlServer.NotificationServices (in microsoft.sqlserver.notificationservices.dll)
语法
声明
Public Function GetSubscriptions ( _
nsApplication As NSApplication, _
subscriptionClassName As String _
) As SubscriptionEnumeration
public SubscriptionEnumeration GetSubscriptions (
NSApplication nsApplication,
string subscriptionClassName
)
public:
virtual SubscriptionEnumeration^ GetSubscriptions (
NSApplication^ nsApplication,
String^ subscriptionClassName
) sealed
public final SubscriptionEnumeration GetSubscriptions (
NSApplication nsApplication,
String subscriptionClassName
)
public final function GetSubscriptions (
nsApplication : NSApplication,
subscriptionClassName : String
) : SubscriptionEnumeration
参数
- nsApplication
An NSApplication that represents the Notification Services application containing the specified subscription class.
- subscriptionClassName
A String containing the name of the subscription class for which all subscriptions for this subscriber should be retrieved.
返回值
A SubscriptionEnumeration that contains all subscriptions for the subscriber for the specified Notification Services application and subscription class. To see all subscription classes for an application, use the Microsoft.SqlServer.Management.Nmo.SubscriptionClass class.
示例
The following examples show how to use the GetSubscriptions method to retrieve all subscriptions in one subscription class of one Notification Services application for a subscriber:
Dim instanceName As String = "Tutorial"
Dim applicationName As String = "Weather"
Dim subscriptionClassName As String = "WeatherCity"
Dim subscriptionFieldName As String = "City"
' Create the NSInstance object.
Dim testInstance As NSInstance = New NSInstance(instanceName)
' Create the Subscriber object.
Dim testSubscriber As Subscriber = New Subscriber(testInstance)
' Set the subscriber ID so that the
' correct records are retrieved.
testSubscriber.SubscriberId = "TestUser1"
' Create the NSApplication object.
Dim testApplication As NSApplication = _
New NSApplication(testInstance, applicationName)
' Retrieve the subscriber's subscriptions.
Dim testSubscriptionEnumeration As SubscriptionEnumeration = _
testSubscriber.GetSubscriptions( _
testApplication, subscriptionClassName)
Dim singleSub As Subscription
For Each singleSub In testSubscriptionEnumeration
Console.WriteLine(singleSub(subscriptionFieldName).ToString())
Next
Console.ReadLine()
string instanceName = "Tutorial";
string applicationName = "Weather";
string subscriptionClassName = "WeatherCity";
string subscriptionFieldName = "City";
// Create the NSInstance object.
NSInstance testInstance = new NSInstance(instanceName);
// Create the Subscriber object.
Subscriber testSubscriber = new Subscriber(testInstance);
// Set the subscriber ID so that the
// correct records are retrieved.
testSubscriber.SubscriberId = "TestUser1";
// Create the NSApplication object.
NSApplication testApplication =
new NSApplication(testInstance, applicationName);
// Retrieve the subscriber's subscriptions.
SubscriptionEnumeration testSubscriptionEnumeration =
testSubscriber.GetSubscriptions
(testApplication, subscriptionClassName);
foreach (Subscription singleSub in testSubscriptionEnumeration)
{
Console.WriteLine(singleSub[subscriptionFieldName].ToString());
}
Console.ReadLine();
线程安全
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 的硬件和软件要求。
请参阅
参考
Subscriber Class
Subscriber Members
Microsoft.SqlServer.NotificationServices Namespace