Creating dynamic pivot reports on SQL Server

In one of my current projects I have some pivot reports that show count of issues in different states. Grouping depends on report. States are dynamic – admins can define new states and save them to states table. This means that I cannot hardcode names of states to queries. Instead I need dynamic pivots. In this posting I will show you how to write reporting procedures that offer dynamic pivoting capabilities.

Read more

ASP.NET MVC: Helper method to display date ranges

I have events web site where I want to show events start and end time to visitors. I wrote simple extension method called DisplayTimeRange() to display event time range on user-friendly manner. My goal is to show times as 01.01.2012 10:00 – 14:00 and 01.01.2012 15:00 – 01.03.2012 18:00. It’s practically displaying time ranges is shortest possible way. In this posting I will show you how to do it using extension method.

Read more

Windows Azure error: An unsupported response was received. The response header ‘MSDeploy.Response’ was ” but ‘v1’ was expected.

You may get the following error when deploying your web application from Visual Studio to Windows Azure using WebDeploy: Remote agent could not be contacted. Make sure the remote agent service is installed and started on the target computer.
An unsupported response was received. The response header ‘MSDeploy.Response’ was ” but ‘v1’ was expected.
The request was aborted: The request was canceled.
COM object that has been separated from its underlying RCW cannot be used.

Read more

The selected database contains foreign keys that create a cycle

You may get the following error when creating data scripts with MSSQL 2008: The selected database contains foreign keys that create a cycle. Publishing data only is not supported for databases with cyclical foreign key relationships. This problem is caused by self-referencing tables and it is given even if you don’t export data from one of such tables. Here is simple and very dirty solution.

Read more

Deploying independent web applications to Windows Azure using single web role

I found very good blog post by Andy Cross’ Blog where he describes how to deploy multiple web sites in a single Windows Azure web role. I like the idea but there are some things that should be understood and done differently if you plan to use same web role for totally different web applications that you want to run on your Windows Azure instance. In this posting I will show you how to deploy independent web applications to Windows Azure instance using single web role.

Read more

Connecting Windows Home Server to web through two routers

I wanted to get my Windows Home Server configured correctly for web so I have valid certificate by Microsoft and I can use subdomain service they are offering. As my home network is not default that is expected by Windows Home Server (no direct access to router that is connected to web) I had to trick my WHS a little bit. In this posting I will show you how to get Windows Home Server work with Microsoft address (http://something.homeserver.com) if it is not connected directly to router that has access to web.

Read more

Windows Azure Error: Failed to start Storage Emulator: the SQL Server instance ‘localhost\SQLExpress’ could not be found

When running some of your Windows Azure applications when storage emulator is not configured you may get the following error: “Windows Azure Tools: Failed to initialize Windows Azure storage emulator. Unable to start Development Storage. Failed to start Storage Emulator: the SQL Server instance ‘localhost\SQLExpress’ could not be found. Please configure the SQL Server instance for Storage Emulator using the ‘DSInit’ utility in the Windows Azure SDK.”. Here’s how to solve this problem.

Read more

Using Lazy and abstract wrapper class to lazy-load complex system parameters

.NET Framework 4.0 introduced new class called Lazy and I wrote blog post about it: .Net Framework 4.0: Using System.Lazy. One thing is annoying for me – we have to keep lazy loaded value and its value loader as separate things. In this posting I will introduce you my Lazy wrapper for complex to get system parameters that uses template method to keep lazy value loader in parameter class.

Read more

ASP.NET 4.5 Preview: Using model binding to display data

ASP.NET Forms 4.5 Preview introduces us model binding for web forms. Web developers who are familiar with ASP.NET MVC already know what model binding is and how powerful it is. Model binding means framework ability to construct objects of known types using values from presentation layer. In this posting I will show you how to use model binding with ASP.NET Forms 4.5.

Read more

Using Lucene.NET search engine library in .NET applications

Adding search capabilities to applications is something that users often ask. Sometimes it is not enough to have just filters on lists. Instead of going with mainstream and write complex SQL queries we can be smarter and use specialized indexing and search solutions that perform way better than custom large SQL queries that I consider as anti-pattern for searching something. In this posting I will introduce you Lucene.NET indexing and search engine and show you how to use it in your applications.

Read more

Using Moq to mock ASP.NET MVC HttpContextBase

Here’s my little example about how to use Moq to mock HttpContextBase and it’s members to make controller tests pass. You can use this code when you are not allowed to use open-source or use-on-your-own-risk pieces of software that provide you this kind on initialization using built-in features. Also it is good exercise that introduces you how to solve mocking problems.

Read more

Importing issues from Jira to database using C#

I am evaluating hosted Jira Studio and it likes me more and more when I’m using it. As hosted service is not in our premises and contains important information about our work I was asked to find out if there’s a way how to read data from Jira Studio and save it to our local data store. In this posting I will show you a simple way how to read issues from Jira Studio and save them to database.

Read more