Monitor Twitter and Respond with!

babblewatch-logo-final-med-whiteI’m looking to get some early feedback on a side project of mine, It’s a tool for monitoring Twitter and Responding. It’s main goal is to help build and maintain your companies brand reputation. It’s in very early stage development, but I wanted to get some feedback so please give it a try;

Re-blogging: Developing Linq to NHibernate

If you’re at a company that might be interested in helping fund a Linq to NHibernate project please read Developing Linq to NHibernate.

Tips for using Silverlight with Monorail (or embedded)

Today I worked on getting a Silverlight chart embedded in my monorail application. I learned a few things.

You need to have a Silverlight application project someplace in order to create the XAP file. This is what will ultimately get used in your view.

Since it’s really running client side, the XAP files are included in your other projects like other client site stuff, that is just manually copied into a directory there.

Databinding to XML doesn’t seem to work, I think I must be doing something wrong, but I finally ended up using Linq to transfer the data into objects and bind to those. Like this:

series.ItemsSource = from n in descendants</p>

                 select <span class="kwrd">new</span> Data
                                Date = n.Attribute(<span class="str">"Date"</span>).Value,
                                Count = <span class="kwrd">int</span>.Parse(n.Attribute(<span class="str">"Responded"</span>).Value)

series.IndependentValueBinding = new Binding(“Date”) { Mode = BindingMode.OneWay };
series.DependentValueBinding = new Binding(“Count”) { Mode = BindingMode.OneWay };

public class Data

<span class="kwrd">public</span> <span class="kwrd">string</span> Date { get; set; }
<span class="kwrd">public</span> <span class="kwrd">int</span> Count { get; set; }


In your View you use embed the XAP file using the object tag like:

<object data="data:application/x-silverlight," type="application/x-silverlight-2" width="100%" height="100%">
    <param name="source" value="/assets/Charts.xap"/>
    <param name="background" value="white" />
    <param name="minRuntimeVersion" value="2.0.31005.0" />
    <param name="autoUpgrade" value="true" />
    <a href="" style="text-decoration: none;">
    <img src="" alt="Get Microsoft Silverlight" style="border-style: none"/>

This is really my first time checking out Silverlight, so I'm sure I'm missing a lot and have a ton left to learn. There is a bunch of great info on the Silverlight site.

Selecting Aggregate Data With Castle.ActiveRecord

Lets say your using Castle’s ActiveRecord and you have a complex query to aggregate some data, but you want that query to return the data in a typed class, just not one that NHibernate or ActiveRecord know about…

Here’s what I ended up doing. Creating the SQL query then using the HqlBasedQuery class. There are two important details regarding this, first the query needs to name the columns using the SQL as keyword and setting the Scalar definition. Second, you need to set a transformer using the SetResultTransformer method. Luckily, NHibernate includes a class that will map named scalars to matching properties or fields. More about that here, in section 14.1.5.

Here’s the code:

var sql = @“
select convert(varchar, published, 101) as [Date],
count(state) as [Total],
sum(case when state = 2 then 1 else 0 end) as [Responded]
from notices n
inner join sources s on n.sourceid = and s.userid = :userid
where published >= dateadd(day, -7, getdate())
group by convert(varchar, published, 101)”;</p>

HqlBasedQuery q = new HqlBasedQuery(typeof (Notice), QueryLanguage.Sql, sql); q.AddSqlScalarDefinition(NHibernateUtil.String, “Date”); q.AddSqlScalarDefinition(NHibernateUtil.Int32, “Total”); q.AddSqlScalarDefinition(NHibernateUtil.Int32, “Responded”); q.SetParameter(“userid”, Id); q.SetResultTransformer(Transformers.AliasToBean(typeof(NoticeCount)));

var results = ActiveRecordMediator.ExecuteQuery(q) as ArrayList; if (results == null)

<span class="kwrd">return</span> <span class="kwrd">new</span> NoticeCounts();

var counts = results.ToArray(typeof (NoticeCount)) as NoticeCount[];
return new NoticeCounts { Counts = counts };

IDictionary and the Brail View Engine

I spent a lot of time trying to figure out that the brail engine assumes IList on indexed properties. If you have a IDictionary you need to use the get_Item method like:





Changes Needed for Castle.MonoRail to use jQuery

To get jQuery as the JS library for monorail I need to do the following:

  1. Get the JS files from jQuery and jQuery.Validation, save those to /Content/Js/ (or where ever).

  2. Implement the IMonoRailContainerEvents and IMonoRailConfigurationEvents interfaces on my GlobalApplication.cs file.

  3. In the Initialized method add:

IAjaxProxyGenerator ajaxProxyGenerator = new JQueryAjaxProxyGenerator();
container.ServiceInitializer.Initialize(ajaxProxyGenerator, container);
container.AjaxProxyGenerator = ajaxProxyGenerator;
  1. In the Configure method add:
configuration.JSGeneratorConfiguration.AddLibrary("jquery-1.2.1", typeof(JQueryGenerator))
  1. In the layout file reference the JS files like:
<script language="javascript" type="text/javascript" src="${siteRoot}/Content/Js/jquery-1.2.6.min.js"></script>
<script language="javascript" type="text/javascript" src="${siteRoot}/Content/Js/jquery.validate.min.js"></script>


  1. Use the Castle trunk source.


Publishing video as FLV using a SWF Player

This task turned out to be much more complicated then I would have expected. First just creating the video took a fair amount of time, trial, and error. I used CamStudio to capture the screen video and then the trial of Video Editor 8.

After that was done I ended up using Any Video Converter to convert the file to FLV. Then I needed a SWF player to embed in the web page. I looked at a couple of options, but ended up with OS Flv. Once that was done and working, I ran into one last issue, resolved here. IIS doesn’t serve FLV files by default, so I needed to add the mime type.

Brutalist Framework