Subversion, TeamCity and Trac

A while back aftermoving house, I thought it time to revisit our source control and Continuous Integration setup. We had been using CSV, CruiseControl and Bugzilla for the best part of about 10 years without any major issues, but we guessed you can’t improve yourselves if you don’t try new things, so here we are!

After much searching we plumped for the combination of Subversion, Jet Brains’ TeamCity and The Trac Project. First off the installation of each was quite a breeze compared to when we did this 10 years ago. Yes things have moved on, improved, Google etc… but it was nice for installations to go without a hitch. Having said that a few sites did help along the way.

For installing and setting up Subversion, we found this site extremely useful. Also, for any out there new to Subversion or indeed source control, this site here is a good resource

TeamCity (continuous integration), well there isn’t too much to say other than simple! We’ve been using ReSharper since about 2004 and have always loved it and once again Jet Brains have delivered.

Trac is a wiki and issue tracking system and as with the others, this was simple to setup and use.

Administrator User missing from Logon Screen

Just a quick one here!

A project that I am working on in Australia has numerous computers that auto-logon and I needed to logon as Administrator to sort some stuff out.

Now, these computers were all running XP but there isn’t an option to select the Administrator user at Logon!

Easy… just press Ctrl and Alt then press Del twice. Up pops the normal Windows logon screen where you simply change the user to Administrator :)

Database diagram support objects cannot be installed

Have you every received this message when you try to access Database Diagrams for SQL Server?

If so, there is a simple fix. You need to change to ownership of the database to a valid user on the computer that you are using like so:

EXEC sp_dbcmptlevel ‘<database-name>’, ’90’
go
ALTER AUTHORIZATION ON DATABASE::<database-name> TO “<valid-domain-and-user>”
go
use <database-name>
go
EXECUTE AS USER = N’dbo’ REVERT
go

Replace the text <database-name> with the name of the database that you can’t access the database diagrams for and also replace the text <valid-domain-and-user> with a valid entry such as: RUSS-LAPTOP\Russ.

This worked a treat for me and hopefully it will for you too. If it doesn’t then you can also try the following to check the compatibility level and the db owner

1. Right Click on your database, choose Properties
2. Goto the Options Page
3. In the Dropdown at right labeled “Compatibility Level” choose “SQL Server 2005(90)”
4. Goto the Files Page
5. Enter “sa” in the owner textbox
6. Press OK and retry

ALTER LOGIN fix for SQL Server logon problems

We’ve all done it. Changed our default database for our logon to a database in SQL Server other than master, then either detached or deleted the database some way down the line. Of course at this point your pretty much screwed as you can’t access much as your login no longer works.

To fix this when you open Management Studio press the Options button and change the Connect to Database option to master. Now, this doesn’t fix the problem, it merely allows you to then open up a New Query. In the query enter the following SQL, change the login name and execute it.

ALTER LOGIN TestLogin WITH DEFAULT_DATABASE = master

Change TestLogin for your own login, close Management Studio and re-open it, press the Options button and change the Connect to Database option back to <default>.

At this point you should be able to get back into SQL Server with the usual authority and you can now re-attach your database.

WinForms Screen Capture

For a recent project we’ve been working on we needed to get a screen shot of a form and it’s contents. After much checking on the net for some sample code, all of which used GDI32 and User32 calls, we gave up looking and decided to investigate ourselves.

In the end it was so simple and clean that we just can’t believe that this isn’t documented that well anywhere on the web. The code below is an extract of our code that takes the forms position on the screen, creates a bitmap of the contents of the screen from co-ordinates passed to it and then saves the resultant screen shot to a file

using (Bitmap bitmap = new Bitmap(ParentForm.Size.Width, ParentForm.Size.Height))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(ParentForm.DesktopLocation.X, ParentForm.DesktopLocation.Y), new Point(0, 0), ParentForm.Size);
}

bitmap.Save(@”C:\test.jpg”, ImageFormat.Jpeg);
}

Enjoy :)

Tagged

Ajax comes to EmigratingToOz.com

