|
 Wednesday, February 28, 2007

Confluence Tree Surgeon

Mike Roberts over at ThoughWorks have a project to help with continuous integration.

The product is called "Tree Surgeon". Tree Surgeon solves the problem of how to set up a development tree.

"Tree Surgeon is a .NET development tree generator. Just give it the name of your project, and it will set up a development tree for you in seconds. More than that, your new tree has years worth of accumulated build engineering experience built right in."

What the product does is it allows you to specify a project name and the application will create a development tree for you (code generation). This tree includes a solution, the tools (NUnit, NCover, NAnt) and a build file and script to execute the build. It saves TONS of time when creating a new project and needing to add it to your build.

Example

Creating a new development tree:

This will generate this tree structure:

Inside of the "ExampleApplication Folder" we have the build and the go script. The "go" script compiles, runs NUnit and NCover. Its the workhorse of the system. Run this from the command line. If you want to see the results while in a command window, I'd advise editing the go.bat file and adding @pause at the end of the script so you can see the results before the window closes.

The solution for the project is located in the 'src' directory:

You can execute the go.bat file and it will complile, and run NUnit and NCover on your application.

The best part about this is that its all configurable. Edit the cs.vm files in the C:\Program Files\Tree Surgeon\Resources\Templates directory and you'll be able to affect the output of the code generation. Plus, its all open source, so you can get the code from the site.

This could help a lot of companies get up and running with a development tree in their source control.

*Note: Currently Tree Surgeon only exports C# files.

I'll be writing more about Source Control Management as time continues... stay tuned.

#    Comments [0] |
 Tuesday, February 27, 2007

Gemini 2.0.5 "The Redirect Loop"

Yesterday while performing some maintenance on our internal Gemini website I ran into an error where the default.aspx page would redirect to the main.aspx page and then the main.aspx page would redirect to the default.aspx page. This loop would continue until windows gave me the classic DNS error page. Looking at the log files I see that the Default.aspx page is issuing a 401 (unauthorized) and then main is issuing a 302 (Redirect). Others have had this problem as well (but with a previous version), but their fix didnt work for me.

I didnt make any changes to the configuration, we just made a dns adjustment. Once the error started occuring we rolled back the change in our dns in attempt to eliminate the error. *NOPE* Didnt work. The redirect loop still existed.

We tried everything from changing security settings, to adjusting config file, rebooting servers, flushing DNS, everything. Nothing worked. The thing is, prior to this errror, we never made any code changes or configuration changes.

Resolution

I'm still baffled by what happened, but how I ended up fixing it is by uninstalling the Gemini application *note: copy your .config file to your local machine before doing this. You'll want it later*. After uninstalling I reinstalled it, and then updated the config file with values that were from the old config file.

I fired up the app through the browser and it works.

Its one of the strangest things I've seen in awhile, but at least its fixed. But the worst part is that it took 4 hours with help from our network team to troubleshoot and when it came down to it, we just had to reinstall. Not the desired method, but still, its an internal app only used by 10 people (max) so it wasnt that big of a deal.

#    Comments [0] |
 Thursday, February 22, 2007

Namespace Aliasing - The using directive

You can easliy alias a namespace in .NET by doing the following:

using System;
using System.Text;
using myXml = System.Xml; // <-- myXml is the alias.

Then in the code you can reference it like this:

using System;
using System.Text;
using myXml = System.Xml;

namespace MetaDatdaGenerator
{
   class Program
   {
      static void Main(string[] args)
      {
         myXml.XmlDocument xmlDoc = new myXml.XmlDocument(); 
         // Do stuff
      }
   }
}

Uses

Perhaps you've named something with similar namespaces or you've encountered a product with a similar namespace. This will allow you to alias them in your projects.

Aliasing a class

You can also alias a class, to save on typing. Saved keystrokes = mo time. Mo time = mo money. Mo money = mo problems! Oh, wait, nevermind...anyway... here's the code.

using System;
using System.Text;
using myXml = System.Xml;
using myException = ExampleCompany.ExampleProduct.Common.Exception.SomeExceptionWithAReallyReallyLongName;

namespace ExampleCompany.ExampleProduct
{
   class Program
   {
      static void Main(string[] args)
      {
         if (args.Length == 0)
         {
            throw new myException("Please provide a parameter!"); 
         }
      }
   }
}

Conclusion

