MS SQL Server
  Home arrow MS SQL Server arrow Page 4 - Delving Deeper into Notification Services
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

Delving Deeper into Notification Services
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2007-03-15

    Table of Contents:
  • Delving Deeper into Notification Services
  • Creating a Delivery Channel
  • Creating an Event Class
  • Creating a Subscription Class and Subscription Event Rule

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Delving Deeper into Notification Services - Creating a Subscription Class and Subscription Event Rule


    (Page 4 of 4 )

    A subscription class with a single subscription event rule is created in the CreateSubscriptionClassMethod() method of Example 18-1. The code follows:

    CreateSubscriptionClassMethod( ) method of Example 18-1. The code follows:A subscription class with a single subscription event rule is created in the CreateSubscriptionClassMethod( ) method of Example 18-1. The code follows:

      private static void CreateSubscriptionClass()
      {
         SubscriptionClass sc = new SubscriptionClass(a, "StockWatchSubscriptions");

         SubscriptionField sf;
         sf = new SubscriptionField(sc, "DeviceName");
         sf.Type = "nvarchar(255)";
         sc.SubscriptionFields.Add(sf);
         sf = new SubscriptionField(sc, "SubscriberLocale");
         sf.Type = "nvarchar(10)";
         sc.SubscriptionFields.Add(sf);
         sf = new SubscriptionField(sc, "Symbol");
         sf.Type = "nvarchar(6)";
         sc.SubscriptionFields.Add(sf);
         sf = new SubscriptionField(sc, "Price");
         sf.Type = "float";
         sc.SubscriptionFields.Add(sf);

         SubscriptionEventRule ser =
            new SubscriptionEventRule(sc, "StockWatchSubscriptionsEventRule");
        
    ser.Action = @"INSERT INTO StockWatchNotifications (" +
             "SubscriberId, DeviceName, SubscriberLocale, Symbol, Price) " +
             "SELECT s.SubscriberId, s.DeviceName, s.SubscriberLocale, " +
             
    "e.Symbol, e.Price " +
             "FROM StockWatchEvents e, StockWatchSubscriptions s " +
             "WHERE e.Symbol = s.Symbol";

         ser.EventClassName = "StockWatchEvents";

         sc.SubscriptionEventRules.Add(ser);

         a.SubscriptionClasses.Add(sc);

         Console.WriteLine("Added subscription class: " + sc.Name);
      }

    ASubscriptionClass object defines a type of subscription within a Notification Services application. TheSubscriptionField objects added to theSubscriptionobject represent fields in the subscription class schema. ASubscriptionChronicleobject lets you store subscription information outside of tables used by the subscription class—this example does not use a subscription chronicle.

    The NMO classes for managing subscription chronicles, subscription classes, and subscription fields are described in Table 18-5.

    Table 18-5. NMO classes for managing subscription chronicles, classes, and fields

    Class Description
    SubscriptionChronicle Represents a subscription chronicle.
    SubscriptionChronicleCollection Represents a collection of subscription chronicles as SubscriptionChronicleobjects. TheSubscriptionChronicles property of theSubscriptionClassclass returns the subscription chronicles for the subscription class.
    SubscriptionClass Represents a subscription class.
    SubscriptionClassCollection Represents a collection of subscription classes asSubscriptionClass objects. TheSubscriptionClassesproperty of theApplication class returns the subscription classes for the Notification Services application.
     SubscriptionField Represents a field in the subscription class schema.
     SubscriptionFieldCollectionRepresents a collection of fields asSubscriptionFieldobjects. The SubscriptionFieldsproperty of theSubscriptionClassclass returns the fields for the subscription class schema.

    ASubscriptionEventRule object represents a rule that uses T-SQL queries to generate notifications when event batches arrive. TheActionproperty represents the T-SQL query for theSubscriptionEventRuleobject. In this example, notifications are generated when the ticker symbol of an event matches the ticker symbol specified in a subscription.

    The NMO classes for managing the different types of subscription rules are described in Table 18-6.

    Table 18-6. NMO classes for managing subscription rules

    Class

    Description

    SubscriptionCondition
    EventRule

    Represents a subscription rule that the generator runs against subscriptions that use conditions to generate notifications.

    SubscriptionCondition
    EventRuleCollection

    Represents a collection of subscription condition event rules as SubscriptionConditionEventRule objects. The subscriptionConditionEvent-Rulesproperty of the SubscriptionClassclass returns the subscription condition event rules for the subscription class.

    SubscriptionCondition
    ScheduledRule

    Represents a subscription rule that the generator runs against scheduled subscriptions that use conditions to generate notifications.

     SubscriptionCondition
    ScheduledRuleCollection

    Represents a collection of subscription condition scheduled rules as SubscriptionConditionScheduled-Ruleobjects. The SubscriptionCondition-ScheduledRulesproperty of the SubscriptionClassclass returns the subscription condition scheduled rules for the subscription class.

    SubscriptionEventRule

    Represents an event rule that contains simple (not conditional) actions.

    SubscriptionEvent
    RuleCollection

    Represents a collection of subscription event rules as SubscriptionEventRuleobjects. The SubscriptionEventRulesproperty of the SubscriptionClassclass returns the subscription event rules for the subscription class. 

    SubscriptionScheduled
    Rule
    Represents a scheduled rule that contains actions that do not use conditions to generate notifications.
    SubscriptionScheduled
    RuleCollection

    Represents a collection of scheduled rules as SubscriptionScheduledRuleobjects. The SubscriptionScheduledRulesproperty of the SubscriptionClassclass returns the scheduled rules for the subscription class.

    Please check back next week for the conclusion of this article.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This article is an excerpt from the book "Programming SQL Server 2005," published by...
       · I found this article very useful in tying together many aspects of Web development...
       · I'm glad you found it helpful; thanks for commenting!
     

    Buy this book now. This article is excerpted from chapter 18 of the book Programming SQL Server 2005, written by Bill Hamilton (O'Reilly, 2006; ISBN: 0596004796). Check it out today at your favorite bookstore. Buy this book now.

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT