Saturday, 26 January 2008

Sitecore Xpress Personal Developer Edition

Huh? What’s that? Is this an entire new product from Sitecore?

That’s right! That’s what it is. And, - then not…

Sitecore Xpress Personal Developer Edition is a free product for you developers out there who want to build your personal web sites running on the exact same technology as the traditional Sitecore site: The same technology that serves web pages to more than 6000 web sites (1400 customers).

It is also the product for those developers who want to learn and experience some of the coolest web based AJAX driven technology on the market. Those who want to play in a fantastic .NET based environment, with full access to the Sitecore Developer Network.

So, when can you do this? Thursday, February 7, 2008 at 7:30 AM (Central European Time), the public web site of Sitecore Xpress will launch. And so will the availability for the product.

You may also register at the two similar webinars that day, which should match most of the globe working hours, to learn much more about the product and for what you may use it. Find the links to the webinars at the Xpress web site, Xpress.sitecore.net.

189426a5e778c594eb67a69cbd5996d1.jpg

09:45 Posted in Sitecore | Permalink | Comments (4) | Email this | Tags: Xpress, Sitecore, .NET, free

Thursday, 08 February 2007

Shuffle children C#

Somebody the other day asked how to create a random spots on the front page of their web site. This is naturally quite simple; by using a simple random function.

However, this user wanted to select specific items using a Sitecore query. The resulting list should be shuffled so the developer easier could iterate through the items.

This is quite easy.

The shuffle algorithm below is very fast. It basically splits the list into two parts; the ordered part and the shuffled part. When an item is selected from the ordered part randomly, it's moved to the end of the shuffled part. And that's simply it; very very fast, and very simple.

Now, this method (RandomizeList) is somewhat generic: I might consider creating a strongly typed list (I actually wanted to do this with the ChildList, but It's read-only). Here goes:

static Random rng = new Random();

static void RandomizeList(IList list)
{
  for (int i = list.Count - 1; i > 0; i--) {
    int swapIndex = rng.Next(i + 1);
    if (swapIndex != i) {
      object tmp = list[swapIndex];
      list[swapIndex] = list[i];
      list[i] = tmp;
    }
  }
}

An example of usage could be something like:

protected void Btn_Click(object sender, EventArgs e) {
  Item itm = Sitecore.Context.Database.GetItem("/sitecore/content/home");
  ChildList children = itm.Children;
  Item[] childrenarray = children.ToArray();
  RandomizeList(childrenarray);

  foreach (Item child in childrenarray){
    Response.Write(child.Name + "<br />");
  }
}


13:30 Posted in .net | Permalink | Comments (0) | Email this | Tags: Sitecore, C#, .NET, Shuffle

Friday, 04 August 2006

Web based task manager in AJAX

Let’s recapitulate the challenge from my last post

We wanted to build a web based application for Sitecore that uses AJAX for emoting something between the task manager and the performance monitor; a customizable task manager.

The reason for creating a task manager / performance manager is two-fold: 

  1. Sitecore allows asynchron processes to be executed as background threads. Indexing, publishing, reporting and other time consuming processes which runs at low priority. For this purpose, Sitecore leverages the access to these threads by a Job manager. The task manager should visually display the jobs being executed, and the status of these.
  2. Solutions can be hosted or devoted or secure servers where access is limited. System administrators may want to use the web based interface to investigate performance monitors from their local machine through the web based interface.

Now, from an architectural point of view, how did I put together this piece of software?

First I thought it would be fairly easy; simply create an AJAX or native .NET application, then let it execute an update every, - say 3 seconds. It should request new tasks as well as getting the basic CPU usage.

But hey; we don’t want to update the entire grid of jobs on every single request. Also, why not make it possible for the user to add their customized performance counters to the usage load display. And then, why not at the same time, display it as a graph.

So, now I was down to a number of features that should be created:

A web based application that would, every X second through XJAX execute some code behind. The code behind would:

  1. Read the Sitecore jobs and update a grid.
  2. Process specific performance counters and
    1. Build an image.
    2. Return image.

Well, it wasn’t really that simple. First of all, I would need to build another AJAX application that allows users to select performance counters and return it to the first form to update another grid.

Allow user to select a performance counter on the grid and change the scale of the graph. Also, when selecting an item, it should be possible to se average value, last value, max value and min value of the selected counter.

So:

  1. Build two applications: “Monitor” and “Select performance counter”.
  2. Build job processor class
  3. Build a task manager class that can read selected performance counters and update them as well as return specific stats.
  4. Build a graph class that can receive data sets, and draw a line graph.

Well, I soon found out that by calling the task class every 3 second would result in two challenges which were mutually damaging:

  1. First, a call every 3 second, and then a performance counter number would result in a rough graph with 3 seconds intervals.
  2. Second, drawing a graph every 3 seconds would result in server load as drawing and file operations. This would be equivalent to having a performance counter affecting performance counts.

Above raises a major challenge with the current architecture. I cannot increase the number of requests to give a better, smoother graph as this would increase the number of graph paints and server load, and in the other hand I cannot decrease the server load.

But, as always, this can be solved. I did it by creating a performance counter collecting Sitecore job which would run as a background thread. It will be kept alive by a ping from the main monitor application every time I request a new graph. The job collects counters every second. Then every 5 second, I request a graph based on the data collected.

So, as simple as that:

  • Create a background thread that can be configured from an application. Thread collects performance counters.
  • Two XAML applications (that are compiled into .NET forms) which are AJAX based:
    • Monitor application
    • Get new counter application
  • Graph class that can draw a class.

Interesting links: