NotificationClass Class
SQL Server 2005
Represents a notification class in a Notification Services application.
Namespace: Microsoft.SqlServer.Management.Nmo
Assembly: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)
Assembly: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)
A notification class defines one type of notification generated by your application. When you define a Notification Services application, you create one notification class for each type of notification that is supported by your application.
For more information, see Defining Notification Classes.
System.Object
Microsoft.SqlServer.Management.Smo.SmoObjectBase
Microsoft.SqlServer.Management.Smo.SqlSmoObject
Microsoft.SqlServer.Management.Smo.NamedSmoObject
Microsoft.SqlServer.Management.Nmo.NotificationClass
Microsoft.SqlServer.Management.Smo.SmoObjectBase
Microsoft.SqlServer.Management.Smo.SqlSmoObject
Microsoft.SqlServer.Management.Smo.NamedSmoObject
Microsoft.SqlServer.Management.Nmo.NotificationClass
The following examples show how to define a complete notification class and then add it to an application:
// Create a notification class NotificationClass flightNotifications = new NotificationClass(myApplication, "FlightNotifications"); flightNotifications.FileGroup = "PRIMARY"; flightNotifications.NotificationBatchSize = 500; // Define a LeavingFrom notification field and use it for grouping // digest messages. Add it to the end of the field collection NotificationField notificationOrgin = new NotificationField(flightNotifications, "LeavingFrom"); notificationOrgin.Type = "nvarchar(6)"; notificationOrgin.DigestGrouping = true; flightNotifications.NotificationFields.Add(notificationOrgin); // Define a Price field and add it at position 1 in the collection NotificationField notificationPrice = new NotificationField(flightNotifications, "Price"); notificationPrice.Type = "float"; flightNotifications.NotificationFields.Add(notificationPrice, 1); // Define a GoingTo field and add it before the Price field NotificationField notificationDestination = new NotificationField(flightNotifications, "GoingTo"); notificationDestination.Type = "nvarchar(6)"; flightNotifications.NotificationFields.Add( notificationDestination, "Price"); NotificationComputedField computedPrice = new NotificationComputedField(flightNotifications, "FormattedPrice"); computedPrice.SqlExpression = "CONVERT(NVARCHAR(10), Price, 1)"; flightNotifications.NotificationComputedFields.Add(computedPrice); // Add the XSLT content formatter to the notification class ContentFormatter contentFormatter = new ContentFormatter(flightNotifications, "XsltFormatter"); // Define content formatter arguments ContentFormatterArgument contentFormatterArgument1 = new ContentFormatterArgument( contentFormatter, "XsltBaseDirectoryPath"); contentFormatterArgument1.Value = @"C:\NS\Full\XSLFiles"; ContentFormatterArgument contentFormatterArgument2 = new ContentFormatterArgument(contentFormatter, "XsltFileName"); contentFormatterArgument2.Value = "NoOp.xslt"; // Add arguments to content formatter contentFormatter.ContentFormatterArguments.Add( contentFormatterArgument1); contentFormatter.ContentFormatterArguments.Add( contentFormatterArgument2); // Assign the content formatter to the notification class flightNotifications.ContentFormatter = contentFormatter; // Enable digest delivery flightNotifications.DigestDelivery = true; // Disable multicast (either digest or multicast not both) flightNotifications.MulticastDelivery = false; // Define a file protocol for notification delivery NotificationClassProtocol fileProtocol = new NotificationClassProtocol(flightNotifications, "File"); // Define fields, which map notification fields to protocol fields ProtocolField fileProtocolField1 = new ProtocolField(fileProtocol, "LeavingFrom"); fileProtocolField1.FieldReference = "LeavingFrom"; fileProtocol.ProtocolFields.Add(fileProtocolField1); ProtocolField fileProtocolField3 = new ProtocolField(fileProtocol, "Price"); fileProtocolField3.FieldReference = "FormattedPrice"; fileProtocol.ProtocolFields.Add(fileProtocolField3, 1); ProtocolField fileProtocolField2 = new ProtocolField(fileProtocol, "GoingTo"); fileProtocolField2.FieldReference = "GoingTo"; fileProtocol.ProtocolFields.Add(fileProtocolField2, "Price"); // Add file protocol to notification class flightNotifications.NotificationClassProtocols.Add(fileProtocol); // Define an SMTP protocol for notification delivery NotificationClassProtocol smtpProtocol = new NotificationClassProtocol(flightNotifications, "SMTP"); // Define fields for the SMTP notifications ProtocolField smtpProtocolField1 = new ProtocolField(smtpProtocol, "Subject"); smtpProtocolField1.SqlExpression = "'Flight notification: '+CONVERT (NVARCHAR(30), GETDATE())"; smtpProtocol.ProtocolFields.Add(smtpProtocolField1); ProtocolField smtpBodyField = new ProtocolField(smtpProtocol, "BodyFormat"); smtpBodyField.SqlExpression = "'html'"; smtpProtocol.ProtocolFields.Add(smtpBodyField); ProtocolField smtpFromField = new ProtocolField(smtpProtocol, "From"); smtpFromField.SqlExpression = @"'sender@adventure-works.com'"; smtpProtocol.ProtocolFields.Add(smtpFromField); ProtocolField smtpPriorityField = new ProtocolField(smtpProtocol, "Priority"); smtpPriorityField.SqlExpression = "'Normal'"; smtpProtocol.ProtocolFields.Add(smtpPriorityField); ProtocolField smtpToField = new ProtocolField(smtpProtocol, "To"); smtpToField.SqlExpression = "DeviceAddress"; smtpProtocol.ProtocolFields.Add(smtpToField); // Define protocol execution settings smtpProtocol.FailuresBeforeEventLog = 2; smtpProtocol.FailureEventLogInterval = new TimeSpan(0, 10, 0); smtpProtocol.FailuresBeforeAbort = 10; smtpProtocol.MulticastRecipientLimit = 50; smtpProtocol.WorkItemTimeout = new TimeSpan(0, 20, 0); // Add the SMTP protocol to the notification class flightNotifications.NotificationClassProtocols.Add(smtpProtocol); // Set expiration for notifications from this notification class flightNotifications.ExpirationAge = new TimeSpan(2, 0, 0); // Add notification class to application myApplication.NotificationClasses.Add(flightNotifications);
Development Platforms
For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.Target Platforms
For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.