microsoft.public.sqlserver.notificationsvcs
[Top] [All Lists]

Re: Custom Formatter: Initialize and Close methods

Subject: Re: Custom Formatter: Initialize and Close methods
From: Joe Webb
Date: Tue, 12 Jul 2005 07:46:11 -0500
Newsgroups: microsoft.public.sqlserver.notificationsvcs
Here's some C# code that can be used to delete all subscriptions for a
particular subscriber. You could put this in a loop of all subscribers
to completely get rid of your subscriptions. (You'll also want to put
this is a try block with proper error handling).

public bool DeleteSubscriptions(string sId)
{
        //Create an NSInstance and NSApplication object
        NSInstance instance = getNSInstance();

        //create a subscriber object
        Subscriber subscriber = new Subscriber(instance);
        subscriber.SubscriberId = sId; 
        
        //delete the subscriptions
        subscriber.DeleteSubscriptions() ;

        return true;
                
}

If you have multiple applications for the instance, you can specify in
which application the subscriptions should be deleted. 

HTH...

-- 
Joe Webb
SQL Server MVP


~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811 

I support PASS, the Professional Association for SQL Server.
(www.sqlpass.org)



On Fri, 08 Jul 2005 01:00:17 -0500,
[email protected] (sidgam) wrote:

>Hey Shyam,
>
>Thanks for the response.  I do have 2 delivery channels and whenever I
>do my tests I set them up to send emails via both delivery channels. 
>I will do some tests using just 1 delivery channel to confirm that
>the Initialize/Close methods are only called once for the batch.
>
>I would like to present the scenario I am trying to use SQL-NS for.  I
>want to set SQL-NS up to be able to send push emails ad-hoc.  The
>recipient community that will receive these push emails is defined
>via rules.  The method I have come up with is to create subscriptions
>to a rule, provide delivery content (body of email) to that rule,
>schedule it for later or immediate delivery.  What I want to be able
>to do is to delete the subscriptions when the delivery of the
>notifications is complete.  Since the rules are not reused, I would
>like to clean up the subscriptions once delivery is complete to
>prevent my subscriptions table from getting too large.
>
>What is the best way to truncate the subscriptions table?  Via code or
>through a scheduled task in the db.  I dont see a clean way to call
>the clean up code in the Custom Formatter or Protocol.  If via a db
>scheduled task, do I just need to call SP
>NSMain.Dbo.NSDeleteAllSubscriptions?
>
>Please let me know.


<Prev in Thread] Current Thread [Next in Thread>