SubscriptionDefinition Class Content Studio 5.7 SDK
Content Studio Web Content Management System

[This is preliminary documentation and is subject to change.]

This class is used to read an maintain subscription definitions related to a category.
Inheritance Hierarchy

SystemObject
  ContentStudio.Document.SubscriptionSubscriptionDefinition

Namespace: ContentStudio.Document.Subscription
Assembly: CSServer5 (in CSServer5.dll) Version: 5.7.5016.0 (5.7.5016.0)
Syntax

public class SubscriptionDefinition

The SubscriptionDefinition type exposes the following members.

Constructors

  NameDescription
Public methodSubscriptionDefinition(CategoryId, SubscriptionType)
Initializes a new instance of the SubscriptionDefinition class.
Public methodSubscriptionDefinition(ConnectionId, SessionId, Guid)
Initializes a new instance of the SubscriptionDefinition class using a specific subscription definition identifier.
Top
Properties

  NameDescription
Public propertyAuthenticationSchema
Gets or sets the authentication schema to use.
Public propertyCategoryId
Gets the identifier of the category where this subscription properties are defined.
Public propertyConnectionId
Gets an integer that identifies the web site.
Public propertyDescription
Gets the description of the category whose subscription properties are loaded.
Public propertyDocumentType
Gets the type of the document this category can contain.
Public propertyEnabled
Gets or sets a value indicating whether this type of subscription is enabled for the current category.
Public propertyEventhandlerMoniker
Gets or sets the event handler moniker that the Service Manager uses when it creates a instance of an custom event handler implementation. This property can be set to an empty string to use the built in handler.
Public propertyIdentifier
Gets the identifier for this subscription definition.
Public propertyName
Gets the name of the category whose subscription properties are loaded.
Public propertyPresentationtemplate
Gets or sets the presentation template used when presentation the message source document.
Public propertyProperties
Gets the properties defined for this subscription.
Public propertySchedules
Gets the a collection of schedule items that describes the schedule to use with this subscription.
Public propertySender
Gets or sets the sender of the subscription message. For email messages this should be an email address
Public propertyServer
Gets or sets the name or IP-number of the server to use when distributing messages.
Public propertySiteUri
Gets or sets the site URL to when the event handler reads the document. This value should be the base url of the site without any file names.
Public propertyCode exampleSubscriptions
Gets the subscriptions of this subscription definition.
Public propertySubscriptionType
Gets the type of the subscription requested.
Public propertyTimeOut
Gets or sets the time out value.
Public propertyUserName
Gets the name of the user that the event handler will use while performing its task.
Top
Methods

  NameDescription
Public methodAddSubscription(String, SubscriberAddress, Boolean)
Adds the subscription to the current subscription definition without any MembershipProvider data.
Public methodAddSubscription(String, SubscriberAddress, String, Object, Boolean)
Adds the subscription to the current subscription definition.
Public methodClearSubcriptions
Removes all subscriptions from a specific definition.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetBaseUrl
Gets the base URL to use. If no SiteUri has been defined the method returns the standard site url from the site's settings otherwise the host name (including the scheme) of the SiteUri. The url ends with a "/" .
Public methodGetCredentials
Gets the credentials.
Public methodGetHashCode (Inherited from Object.)
Public methodStatic memberGetItem
Gets limited information about a subscribable category.
Public methodStatic memberCode exampleGetList
Gets a simple list of categories that can be subscribed to.
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodStatic memberRemoveSubscription
Removes a specific subscription by using a specific connection identifier and subscription identifier. I.e removes a subscriber from their category subscription definition.
Public methodStatic memberRemoveSubscriptions
Removes one or more subscriptions using one of more subscription identifiers. I.e removes one of more subscriber(s) from their category subscription definition.
Public methodSave
Saves the Subscription data represented by this instance back to the underlying database.
Public methodSetCredentials
Updates the credentials used by the event handler when it executes.
Public methodStatic memberSubscriptionsBySubscriber
Gets a list of subscriptions for a for the specified subscriber.
Public methodStatic memberSubscriptionsWithUserData
Gets a list of all subscribable categories with information about subscriptions for a specific address.
Public methodToString
Returns a String that represents the current SubscriptionDefinition object.
(Overrides ObjectToString.)
Top
Remarks

Note Note
This class is new in Content Studio 5.2
Examples

The following code sample shows how to programmatically enable a category for subscription, add a schedule and set some properties. This example works in a Content Studio document only.

//You might need to add the following using statement at the top of the class file.
//using ContentStudio.Document.Subscription;
try
{
   CategoryId catId = new CategoryId(CS_ConnectionId, CS_UserSession, CS_InsertedCategoryId);
   SubscriptionDefinition sp = new SubscriptionDefinition(catId, SubscriptionType.Newsletter);
   //Enable this category for subscription
   sp.Enabled = true;
   //remove any existing schedule
   sp.Schedules.Clear();
   //Add a new schedule effective on Monday, Tuesday and Wednesday at 12.00 and 19.00
   Schedule sch = new Schedule("Schedule1", new DateTime(2008, 01, 01), false);
   sch.AddWeekDays(DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday);
   //Add the occurences
   sch.AddOccurences(new SimpleTime(12, 00), new SimpleTime(19, 00));
   sch.Schedules.Add(sch);
   //Set the sender email
   sp.Sender = "info@ContentStudio.se";
   //Add (or update) a property and its value
   sp.Properties.SetProperty("myProperty", "property value");
   //Save the properties back to Content Studio
   sp.Save();
   Response.Write("<div>Subscription definitions was saved successfully!</div>");
}
catch(Exception ex)
{
   Response.Write(String.Format("<div><b>{0}</b>{1}</div>", 
                                "Unable to save the subscription!", ex.Message));
}

The example below shows how to programmatically determine whether a category is enabled for subscription and how to determine the next occasion specified in the schedule.

//You might need to add the following using statement at the top of the class file.
//using ContentStudio.Document.Subscription;
try
{
   CategoryId catId = new CategoryId(CS_ConnectionId, CS_UserSession, CS_InsertedCategoryId);
   SubscriptionDefinition sp = new SubscriptionDefinition(catId, SubscriptionType.Newsletter);
   string message;
   if(sp.Enabled)
   {
      Nullable<DateTime>nextDate = sp.Schedules.NextOccurence;
      message = String.Format("The category is enabled for subscription<br/>Next occurence: {0}", 
                              nextDate.HasValue ? nextDate.Value.ToString() : "None");
   }
   else
      message = "The category is not enabled for subscription";
   Response.Write(String.Format("<div>{0}</div>", message));

}
catch(Exception ex)
{
   Response.Write(String.Format("<div><b>{0}</b>{1}</div>", 
                                "Unable to read the subscription properties!",
                                ex.Message));
}
See Also

Reference