Automate your tasks

January 12th, 2012 | Posted by Robert Curlette in Lifehacking - (1 Comments)

Automate it

My timesheet is one of the most important things to do every day but the last thing I think of. Last year I discovered the Windows Scheduler program and my timesheet has never been so up to date. I only noticed how effective it was when my password changed and the programs stopped opening automagically every day at the same time.

Scheduler opens the Excel sheet and puts it in front of my face at 4:55 pm every day. It takes me 5 seconds to put the hours in and save. Done.

How to do schedule Excel to open automatically on Windows XP:

1. Open Control Panel, Scheduled Tasks
2. Add Scheduled Task
3. In the Application list select Microsoft Excel. If it is not listed there, you can copy the shortcut from the Start/Programs menu
4. Select when to perform the task
5. Enter password. Note: if your password changes the tasks stop running and do not show you any errors or reminders. It usually takes me a few days before I realize it is not opening. Forgetting about it is specific to my timesheet, for some strange reason.
6. Checkbox for advanced properties. This is where we put the file we want to open.
7. In the run textbox, go to the end of the line, put a space, then add the path to your Excel file like this “C:\RC\Docs\Timesheet_Curlette_2012.xls”
8. Finish, put your password in again, and forget about it. Your computer is now going to do the most difficult part – starting the task!

Scheduling the browser:

I live in Amsterdam and there is a last minute ticket website that sells tickets at 50% off starting at 12:00 noon every day. The ticket office is around the corner from where I work, so if I see something, I can walk over and buy them right away.

1. Follow the steps above, in step 3 choose Firefox, Chrome, Safari, etc.
2. In step 7, after the link to the app in the run box, type the website address in quotes. My link to firefox looks like this: “C:\Documents and Settings\All Users\Application Data\Mozilla Firefox\firefox.exe” http://www.lastminuteticketshop.nl

Good luck with improving your daily tasks!

Tridion Event System 2011

November 29th, 2011 | Posted by Robert Curlette in Tridion - (10 Comments)

The Tridion 2011 upgrade brings a whole new set of possibilities for the Tridion Event System. Exciting improvements include Asynchronous events, multiple Event System DLL support, configuration via XML file, and a much more flexible architecture. Overall a great effort from Tridion and a much welcomed one. ūüôā

Advantages to 2011 Event System

  • Native .Net architecture
  • Multiple Event systems per server
  • Asynchronous events
  • Uses delegates to subscribe to Events
  • Additional Event Phases (Abort, InDoubt, Processed)
  • Configured via XML file. Can easily see which .dlls will be called by the Event System

Event Phases

The Pre (Initiated) and Post (Processed) are still there, and are joined by 3 new Event Phases.

  • Initiated = Pre
  • Processed = Post
  • TransactionCommitted = Post
  • TransactionAborted
  • TransactionInDoubt

Sample Event System Project

Getting started with the new Tridion Event System in 2011 is easier and a complete different experience than with previous Event Systems. I will walk through setting up a new Event System for 2011 and implementing 1 sample event.

Let’s create a sample event system project in Tridion 2011 for the famous OnComponentSavePre event. For this demo I will use Visual Studio 2010, but you can also use VS 2008 or VS 2011. Following these examples it is easy to map an older Event System to then new Tridion 2011 model. We also gain a lot more flexibility, control, and predictability over the Events in the implementation.

Create a new Windows Class project from Visual Studio

– Target Framework can be .Net 4.0 or .Net 3.5

Add references and using statements

DLLs are located at \{install folder}\Tridion\bin\client
– Tridion.Common.dll
– Tridion.ContentManager
– Tridion.Logging
– Tridion.ContentManager.Publishing (if using Publish Events)

using System;
using Tridion.ContentManager.ContentManagement;
// Add Reference to 'Tridion.ContentManager', located @ Tridion\bin\client on CMS Server
using Tridion.ContentManager.Extensibility;
using Tridion.ContentManager.Extensibility.Events;
using Tridion.ContentManager.Publishing;
using Tridion.Logging;

Create the Class

Tridion calls all of our Event Systems configured in the Tridion.ContentManager.Config file. For this reason, we need to make sure the class attribute [TcmExtension(“SomethingUnique”)] is placed on our Event System class.

The class extends the TcmExtension class and this is needed on our class for Tridion to implement the methods.