Though it may not be used often, I've found myself using it a couple times when I needed to resolve some names to save on typing as well as an instance where I had two classes with the same name.

MSDN link: The using directive.

   
#    Comments [0] |
 Wednesday, February 21, 2007

Google Maps on your Mobile

If you're like me, you visit new places quite often and you need to find your way around. Or, maybe you're just terrible with directions and you can't find your way out of a wet paper bag, either way, its Google to the rescue.

For awhile now Google has offered Google Maps for mobile devices.

I installed it on my Blackberrry 7105t. I swear to the gods that be, I use this thing DAILY.

Uses
Finding stores: "Target in Stamford, CT". BLAMMO! It finds it.

Directions: Get directions to and from a location.

Favorites: Store favorite locations, such as home, work, the wife's office, etc. This saves a TON of typing on a handheld.

How to get it

Go to www.google.com/gmm on your mobile phone.

Supported Devices:

  • Most Java-enabled (J2ME) mobile phones.
  • Palm devices with Palm OS 5 and above.
  • All color BlackBerry devices.
  • Windows Mobile devices with Windows Mobile 2003, 5.0 and above.

I've seen it installed on Razr's as well as a few Sprint phones (not sure what models) that have internet access.

Once you get this bad-boy installed, you'll never be lost.

#    Comments [0] |
 Tuesday, February 20, 2007

Updated: Formatted XML From SQL

In my previous post I showed you how to return XML from the SQL Server Database. To further this topic, you can also format your XML to use Xml elements. This time, we're going to take a list of Customers and view their orders along with some information from the order, thats right, its straight from MSDN (with a couple tweaks).

This SQL Query will return Xml formatted as formatted elements.

USE AdventureWorks;
GO

SELECT TOP 10
     Customer.CustomerID,
OrderHeader.CustomerID,
OrderHeader.SalesOrderID,
OrderHeader.Status,
Customer.CustomerType
FROM Sales.Customer Customer, Sales.SalesOrderHeader OrderHeader
WHERE Customer.CustomerID = OrderHeader.CustomerID
ORDER BY Customer.CustomerID
FOR XML AUTO, ELEMENTS, ROOT('Customers')

Returns:

<Customers>
   <Customer>
      <CustomerID>1</CustomerID>
      <CustomerType>S</CustomerType>
         <OrderHeader>
            <CustomerID>1</CustomerID>
            <SalesOrderID>43860</SalesOrderID>
            <Status>5</Status>
         </OrderHeader>
         <OrderHeader>
            <CustomerID>1</CustomerID>
            <SalesOrderID>44501</SalesOrderID>
            <Status>5</Status>
         </OrderHeader>
         <OrderHeader>
            <CustomerID>1</CustomerID>
            <SalesOrderID>45283</SalesOrderID>
            <Status>5</Status>
         </OrderHeader>
         <OrderHeader>
            <CustomerID>1</CustomerID>
            <SalesOrderID>46042</SalesOrderID>
            <Status>5</Status>
         </OrderHeader>
      </Customer>
      ...
<Customers>

 

Explanation

The XML AUTO mode tells SQL Server to return the data in a XML format. We have provided the Sales.Customer table an alias of "Customer". If I had not done this, the results would have printed each element as:

<Sales.Customer>...</Sales.Customer>

This is not desirable.

The ELEMENTS option tells SQL Server to return the data as Xml elements, not as attributes. Had we eliminated this from the query, our query would have returned this:

<Customers>
   <Customer CustomerID="1" CustomerType="S">
      <OrderHeader CustomerID="1" SalesOrderID="43860" Status="5" />
      <OrderHeader CustomerID="1" SalesOrderID="44501" Status="5" />
      ...
   ...
</Customers>

This can work, but this time I wanted to demostrate the ELEMENT option.

The ROOT('Customers') allows us to set a root Xml element named "Customers".

 

Conclusion

While this may not be the next best thing you've ever seen, its still cool and it can save you time in the long run. Possible uses might include a quick way to get data out of your system and into a XML format for a one time use. Or you could use it for your data access layer and have it return XML to the business layer that might be used in a web service.

Its been reported that working with large XML Docs in .NET can be memory intensive, so perhaps this might help in processing and in saving memory on that server thats running on an old desktop that your boss had laying around. (We've all worked at a company who had a 'server' which was nothing more than a beefy desktop sitting in the server room.) :)

kick it on DotNetKicks.com

#    Comments [0] |