The goal of the EmigratingToOz.com website is to be the oracle of information about Australia for us UK poms and to help them in the emigrating process. To that end, one of the things we needed to do was also supply real-time information about Australia from the point of view of weather, money and time.

Initially, the website was set up to actively get this information from a variety of sources and simply display on the page via the master page. However, the weather information in particular, comes from a slowish website that was killing the inital load time of the site.

The solution was simply to implement Ajax calls to get the information required in an asynchronous manner. Using the generic library that we created to demostrate Ajax calls on our main website, we were able to implement the calls for all of the data in one quick afternoon. The result is a quicker and more pleasing experience.

Showing a Windows form full screen

Ok…. quite simple you might think! And yes it is, but only if you know how!

For a small project that we are working on at the moment we needed to show a Windows Form in full screen mode without the taskbar etc… It is quite simple in the end but needs a couple of Win32Api calls, but that is simple enough. The one thing that is easy to forget is that you need to set the FormBorderStyle property for the form to None, otherwise you will still have the menu bar showing.

To acheive the full screen mode create a simple class with the code below in it

[DllImport(“user32.dll”, EntryPoint = “GetSystemMetrics”)]
public static extern int GetSystemMetrics(int which);

[DllImport(“user32.dll”)]
public static extern void SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int X, int Y, int width, int height, uint flags);

private const int SM_CXSCREEN = 0;
private const int SM_CYSCREEN = 1;
private static IntPtr HWND_TOP = IntPtr.Zero;
private const int SWP_SHOWWINDOW = 64;

public static int ScreenX
{
get { return GetSystemMetrics(SM_CXSCREEN); }
}

public static int ScreenY
{
get { return GetSystemMetrics(SM_CYSCREEN); }
}

public static void SetWindowFullScreen(IntPtr hwnd)
{
SetWindowPos(hwnd, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW);
}

Then in your application simply create a new instance of the form and call the Show method on the form.

Form form1 = new Form();
form1 .Show(this);

Then finally create an OnLoad handler for the form and call the SetWindowFullScreen method on our helper class and that is it.

WinApi.SetWindowFullScreen(Handle);

Tagged

New CodeConsults website – Emigrating To Oz

We’ve recently started a new project website called¬†Emigrating To Oz

Its a site centering around providing a resource of information for people wishing to emigrate to Australia, but its still in its infancy and we are targetting a Q2 2008 release with all the bells and whistles, but in the meantime the site is live so that we can begin getting it indexed and tested.

There’s plenty of work to do and content to add and we’re hoping that in time it will become an excellent resource for us Poms who are looking at possible life Down Under.

This application has failed to start because the application configuration is incorrect

C++ installations have never been easy and probably never will be. Having not done any C++ release work for a number of years I ran into a problem when releasing a C++ application that I built using Visual Studio 2005.

In the old days you had a nightmare working out which version of the C++ libraries to distribute and where to put them. Unless of course you statically link to the libraries which resolves the problem but makes the files rather larger.

But now with building the application using VS 2005, there is this new problem that arises which results in the obsure message

This application has failed to start because the application configuration is incorrect

After a bit of digging into all of this I found that there is a redistributable package from Microsoft that installs the necessary libraries for C++ that were used by VS2005 to build the application in the first place. Where it puts the libraries I don’t know, but to be honest I don’t really care as the installation was very simple and worked first time….so i’m happy for now.

Heres a link to the redistributable package from Microsoft. ¬†This is the SP1 version of the package which is required if your VS2005 installation is all up-to-date. If it isn’t there is an older version of the package available from Microsoft, or your could do the right thing and get VS2005 up-to-date instead.

Tagged

A neater way of getting data out of a DbDataReader

Previously I have always done the following to iterate through a bDataReader

while(reader.Read())
{
int index = reader.GetOrdinal(“User_Description”);
list.Add(reader[index] as string);
}
But today I stumbled upon the following which is so much neater:

foreach (DbDataRecord dbDataRecord in reader)
{
int index = dbDataRecord.GetOrdinal(“User_Description”);
list.Add(dbDataRecord[index] as string);
}

I just think it’s a lot neater and clearer as to what’s going on.

Tagged