Julian Wraith

Menu Close

Tag: 2011

Event Systems in SDL Tridion 2011

Event Horizon

As I mentioned in one of my previous post the event system has been revised to me more modular and, probably more importantly, to be native .NET.

An event, an action from a user, triggers the event system which is one or more .NET classes which will act upon this event in some way. In versions of Tridion prior to 2011 the event system has been a single class which then leads to having to combine different event activity into the same piece of code. For instance, additional logging and workflow elements might have to be combined; this leads to unnecessary complexity in the code itself. It also means you cannot easily turn off (and on) part of the code.

In SDL Tridion 2011, this has changed (although you can still run older event systems) to allow you to hook into events using multiple separate event systems. As Bart Koopman explains in this article, when we hook into the events we concern ourselves with the phase of the event, the type of event and the object itself.

The phase relates to where in the event you are, for example, initiated, processed, committed etc. The type refers to the type of event, e.g. Publishing, BluePrint, or Data Modification events. Lastly our object (or in more familiar terms “item”) itself; our Component, Page, Schema etc. With these I can easily define that I would like to fire an event on a Component, when it is published and after that publish action has started.

Two more additional features are important. Firstly, it is quite possible that you have more than one event system hooked into the same event, so with the “Event Subscription Order” you can also specify the order in which your code is triggered (creating a event system stack). Secondly, you can also specify an event to run asynchronously rather than wait for code to complete before other code can continue (synchronously).

Event System Example

We need to do two simple things to get this to work:

1)      Define out event system class

2)      Configure SDL Tridion to load the event system and make it active

The Event System Class

We need to define our event system and this being .NET we can pretty much do anything we want from here, however, we need to at minimum hook (or rather subscribe) to an event.

Our event is going to log everything that happens to a Windows Event log called “Message Log”. We open our class and declare all the variables we need etc:

using System;
using System.Diagnostics;
using System.Threading;
using Tridion.ContentManager;
using Tridion.ContentManager.Extensibility;
using Tridion.ContentManager.Extensibility.Events;

namespace Tridion.Utilities. ExampleEventSystem {
[TcmExtension("ExampleEventSystemEventHandlerExtension")]
      public class ExampleEventSystem : TcmExtension {
           #region Local Variables
           private static EventLog messageLog = new EventLog();
           #endregion

In our constructor we will initialize out Windows Event Log and call our subscribe method:

          public AuditLogger() {
               Init();
               Subscribe();
          }

Create the event log:

          private static void Init() {
               if (!EventLog.SourceExists("TridionMessages")) {
                   EventLog.CreateEventSource("TridionMessages ", "Message Log");
               }
               messageLog.Source = " TridionMessages ";
          }

Subscribe to our events:

          public void Subscribe() {
               EventSystem.Subscribe<IdentifiableObject, TcmEventArgs>( LogMessage, EventPhases.Processed);
          }

In this case I have used all “IdentifiableObject” which is everything, the method, LogMessage, that will called when the event fires and the phase is “processed”. The method signatures for subscribing are:

Subscribe<TSubject, TEvent>(TcmEventHandler<TSubject, TEvent> eventHandler, EventPhases phases, EventSubscriptionOrder order)
SubscribeAsync<TSubject, TEvent>(TcmEventHandler<TSubject, TEvent> eventHandler, EventPhases phases, EventSubscriptionOrder order)

In our case we defined no subscription order so it will be “normal” order.

And finally define the method that will actually log our message:

          private static void LogMessage(IdentifiableObject subject, TcmEventArgs args, EventPhases phase) {
               String message = "Session user: " + subject.Session.User.Title.ToString();
               message = message + "\nTarget URI: " + subject.Id;
               message = message + "\nItem Type: " + subject.GetType().Name;
               message = message + "\nEvent: " + args.GetType().ToString();
               message = message + "\nPhase: " + phase.ToString();
               messageLog.WriteEntry(message, EventLogEntryType.Information, 0, 0);
          }
     }
}

Configuring Tridion

To load our event system, we must load the class responsible. This we do in the Tridion.ContentManager.config which can be found under the %TRIDION_HOME%\config directory and we add a line to the extensions section to add our assembly:

<extensions>
<add assemblyFileName="C:\myevevntsystem\messagelogger.dll"/>
</extensions>

Five things you must know about SDL Tridion 2011

Online Marketing Explorer

It has been released and I decided to list out five things that I think are very important to the release of 2011. Mostly talk has been about the new Content Manager Explorer (and it’s cross browser functionality) but this is just the surface. Underneath there are many changes of which just five is a small snippet of what you can find in the box…

The five:

Scalable Deployer

To meet the demands of a large scale enterprise the deployer is now much more scalable than before allowing organizations to constantly grow their environment to meet the demands placed upon it by a growing content organization. The scalable deployer allows multiple processes to simultaneously process deployments as well as updating the publisher on how much load they can handle to avoid overloading.

Storage Layer

The new Content Delivery storage layer is based upon the Java Persistence API (JPA) and its concrete implementation, Hibernate.  With this you are able to expand the single Content Delivery storage layer to encompass multiple different data sources (e.g. product information or user generated content)  into one single layer.

Online Marketing Explorer

Drive Customer Impact with the new Online Marketing Explorer. Giving an overview of your marketing activities with a centralized model of campaigns, reporting and actionable insights.

Content Services

Content Services is the new RESTful webservice on Content Delivery based upon the oData and oAuth standards. You now have your published content available through a webservice to any application, mobile app, affiliate, white label site, 3rd party the list goes on…

Event System

The new fully .NET event system is modular. Does not sound like much but you can add one or more separate event systems to the same Content Management environment. Each event system can work alone hooking into different CM activities or can work together as part of coordinated event driven activities.

I love SDL Tridion

Now it will not come as a surprise to many of you that I work for SDL WCMS (as a Technical Account Manager) and I have been working here for almost 8 years. In that time I have seen 11 versions of the SDL Tridion Content Manager platform of which the new 2011 version is the latest.

As I love SDL Tridion I wanted to share with you the video released this week that tells, from our employees point of view, why we all love SDL Tridion so much…

PS: Don’t forget to switch it to HD!

SDL Tridion 2011 Visual highlights

Recently I attended the bootcamp of the 2011 Community Technology Preview, a preview for existing partners and customers of the latest version of SDL’s WCMS, SDL Tridion 2011.

What has changed the most – or rather the most obvious change – is the Content Manager Explorer also known as the Tridion GUI. In 2011, apart from running on all the major browsers and also an iPad, it features a redesign that will be familiar to existing users but also taking on board lots of new usability features.



One of the nicest features of the new interface is the ribbon toolbar. On the current version of Tridion, the buttons on the toolbar are somewhat hard to see and can make it difficult to see what the particular button is supposed to do. The ribbon features a big icon and some text as well which should make finding the function you want easy.



If you don’t like the ribbon you can always collapse the ribbon down to the more traditional row of icons.



Two more features I would like to highlight. Gone are the tabs on the publishing queue and it now shows you all options in the same area. It’s common for me to forget that I have other options on the other tab, so having them all in one place is better for the old folk like myself.



And then lastly I want to show you another nice feature. Error messages in-line to the interface, so now the option to feed more back to the user about what is going on. If you missed a message, you can also get a list back of the message history.



© 2019 Julian Wraith. All rights reserved.

Theme by Anders Norén.