ICSEventHandlerEventHandler Method Content Studio 5.7 SDK
Content Studio Web Content Management System

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

Defines a standard event handler for Content Studio synchronous server side events. Objects that implements this interface can be called by Content Studio on the server side

Namespace: ContentStudio.EventActions
Assembly: CS5Interfaces (in CS5Interfaces.dll) Version: (

void EventHandler(
	string eventXMLArguments,
	string customData,
	Object content,
	ICSCredentialsContainer credentials,
	ref bool cancel,
	out int status,
	out string statusText


Type: SystemString
An xml document sent to the implementer from Content Studio.
The exact content varies between different events. The sample is typical for a document event (ex. OnDocumentSave or OnDocumentApprove).

<event type="Integer value"
        event="String value"
        msgid="String value" >
    <timestamp>Date value</timestamp>
    <connectionid>Integer value</connectionid>
    <callerinfo sid="String value" 
              logonname="String value" 
              email="String value" 
              fullname="String value" 
              userkey="String value" 
              sessionid="Integer value" />
        <documentid>Integer value</documentid>
        <documentname>String value</documentname>
        <filename>String value</filename>
        <encoding>String value</encoding>
        <categoryid>Integer value</categoryid>
        <documenttitle>String value</documenttitle>
event This element acts as the root node of the document.
 typeThe numeric identifier of the event.
 eventThe name the event.
 msgidA unique identifier of the specific event message
timestamp The date and time of the event
connectionid An identifier of the Web site
callerinfo This element has attributes that contain data about the caller.
 sidThe caller's security identifier in the SDL format (ex. S-1-5-16)
 logonnameThe caller's logon name in the DOMAIN\USERNAME format
 emailThe caller's email address, if registered in CS
 fullnameThe caller's fullname, if registered in CS
 userkeyThe caller's Content Studio userkey
 sessionidThe caller's session identifier
objectdata This element act as root node for elements that contains data about the affected document.
documentid The identifier of the document
documentname The logical file name of the affected document (ex. Unit1/Category1/pic1.gif).
filename The file name of the affected document as it appears on disc.
encoding The encoding (ex. utf-8), if existing, of the affected document.
categoryid An identifier of the category where the affected document is placed.
documenttitle The name of the affected document.
Type: SystemString
User defined static data that has been specified for the Event action definition that triggered this event. The data is supplied via the command text field in the Event actions property window.
Type: SystemObject
The document content as it exists in Content Studio when the event is raised. Not all events supply content.
Type: ContentStudio.EventActionsICSCredentialsContainer
A reference to Content Studio's implementation of the ICSCredentialsContainer interface. This is used to pass system defined credentials to the custom implementation. The event handler can use these credentials when ex. communicating with an external system such as a database or a mail server.
Type: SystemBoolean
A reference to a Boolean parameter. Event handlers sets this parameter to true to indicate that all changes in the Content Studio event that triggered the event should be rolled back. If the value remains false after the call, the event in Content Studio will not be rolled back, regardless of the outcome of the operation performed by the event handler..
Type: SystemInt32
Implementations should set this parameter to zero to indicate success. All other values will throw an error in the Content Studio event that triggered the event causing data to be rolled back.
Type: SystemString
The textual representation of the error indicated in the Status parameter

The following sample shows a complete implementation of a very simple custom event handler that prevents document to be deleted in a category regardless of the permission of the caller. When a delete operation occurs, Content Studio raises the event and if the event handler sets the cancel parameter to trueContent Studio rolls back any change made to the system.
Compile the sample code to a DLL named SyncEventHandler.dll and place the resulting DLL in the same directory as the Content Studio binaries are installed (ex. C:\Program files\Teknikhuset\Content Studio 5\CSServer). In the Content Studio administrative interface navigate to the category where the eventhandler should be used and in the Category properties dialog, open the Event Actions dialog. If you have sufficient permissions you should be able to create a new event handler for a Syncronous event handler object. Select the OnDocumentDelete event and in the ProgId textbox write the following string:
SyncEventHandler.OnDocumentDeleteHandler, SyncEventHandler
This will tell Content Studio Service that it can find an implementation of the ICSEventHandler interface in a class named SyncEventHandler.OnDocumentDeleteHandler located in the assembly SyncEventHandler. Content Studio locates the assembly, creates an instance of the OnDocumentDeleteHandler class and casts the instance to its implementation of the ICSEventHandler interface and calls the EventHandler method on the retrieved interface.

using System;
using ContentStudio.EventActions;

namespace SyncEventHandler
    public class OnDocumentDeleteHandler : ContentStudio.EventActions.ICSEventHandler
        void ICSEventHandler.EventHandler(string eventXMLArguments, 
                                          string customData, 
                                          object content, 
                                          ICSCredentialsContainer credentials, 
                                          ref bool cancel, 
                                          out int status, 
                                          out string statusText)
            status = -1;
            //Any custom message passed in?
            if((customData != null) || (customData.Length == 0))
                statusText = customData;
                statusText = "Delete is forbidden in this category";
            cancel = true;
See Also


Other Resources