Monday, February 26, 2007

Cool open source .NET charting component

I've been looking around for a decent free (as in beer) .NET charting component that I can use from ASP.NET for my current website project. At first I tried WebChart, but it didn't seem to want to work under mono. I could have probably figured out the problem with a little bit of effort, but I've got better things to spend my time on at the moment. So a little more digging and a search of the Mono mailing list uncovered zedgraph. This component is awesome. Take a look at some of the sample graphs - it produces really professional looking results.

Now I haven't delved into the guts of it yet, that's tonight's task, but I just wanted to let people know it's out there.

Labels:

A fun weekend.

Well another work week has begun but I had quite a fun weekend so am OK about getting stuck back into it at work. On Friday night Bruce and I watched Alien and Aliens back to back. These are possibly two of the greatest Sci-fi movies ever made. We did Aliens 3 on Saturday night, but didn't quite manage to complete the set. Well, I guess there's always next weekend for the Resurrection!

On Sunday afternoon Anthea and I visited the London Zoo. Now I'm a firm believer that Zoo's not only have their place but are absolutely essential to the continued existence of so many of the wonderful creatures on this planet. It was great to see the breding programmes are having a positive impact and are literally bring a number of the species that I saw back from the very edge of extinction. Hopefully one day those species will thrive in the wild again, but for that to happen their natural habitats must first be protected from deforestation and poaching. I took a few photos although I didn't have time to look at any of them last night. I might post a couple here if any of them turned out OK.

Labels:

Friday, February 23, 2007

HttpHandlers and session state

While hacking on my website the other night I found a need to build an HttpHandler (actually a page would have worked fine, but a httphandler was more elegant). I got part way through debugging when I found that session state wasn't available in an HttpHandler! This caused me some consternation as I have an HttpModule which I use to retrieve my nhibernate session during the execution of a request and it stores the nhibernate session in the HttpContext session (hopefully that's not too many sessions and you're still with me).

Anyway I almost re-engineered the handler to work another way when a search of google groups revealed this simple solution, your handler simply has to "implement" the empty IRequiresSessionState interface (you'll need to be using the System.Web.WebSessionState namespace.) e.g.

public class VerificationHttpHandler : IHttpHandler, IRequiresSessionState

That's it, you now have http session available in your handler.


Labels:

Friday, February 16, 2007

nhibernate - a complex beast

I am beginning to discover that nHibernate is a far more complex beast than I realised. Over the last couple of days I've spent some more time reading the documentation (out of necessity rather than pure interest) and it is capable of some amazing things, however this flexiblity comes at the cost of complexity (as is often the case).

Here's an example of a trap for young players that caught me the other night. I have two entities A & B that map two two underlying tables tableA and tableB. The primary key of tableA is a foreign key in tableB. tableA contains a property Rating1Count which is the count of a column in tableB. I had code similar to the following:

ISession session = NHibernateHttpModule.CurrentSession;
ITransaction transaction = session.BeginTransaction();
try
{
    log.Debug("Saving new B");
    session.SaveOrUpdate(b);

    log.Debug("saved new B");
    ICriteria crit = session.CreateCriteria(typeof(A));
    crit.Add( Expression.Eq("AId", a.AId) );
    log.Debug("Executing query");
    IList As = crit.List();
    if (As.Count == 1)
    {
        a = As[0] as A;
        log.Debug(string.Format("Count of 1s in tableB {0}", a.Rating1Count));
    }
    transaction.Commit
}

After testing this I found that even though my changes were being persisted to tableB (verified by querying mysql directly) they weren't reflected in my tableA object.

Then it dawned on me, at what point does nhibernate write the changes to the database? I moved the transaction.Commit line up to be directly below the call to SaveOrUpdate and lowe and behold it works!

In hindsight it's obvious, but it had me scratching my head for a while (and it was late - at least that's my story and I'm sticking to it!).

Labels: ,

Wednesday, February 14, 2007

Been a busy boy

Well, so much for my good intentions to start blogging again pre Christmas. Life has been crazy busy as usual and this always seems to be one of the first things to drop off the list. I am hopefully on my way to being more productive now thanks to my new strategy for Getting Things Done. I'm only really part way towards fully implementing this program but I do feel that it's already helping me keep more on top of things.

We had a great trip around Paris, Rome, and the Amalfi Coast with my folks for Christmas. I am hoping to get the photos up on www.jamesfitzsimons.com soon.

I've been concentrating hard on my secret website project of late. I'll let you know more about the purpose of the site in the future when it's ready to launch, but for now lets just say it's great to get back into web development. I've been really enjoying playing with some of the new features of ASP.NET 2.0 (using Mono of course) and have also been discovering the magic of nHibernate. I hope to make more posts about the specifics of that in the future.

One of my recent discoveries while searching for information on some aspect of web development has been http://tropicalseo.com. This guy has some really interesting points to make about Search Engine Optimisation, but also about aspects of web site management in general. Oh, and it probably helps that I "share the dream"!

Labels: