Thursday, March 4, 2010

Porting Legacy Web Apps to Sitecore Quickly

Have you ever had a client request where they’d like to have any of their Web apps to be ported over to Sitecore?  And, why not, it looks like Windows and it’s .NET, it can’t be that hard.  Well it can be easy and it can be hard depending on what level you want to port the application.  For this post, we just want to see the legacy app in the Sitecore Shell.  Sometimes, that’s all is needed since the Web app already works pretty well.  Plus, it just looks cooler when your app is within Sitecore.

So, to show the app within Sitecore, we just need to create a Start menu item that invokes the remote Web app.  Let’s start.

Power up Sitecore and login.  Click on the Sitecore “start” button > All Applications > Sitecore on the Net > Sitecore Homepage.  That’s just the Sitecore corporate site.  I’m guessing you’re following what I’m getting at.  You can easily encapsulate (frame) any Web apps that you have created. This is really important because Sitecore let’s you incorporate legacy Web applications especially when it takes a while to port a complex application.  This gives your CMS users a way to access the legacy app through the Sitecore shell provided that the app doesn’t interfere with Sitecore’s windowing mechanism.  There might even be a way to pass data from Sitecore to the app through the URL because that’s essentially how the Web app is invoked.

You can quickly do this by going to the Core DB.  Open the Content Editor and go under Documents and Settings. Traverse the nested folders until you get to Programs.  Inside Programs, you can create a Start menu folder, or the “shortcut” that invokes your legacy Web application.  To create the “shortcut”, which is really a Start menu action, select it from the Insert ribbon.  The most important piece of data you need to assign is under the Message field.  Enter:

RunExternal(\"<URL>", \"\", \"Software/32x32/application.png\", \"<WINDOW TITLE>\")

where <URL> is the Web address to your Web application, <WINDOW TITLE> is the title that is shown on the Sitecore window that appears.  You can also change the icon that appears on the window if you’d like.  Just make it the same icon that you specify in the Icon field of the menu item.

To see the new menu item, refresh the Shell or switch to the Master DB (which refreshes the Shell), and notice that you’ll find your new menu item in the Start menu.  Clicking this item should invoke your remote legacy Web application.

This is the quickest way. Obviously, you can’t do much with this since the Sitecore and the app are not really integrated.  There is only one way communication, if even any from the URL.  But, you can actually use Sitecore’s security to restrict access to the Start menu item, thus making it seemingly secured  Of course, you still have to keep the app secured somehow but at least there’s another level of security that can be used on top of the Web app itself.

There are other two ways to port apps into Sitecore.  With moderate complexity, you can use Sitecore as the app’s data storage.  This means that you’ll have to figure out how to port DB tables to templates (which is pretty simple since that’s how they initially taught us during Sitecore training to explain the concepts).  You can still just use straight ASP.NET controls to do your UI and just use Sitecore APIs to update those related Sitecore items.  I actually created one like this that essentially converted the ASP.NET generated site into PHP files and published the site to Linux with Apache complete with uploaded images, etc.

The most complex way is basically creating a XAML app.  That’s essentially how the native Sitecore apps you see now are developed such as Content Editor, Workbox, etc.  This has been the case since v5 so I’m not sure now how compatible Sitecore’s XAML with the Windows Presentation Foundation (WPF) (Anyone from Sitecore???).  This way of porting the legacy Web apps benefit from the separation of UI from logic, which is what XAML was supposed to achieve.  XAML is intended to be device-independent.  This method is the most lightweight and you can use all the readily available Sitecore-specific XAML controls already created by Sitecore.  You also benefit from the UI’s performance techniques such as AJAX and others without thinking about them.

Anyway, I’ve given you 3 ways to port your legacy apps.  Sometimes it just as easy to port an app than to only integrate them especially when it requires administrative UI.  One of the main reasons that Sitecore is so powerful is its UI, so leverage that with your legacy apps and future ones.

No comments:

Post a Comment