LBi Techblog
Code & Technology Cocktail
Code & Technology Cocktail
3
Apr
Sometimes you want to discuss the sitecore tree with colleagues or the customer. The only way to achieve this is taking a screenshots but that does not give you the flexibility to change the structure or text in f.e. an e-mail conversation.
To solve this I wrote a small aspx page (code inspired by a blog post from Sean Kearney) to be able to copy paste the sitecore tree as rich text. (<ul> and <li> is used to achieve this)
How to us it?
Download 2text.zip Copy 2text.aspx in \Website\sitecore\admin\ Browse to http://yoursitecoresite/sitecore/admin/2text.aspx
Feel free to adapt it to your own wishes
13
Oct
Recently I had a bug in one of my website because of a recursive infinite loop. The effect was some random restart of IIS but noting in the sitecore logs and not way to know why.
In the windows event viewer I saw in the IIS section that the I had some IIS crashes with the event code 5011.
After googling a little bit I found this website: http://martinnormark.com/how-to-handle-iis-event-id-1009-event-id-5011-on-iis-7
So, if you create a dll with this class
#region Using
using System;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Web;
#endregion
/// <summary>
/// Handles all unhandled exceptions from in the current AppDomain.
///
/// Works great to catch unhandled exceptions thrown by IIS's child threads, /// which will make the application pool terminate unexpectedly
/// without logging. This makes sure your Exception /// is logged to the Application event log.
/// </summary>
public class UnhandledExceptionModule : IHttpModule
{
#region Fields
private static int _UnhandledExceptionCount = 0;
private static string _SourceName = null;
private static object _InitLock = new object();
private static bool _Initialized = false;
#endregion
#region IHttpModule members
public void Init(HttpApplication app)
{
// Do this one time for each AppDomain.
if (!_Initialized)
{
lock (_InitLock)
{
if (!_Initialized)
{
string webenginePath = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "webengine.dll");
if (!File.Exists(webenginePath))
{
throw new Exception(String.Format(CultureInfo.InvariantCulture, "Failed to locate webengine.dll at '{0}'. This module requires .NET Framework 2.0.", webenginePath));
}
FileVersionInfo ver = FileVersionInfo.GetVersionInfo(webenginePath);
_SourceName = string.Format(CultureInfo.InvariantCulture, "ASP.NET {0}.{1}.{2}.0", ver.FileMajorPart, ver.FileMinorPart, ver.FileBuildPart);
if (!EventLog.SourceExists(_SourceName))
{
throw new Exception(String.Format(CultureInfo.InvariantCulture, "There is no EventLog source named '{0}'. This module requires .NET Framework 2.0.", _SourceName));
}
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);
_Initialized = true;
}
}
}
}
public void Dispose()
{
}
#endregion
#region UnhandledException event handler
public void OnUnhandledException(object o, UnhandledExceptionEventArgs e)
{
// Let this occur one time for each AppDomain.
if (Interlocked.Exchange(ref _UnhandledExceptionCount, 1) != 0)
return;
StringBuilder message = new StringBuilder("\r\n\r\nUnhandledException logged by UnhandledExceptionModule:\r\n\r\nappId=");
string appId = (string)AppDomain.CurrentDomain.GetData(".appId");
if (appId != null)
{
message.Append(appId);
}
Exception currentException = null;
for (currentException = (Exception)e.ExceptionObject; currentException != null; currentException = currentException.InnerException)
{
message.AppendFormat("\r\n\r\ntype={0}\r\n\r\nmessage={1}\r\n\r\nstack=\r\n{2}\r\n\r\n",
currentException.GetType().FullName,
currentException.Message,
currentException.StackTrace);
}
EventLog Log = new EventLog();
Log.Source = _SourceName;
Log.WriteEntry(message.ToString(), EventLogEntryType.Error);
}
#endregion
}
Add add this
<httpModules> <add type="UnhandledExceptionModule" name="UnhandledExceptionModule"/> ..... </httpModules>
You will have more details about the cause of this error a StackOverflowException in my case.
It takes me a lot of time to find why because I didn’t find how to know witch line or class cause the exception but it already help a lot
This class also adds all the unhandled error in the event viewer so it is also great to have it.
12
Oct
useful if you need to generate a link to send to one of your editors.
The format of this link will be : http://Youthostname/sitecore/shell/Applications/Content Editor?id=%7b9822ABDF-F2B7-41BA-B56D-63E73BEB7E88%7d&vs=1&la=en&sc_content=master&fo=%7b9822ABDF-F2B7-41BA-B56D-63E73BEB7E88%7d&ic=People%2f16x16%2fcubes_blue.png&he=Content+Editor&cl=0
Where the parameters are:
useful of you need to open it from one of your xaml application :
UrlString str = new UrlString();
.Add("id", id);
str.Add("fo", id);
Windows.RunApplication("Content editor", str.ToString());
More sitecore tips on my blog: http://sitecoreblog.blogspot.com/
22
Sep
Jonathan, Luigi and Sarah are visiting LBi London! Let’s follow their adventure.
Jonathan – London
7:30 am – Time for Luigi and I to leave our accommodation in the Docklands to go pick Sarah up at St. Pancras! I’ve been working at LBi London for 2 weeks, while Luigi joined the team yesterday and Sarah will come just for the FatWire training.
9:00 am – We finally arrive at LBi where a unicorn (!) is there to greet us. It seems there’s a lot of shooting activity going on at the office these days! Yesterday we saw people in white spandex, a guy dressed as a panda, and we barely missed taking part in a balloon release (red ones of course) on the 2nd floor terrace. Keep an eye on http://twitter.com/#!/LBiLondon for more details! (hint: new show reel coming out soon)
9:15 am – Day 1 of this FatWire tailor made training kicks off. The whole team is attending even though the topics are rather tech savvy. We have a technical architect, a test lead, 4 testers, a configuration manager, an IT lead and 6 developers including our guest Sarah.
The dev team is quite blended: one is LBi London, 2 are from the client side (a big financial kingpin, “thou who shalt not be named”) and then Luigi and I from Brussels
The FatWire consultant goes over a list of topics requested by the team, which include:
- RealTime publishing: current publishing method used by client is “mirror to server”, meaning the assets being published are queued, mirrored to the destination and then unpacked. RealTime publishing is a dynamic process copying assets and their dependencies from one system to another. Each of the 5 stages of the process can be monitored through a user interface. The publishing can be scheduled to run at a specific time.
- Content Server developer tools (aka CSDT): Eclipse plugin allowing to manage FatWire resources and exchange them within a team. This has been improved in FatWire 7.6 and makes developer life much easier!
Tomorrow’s session will mainly be about CAS (SSO for all FatWire products), CIP (Content Integration Platform, which is used to connect to third party systems such as Documentum in order to export/archive FatWire data) and Engage (recommendation framework allowing personalization).
9
Aug
Here is our first contribution to the Shared Source library.
http://trac.sitecore.net/ScheduledTaskUtils
This module allows you to run manually a sitecore scheduler. This is very useful especially when you try to debug a scheduler.
Here is a small screenshot
If you have some bug of improvement request, you can post a reply to this post.
Original post on: http://sitecoreblog.blogspot.com/2011/07/new-module-on-trac.html
31
May
25
May
I just finished a technical demo for a customer when I got a very pleasant phone call to inform me that I would be on the Eurostar to London the next day for EPiServer training. The next day Nele, François and I arrived at The Office where we were introduced to our teacher Bevan Souster. We took some coffee and chatted a bit with the other participants from all over the world: our trainer used to live in New Zeeland, there were students from Scotland and Poland and there was also a colleague from LBi London. It seemed like this training would also be the perfect opportunity to work on our English accents. I really liked the international touch. I had just visited LBi New York during my holidays and now I met a colleague from our office in London. It’s always nice to exchange ideas in this global environment. After all students introduced themselves we kicked off with the EPiServer basics. Before this training I actually didn’t know that much about EPiServer so it was interesting to see what end users and editors could achieve with it. The last version of EPiServer also includes wysiwyg editing on the site, a great feature that editors see as a must have in modern CMS. Later we dived deeper into the core of the system. The team behind EPiServer made it easy to get started and gives developers a lot of tools, templates and a high level API to quickly build a basic dynamic website (with news items, google maps, …). The nice thing is that you get a lot of controls out of the box which take care of binding and other repetitive tasks. If you want to create more complex stuff the API will help you out. It’s also good to know that there has been already developed a lot by the community at epicode
From next week on I will be working on a real project at LBi London (can you feel the exitement!), so stay tuned for more EPiServer talk next weeks.
9
May
It’s about 1 year ago that Microsoft organized the Windows Phone 7 Developer Hub at Living Tomorrow. The perfect timing to have a look at who is developing #wp7be apps in Belgium.
At the moment (06/05/2011) there are 56 apps by 14 developers, for more details you should certainly check out the Windows Phone 7 Stories Blog.
And guess what I’m one of those 14 developers #BeTrains even made it to the App of The Week selection
Keep an eye on this blog, there certainly will be more posts on Windows Phone 7 development in the future.
9
May
For a small proof of concept I have been doing a bit of research on motion detection with a webcam in Silverlight 4. The goal is to allow the users to “click” a button by waving at it. There will be 4 buttons, one in each corner of the screen. If the user wants to “click” on a button he waves his/her hand at the location of the button.
Before I started coding I did some research on image processing to find the best solution for this “problem”.
There are a couple of good image processing libraries in C#.
Those libraries are actually quite powerful because you can do face/hand/object detection with Haar-like features. Alfréd Haar also proposed the Haar functions later used in Haar wavelets, very powerful math that is being used for image compression and multiresolution curves and surfaces. That’s all very exiting but unfortunately you cannot use them in Silverlight 4 because you can’t execute unmanaged code in a 3rd party app.
No panic, there are also some Silverlight libraries and tutorials on motion detection and object recognition.
I had a look at all the libraries and articles and found that the last one was the most interesting for my proof of concept.
The motion detection is actually quite simple:
So the algorithm detects areas where there is a lot of movement. Detecting a real hand would be very complicated without an unmanaged code library like EmguCV. A decent hand tracking algorithm in Silverlight would also be too CPU intensive.
9
May
Colorbox is a light-weight, customizable lightbox plugin for jQuery 1.3, 1.4, and 1.5. And I found out that the last part of that sentence is quite important the hard way.
I had a strange error on a page that used colorbox in internet explorer: “a script on this page is causing Internet Explorer to run slowly”. We didn’t change the source at all so it had to be linked to an external script … et voila we found the guilty line:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
There are good reasons why you should let google host jquery for you but be careful how you use this feature! If you just specify 1/jquery.min.js it will automatically take the latest version. So jQuery changed from 1.5.x to 1.6.x and it broke colorbox which is only supported up to 1.5. To bypass this problem we still let google do the hosting for us but we use a specific version of jQuery which is not automatically updated.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
So be careful if you automatically fetch the latest version of jQuery because it might break your site even if you did not change a line of code.