Using NodeJS and FTP with Promises

I've played with node in the past but as of the new year I decided to try and make a more concerted effort to get stuck into node properly. I decided to go back to the beginning to try and get a better appreciation for the language so read "JavaScript: The Good Parts by Douglas Crockford". I found that exercise fulfilling and resulted in a few light bulb moments that made some dots join up so I'd recommend reading it if you haven't already.

Real World App

As I stated earlier I have already played with node in the past using Express and have read quite a bit on node and read many examples but I wanted to write a non-web app as I felt this would give me a better opportunity to get to grips with the language and Node. Using Express allows you to get up and running very quickly without to much head scratching so I felt a standalone script would give me more exposure to things.

Read more...

Unit Testing with SqlException

So after a nice Christmas break I get to some code that needs some unit testing around a try/catch. Something similar to this:

try
{
    myService.DoSomethingThatMightTakeALongTime();
}
catch (EntityCommandExecutionException ex)
{
    var exception = ex.InnerException as SqlException;
    if (exception != null)
    {
        if (exception.Number == -2)
        {
            //Do something special
        }
    }
}

Read more...

Using SQL Server with node.js

I like to keep eyes and ears open for new technologies and methodologies in order to become a better developer and I'd heard about edge.js many months ago but made a mental note of it and waved it goodbye. edge.js lets you have two-way communication between node and C# libraries. When I first looked at it I thought that sounded a bit hacky, I've spent my time communicating with COM libraries in Delphi and OCX libraries with C# and didn't like it so I felt this was pretty much the same thing. A long time passed and I was writing a console based Windows app as a service and had wondererd whether I could quickly port it to node.

I was discussing with a colleague about using node at work and that we needed something seperate and small just to try it out and see how the whole developement process with it worked. As the database that this app needed to communicate with was MSSQL I looked into a library on NPM that would communicate with MSSQL and maybe act as an ORM. There was a Microsoft lib that seemed untouched and reading the comments on the issues list on Github it didnt favour too well. There were libraries that would communicate with MySQL & PostgresSQL but not MSSQL. In my search I came across edge.js again. It had 2 samples, one that used edge-sql and one that used ScriptCS so in laymans terms, one that used a precompiled dll and one that used a C# script that was executed at runtime.

Read more...

Octopus XML Transformation in Services

We use Octopus Deploy at work and its a superb tool for deploying your applications whether they be websites or *.exes.

One of the great things it also provides is the ability to use Microsoft's Transformation process for config files. However, when deploying a exe application its a bit trickier than a website. Unfortunately the documentation doesn't mention the steps needed to get this working so read on!

Typically a web application will have web.config and a web.Release.config as well as other derivations you may use. Octopus also supports web.[Environment].config.

Read more...

Using Git to update YouTrack via TeamCity

This post is mainly a reminder for me as I keep forgetting the command in Git to integrate commits to YouTrack items.

YouTrack uses TeamCity to get the information about the commits and then scans the commit comment for a YouTrack item id and any commands that it can apply such as item status or time spent on said item.

There is some documentation here but its not the greatest in terms of clarity and I've spoken to Hadi Hariri from JetBrains about improving this so hopefully they're working on it.

Anyhow here's some example Git commands to wire it all up

git commit -am "I fixed a massive bug #PROJ-158 Complete"
git commit -am "I fixed a massive bug #PROJ-158 Complete add work 1h"

The first command will update the status of YouTrack item #PROJ-158 to Complete. The second item will do the same but also add Time Tracking information to the item in YouTrack.

Hope that helps, Happy Coding!