Monday, October 27, 2014

An argument for using WebGrease instead of the ASP.Net Web OptimizationFramework

ASP.Net Web Optimization was introduced to ease the minification and bundling of JavaScript and CSS files within your project. It's available out of the box with any new project that uses the MVC 4 project templates. In your App_Start folder, there's a file called BundleConfig where you configure what files should be minified and bundled into one file. Minification and bundling are a good thing of course, because they reduce the number of requests the browser has to make in order to retrieve the resources it needs to render a page, and they reduce the size of those resources.

But, what if you have an MVC 3 or WebForms project? What do you do? There are plenty of tutorials out there that will walk you through adding the ASP.Net Web Optimization NuGet package to your project, and the steps that it will take to get your project configured. This post however takes a different approach. What if we don't use the ASP.Net Web Optimization package at all... what if we just use WebGrease instead?

Sunday, August 31, 2014

Installing Ghost on Ubuntu 14

I've been wanting to check out Ghost for a while now, and over the weekend I decided to give it a whirl. I fired up a new VM and installed the latest version of Ubuntu, downloaded the source from the site, and followed the simple installation procedure. And that's about as far as I got.

Unfortunately, something within the latest release of 'buntu is not configured correctly to just install and go. After some Googlin' I found Jinyu Liu's post about setting up Ghost, and he found the magic.

Run the following:
sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
It will fix the Node symbolic link, which is apparently not correct.

After running that, everything installed just as described on the site, and I had a new blog up and running in minutes.

Monday, August 25, 2014

SSRS Deployment Center

I recently worked on an enterprise project that involved deploying SSRS reports and data sources to different environments throughout the organization. SSRS reports have always lacked proper deployment tooling compared to other project types. The RS.EXE deployment tool from Microsoft makes it possible to create scripted deployments, but it's too complex for the average business user. And although it's possible to use it in conjunction with automated builds, it is not as easy as it should be. Because of this I created a set of GUI and command line tools called the SSRS Deployment Center that will hopefully ease future SSRS report deployments.

I've put the project onto CodePlex, so if your in need of a set of tools to make report deployments easier, check it out here:

The CodePlex site has all of the information you need to download, configure and run the tools.

Monday, July 28, 2014

SSRS Nested Subreport Gotcha!

Recently I was working on a reporting solution for a client when I ran across an interesting problem. I was writing a report in SSRS using multiple nested subreports that would roll up into the report. This has been a fairly common approach that I've used in the past. The difference in this case was the number of nested subreports. Specifically I was using three levels of reports, all of which used some form of data binding. I ran into an issue where the "grand-child" report would not render.

It is easiest to explain the situation using images. There are three reports. A top level, "master" report that we will refer to as the Parent. Within the Parent report there is a sub report that we will refer to as the Child. And within the Child report there is a sub report that we will refer to as the GrandChild.

Monday, July 21, 2014

Monday, April 28, 2014

Improving WebSql interaction using jQuery Deferred

I recently inherited a project that made heavy use of WebSql. Though it has been deprecated as a client side technology, this project was using it to create an offline web application that could be run on mobile devices. The immediate problem that I noticed with the project was that there was no consolidation of logic into a central JavaScript file. Each page included inline functions that essentially did the same thing, just using different queries. After profiling the site I realized that this "distribution" of logic also led to multiple instances of the web sql database being instantiated.... which, as you guessed, is a problem.

To address this issue I started by creating a wrapper for the Web SQL functions that would make it easier to work with the technology. The wrapper removes the work of instantiating the database object and managing the transaction, and it uses jQuery Deferred objects to make it easier to work with the results returned by the Web SQL calls.

Monday, February 24, 2014

A Multi-Term jQuery Mobile Listview Filter

If you've done any development with jQuery Mobile you've likely used the Listview Widget. It's a handy little component that makes rendering list data a breeze. Even better, it has a built in search filter that you can enable by simply decorating your list element with data-filter="true"

The default behavior of the Listview Widget's filter is to match on a single term. The moment you add an additional space into your search string, look out! But, if you need multi-term search behavior in your filter, it's easy to add.

Tuesday, February 4, 2014

Quick and Compliant Email Templates using Razor

Even in today's hyper connected world where you can Tweet someone's TV or Instagram your refrigerator, it seems like when it comes to business, Email is still king. If you need a simple, effective, and fast way to create a templated email in code, I suggest using Razor as your templating engine.

If you've done any MVC development since version 3, you've likely used the new Razor View Engine. Its concise and semantic, and it gets out of the way of your html. Best of all, it's not dependent on MVC, so you can re-purpose it in many different ways.

There are already a few existing projects that surround Razor templates. In this example I'm using the following project, but you can use whatever you prefer to get the job done:

I like the RazorTemplates project because like Razor itself, the syntax in the RazorTemplates project is concise and semantic.

Monday, January 27, 2014

Generic Repositories Including Includes!

The real credit for this solution goes to Steve Moss. He posted this article last year:

All that I've done is modified his work to fit in with the generic repository pattern that I often use.

One of the difficulties in using a repository to manage your data is that the repository itself can end up obscuring functionality from the underlying data provider. The pattern that I previously wrote about did just this. If you needed to Include relationships that were not originally established in your entity model, you had to create additional logic to retrieve that missing data.

As the Entity Framework has matured, the support for Including data from related entities has improved. Specifically, since EF 4.1, you can use strongly typed lambda's to specify relationships to eagerly load data. This, in combination with the existing string "Include", make working with entity relationships much more convenient.

To extend the original repository pattern to support dynamic includes, all that has to be done is to add an additional Select overload to the repository interface, and then make a quick change to the base class and the child classes that implement it.

1. Update the interface definition. The overloaded Select method that accepts an array of Expressions is the key.
public interface IRepository : IDisposable
    void Insert<E>(E entity) where E : class;

    void Update<E>(E entity) where E : class;

    void Delete<E>(E entity) where E : class;

    IQueryable<E> Select<E>() where E : class;

    IQueryable<E> Select<E>(params Expression<Func<E, object>>[] includeExpressions) where E : class;

    E Select<E>(object key) where E : class;