namespace Tridion.EventSystem.v2011
{
    // The class attribute is unique per Event System dll on the server.
    // In 2011 we can have multiple Event System dlls on 1 server.
    [TcmExtension("Tridion2011EventSystemRC")]  // This needs to be unique per Event System
    public class EventSystem : TcmExtension
    {

Subscribe to Events

Place all of your subscribe calls in the class constructor or create a method as I do here called Subscribe and place the subscription methods there. Tridion only calls the methods in the Constructor when firing Events.

The .Subscribe method signatures are very special and needs all of the params to work and in this order. The online documentation describes the method signatures in more detail. See the documentation link at http://www.sdltridionworld.com.

public EventSystem()
{
	Subscribe();
}

public void Subscribe()
{
	// OnComponentSavePre
	EventSystem.Subscribe<Component, SaveEventArgs>(OnComponentSavePre, EventPhases.Initiated);
}

Component is the object we are subscribing to and SaveEventArgs is the Event we listen for. There are lots of EventArgs and it is best to use the Visual Studio object browser to see them all.

OnComponentSavePre is MY method and I could call it OnComponentDoThisBefore if I wanted to, but I use the original R5 names to keep it simple.

EventPhases.Initiated is the new -Pre and TransactionCommitted is the new -Post.

Implement Events

Create the methods to handle the event with the above method signature. The Params must match the signature of the Subscribe event. The order should be the same, (Object, Event, Phase).

private static void OnComponentSavePre(Component comp, SaveEventArgs args, EventPhases phase)
{
	comp.Title = "a " + comp.Title;
	args.ContextVariables.Add("StartTime", DateTime.Now);
}

Here I use Component for the Object and update the Title when saving. This is one way to test if the Event system is working. If I used a Post method I would need to throw an error to the Event Log or use a Logger to test if it works.

If I wanted to capture the Event for all items, I could subscribe to the IdentifyableObject and if I only wanted to catch the Events on VersionedITems (think Component, Page, Template, etc) then I could subscribe to a VersionedItem – both new in 2011.

Handling Errors

Any Pre- Errors show up in the new Tridion Message Center. This is really nice and much improved from previous error dialogs. The messages are saved and we can view them later. This implementation of errors is very handy when debugging the -Pre Events, now called ‘Initiated’.

The Tridion.Common assembly is needed for the TridionException event.

Installation / configuration

  • Copy the compiled DLL to the CMS Server
  • Open the Tridion.ContentManager.config file
  • Add the dll to the extensions:
    <add assemblyFileName=”C:\Program Files (x86)\Tridion\bin\Tridion.EventSystem.v2011.dll”/>
  • Shut down COM+
  • Restart the ‘Tridion Content Manager Service Host’ Service

Summary

I really enjoy working with the new Event System and think the Async support, multiple event systems, and .NET 4.0 integration will provide a stable foundation for the future. A big thanks to the Tridion R&D team for doing a great job with the new and improved Event System for Tridion 2011.

Full Code:

using System;
using Tridion.ContentManager.ContentManagement;
// Add Reference to 'Tridion.ContentManager', located @ Tridion\bin\client on CMS Server
using Tridion.ContentManager.Extensibility;
using Tridion.ContentManager.Extensibility.Events;

namespace Tridion.EventSystem.v2011
{
    [TcmExtension("Tridion2011EventSystemRC")]  // This needs to be unique per Event System
    public class EventSystem : TcmExtension
    {
        public EventSystem()
        {
            Subscribe();
        }

        public void Subscribe()
        {
            // OnComponentSavePre
            EventSystem.Subscribe<Component, SaveEventArgs>(OnComponentSavePre, EventPhases.Initiated);
        }

        private static void OnComponentSavePre(Component comp, SaveEventArgs args, EventPhases phase)
        {
            comp.Title = "a " + comp.Title;
            args.ContextVariables.Add("StartTime", DateTime.Now);
        }
    }
}

Tridion WebDav URL

November 9th, 2011 | Posted by Robert Curlette in Tridion - (0 Comments)

Tridion makes all items available using a WebDav URL. This is an environment independent variable that never changes. It is preferred to use this instead of an item URI when programming templates or scripts.

I recently needed a WebDavURL for a Folder and wrote the following snippet in a Component Template and then previewed with a Component in the desired folder:

[%
writeout component.organizationalitem.info.webdavurl
%]

This WebDavURL can be used anyplace you would normally use a URI.

The WebDavURL is also available on the info tab – however, on that screen you cannot copy it.

Getting ready for the upgrade

The Tridion 2009 upgrade is a low-risk upgrade that provides significant benefits for templating development, tagging content with keywords, and more efficient Broker queries. Anyone using Tridion 5.3 today can gain many benefits with little effort.

Step 1: Confirm server hardware requirements

Read the manual. Login to www.sdltridionworld.com and download the Tridion 2009 Upgrade guide.  Pay attention to the supported platforms information and confirm your servers meet the minimum requirements.

Most likely your support agreement includes upgrading to the latest version, including Tridion 2009

Step 2: Prepare workstations for developing using Visual Studio

Software: Visual Studio 2008 / 2010 РI prefer VS 2010 with features such as intellisense (matching a word anywhere the function contains it, not just at the beginning), jQuery debugging, and great Asp.net MVC support.  It also supports compiling to asp.net 2.0, 3.5, and 4.0.

Version control РI prefer Subversion but have heard great things about GIT.  SVN has a free plugin to Visual Studio called Ankh, allowing commits and updates from VS.  TortoiseSVN provides tight Subversion integration with Windows Explorer

Hardware –¬†If running Visual Studio 2010 then 2GB Ram is essential. ¬†For Event System development and workflow I suggest to run a local instance of Tridion inside a VMWare image. ¬†This works really well on Macs too! ¬†Otherwise, it might be possible to remote into a development server, but sharing connections is less than ideal in a development team, and installing workstation tools on a server is not ideal.

Questions and Answers

TemplatesРWill my existing .NET, VBScript, and XSLT templates work?  Yes,   Tridion is notoriously good about supporting legacy methods (there are still some version 4.4 methods in the API!).  No worries here.

Compound TemplatesРDo I need to re-write my templates?  No, all 5.3 templates will work, and you can use the new Compound Templating features side-by-side with the older VBScript templates.

Template Functions:  What are template functions?  Tridion 2009 provides the ability to write custom functions in .NET and call them from your HTML DWT templates.  This brings a lot of possibilities to DWT templates.

BrokerРWill my Broker queries still run?  The answer is yes, and they may even be improved due to refactoring of the SQL generated to the Broker.  

SiteEdit– Which version of SiteEdit does Tridion 2009 work with? Do I need to upgrade to SiteEdit 2009?

Tridion 2009 works with SiteEdit 1.3 as well as SiteEdit 2009.  Please make sure to get all the hotfixes for SiteEdit 1.3.  However, SiteEdit 2009 SP2 provides great customization features, including adding items to the toolbar.  It also works with both VBScript templates and Compound Templates.  New browser support is added and editing pages in Chrome and Firefox never felt better.  SiteEdit 2009 SP2 is definitely worth the upgrade.

GUIРWill my Tridion users be OK with the new GUI?  Yes, the GUI now offers more options for keywords, but otherwise the other features work as they do in 5.3.  

Outbound EmailРIs Outbound Email compatible?  Yes, and there is a new version of Outbound Email, Outbound Email 2009, that provides better email campaign and contacts management and continues to promote content re-use for all mailings.

Part 2 will cover upgrading the CMS, Database, and Broker. Part 3 will cover the first steps in working with Compound Templating.

Book: Design of Design

June 2nd, 2010 | Posted by Robert Curlette in Book review - (0 Comments)

Fred Brooks of Mythical Man Month fame is back and brings all of his insights together in one book.  The short chapters in the book are refreshing and bring pointed insights gained from years of experience as both a software architect and a traditional building architect.  Going into challenges such as remote teams and communicating the book approaches current issues facing many organizations.

I really enjoyed his discussion of using prototypes and iterations to achieve software success.¬† He is a ‘dyed-wool empiricist’ meaning that in his view all people will make mistakes and it is impossible to write a perfect software program that addresses all user requirements and without bugs the first time.¬† This is a refreshing view and relieves the pressure of the waterfall model where there are no iterations or going back to previous steps for refactoring the solution based on new information gathered while building the software.¬† He mentions that in other fields the designer or architect often reworks the solution to take advantage of a constraint that has disappeared during the project.¬† Often in the waterfall model there is no time to do this because the project team is living inside a time box where everyone is rushing to finish the deliverable to hand the ‘final’ version to the customer.

I am looking forward to incorporating more prototypes and iterative approaches in my next projects.  Hopefully the customer will be happy and have the right expectations set before seeing the final product.