Redmine: a trick to import data from Mantis

Today I decided to give Redmine a try as my new project management and bug tracking solution, mainly cause I wanted to try its integration with Subversion (given the fact that setting up an integration between Mantis and Subversion is a really painful).

To make things short I installed the Bitnami Remine Stack, then I started to face the problem of how to import the data I had in Mantis, the official documentation for the full migration can be read here.

I tried to follow it but it didn’t worked for me at start, I had to do some more things in order to make it work:

  1. Navigate to your installation folder, in my case “C:\Program Files\BitNami Redmine Stack” and use “use_redmine.bat” to open the command prompt
  2. inside the command prompt navigate to “C:\Program Files\BitNami Redmine Stack\apps\redmine” you have to launch the import script from there for it to work correctly.
  3. Before launching the script you have to figure out your “environment”, for a default Bitnami istallation it is set to “production”.
    If you set up the Redmine installation by yourself you already have this data available. Otherwise you can check your available environments looking at this folder: “C:\Program Files\BitNami Redmine Stack\apps\redmine\config\environments”, you can have different environment there, but only one is valid, that is: it has a database associated with it. To identify it you can open the database configuration file: “C:\Program Files\BitNami Redmine Stack\apps\redmine\config\database.yml” and for each environment you can see the related database.
    Now you just have to look in the mysql database folder “C:\Program Files\BitNami Redmine Stack\mysql\data” and you’ll see the valid database defined (in my case bitnami_remine, which corresponded to the production environment).
  4. Here’s the tricky part! Before launching the script you have to find a way to reach you current Mantis database, setting up remote access to a MySql database involves several steps; and even if you do so sometimes the importation script fails anyway to connect to the database; it took me a couple of hours of tries before finding this simple workaround: copy the whole mantis database folder from mantis’ MySql\Data to Redmine’s MySql data folder.
    In this way you are ‘mounting’ a mirror of the mantis database inside the redmine mysql instance.
    Be careful: you only have to copy the single database folder (usually called mantis), leave all the other system folders as they are.
  5. You can now launch the script as it’s stated in the documentation:
    rake redmine:migrate_from_mantis RAILS_ENV="production"

Castle Windsor WCF Services Resolution Facility

I have to admit I am not a huge fan of the automatic proxy generated code that you can obtain with svcutil.exe or using a standard Visual Studio service reference; mainly because it’s bloated with a lot of unneeded code, especially if you develop the service AND the clients that will use it (don’t get me wrong, the generated code is very useful if you do not have full control over the service or you are using a 3rd party WCF service).

Let’s put us in the good case in which we develop the service and the consumer and we have full control over the assemblies that defines the contract of the service and the classes that will be used to exchange data.

Some friends of mine (Andrea Balducci and Gian Maria Ricci) already showed you a simple technique to use Castle Windsor to host a WCF service), let’s now complete the picture and see how you can use the IoC container to generate a proxy on the client to consume those services.

But first of all you have to keep in mind that all you need to use a WCF is just an interface that matches the one exposed by the service (and eventually that extends it with asynchronous methods) and a set of classes used to exchange data (if the service itself does not expose only basic types).

Let’s consider we have a test WCF service with a contract like this:

[ServiceContract]

NHibernate/SqlServer: persist a generic ‘serializable’ object to an XML field

Recently we had the problem of persisting some sort of extended data attached to a business object with the schema and the data of these extended information that can vary over time (usually with an additive strategy). Since we do not need to do extensive or complex analysis queries on these data (they are almost all there for a ‘cosmetic’ fashion) the first thing that came into my mind instead of creating another mapping to a liked table was to use an XML field.

Plus the data that can be stored in this data extension field can be totally different from object to object.

If you know the Type of the object that represent the data to save my good friend Alkamfer already have an elegant solution: Use Xml field in SqlServer with nhibernate.

The first step is to find an efficient way to serialize/deserialize objects to our XML format, I made some tests on the standards .net serializers and it came out that the new DataContractSerializer is quite fast compare to the old XmlSerializer, so I decided to give it a try.

Serializing an object is not a real problem, the deserialization step is a little more problematic, mainly because we need to know the type of the object we want to deserialize. but since we want to deserialize some data coming out from a single XML field in a database we do not have this information available...untill we find a way to embed it inside the XML serialized stream.

So the first step was to write a couple of simple functions to serialize a class to an XML stream embedding the type of the serialized item in the outmost tag. This is quite simple to do using the DataContractSerializer functions: WriteStartObject(), WriteObjectContent() and WriteEndObject().

Here’s the code for the serialization helpers, the Type attribute is embedded in a custom attribute called serType:

public static class DataContractSerializerHelpers

Silverlight/WPF UIElement: how to find and ancestor of type procedurally

Suppose you have the following scenario you have two templated UserControl:

  • UCContainer - is a graphical container for other controls, it can be used to contain different kinds of controls, it can be skinned using a template that will be changed by the user/graphic designer. You cannot do any assumptions on the template.
  • UCDetail - is a detail control contained in a UCContainer.

Given an instance of UCDetail, we want to access and modify property of the UCContainer that contains it. if You are lucky the Parent property or the VisualTreeHelper.GetParent() function can give you a reference to the UCContainer control itself. But more often they will give you a reference to a container control defined inside the UCContainer template (usually a StackPanel or a Grid).

I’m not willing to go deep into concepts like the WPF Visual and Logical tree, you have tons of resources and books to look at for that.

The only viable way I’ve found so far to get the ‘logical’ parent of the control is to use a recursion and look if the type of the parent object returned by and UIElement matches the type of the object that I consider his ‘logical’ parent, Here’s the code that does the trick:

public static partial class Extensions

ASP.NET Routing and DataBinding

On a project I’m currently working on the new ASP.NET Routing was used to realize a navigation system for the website but also to present the Urls in a way that is friendly to the search engines’ analysis tools in order to improve indexing a bit.

In this article I’m going to describe what ASP.NET Routing is, there are already a plethora of good resources available on the web, I will show you a flexible way to retrieve parameters from the Url that is associated to a particular request.

We suppose to have the usual Person class that defines an object in our database:

public class Person

Internet Explorer 8 causes troubles to Vista and TestDriven.Net (‘test with...debugger’ not working)

Two days ago I installed Internet Explorer 8 and I have to admit I was quite satisfied by its performance... it seemed more responsive and with faster load times compared to Ie7.

However today I started to experience the first problems...in Windows Vista (I have an Italian version of the operating system) I noticed that each time I opened a new folder on the file system, it would open in a new window, totally ignoring the option to open it in the same window (I’ve double checked both the option and the registry keys to make sure the settings were correct).

The second strange thing was the fact that TestDriven.Net option ‘Test with...debugger’ stopped working. I’ve spent 2 hours messing with the registry keys and similar trying to figure out the problem without success.

The last option I had was to check for whatever I’ve installed in the last days and guess what? After removing Ie8 and restarting everything started to work again.

To uninstall Internet Explorer 8, go to Control Panel, and click on Uninstall Programs link or Programs and Features icon. Then on Tasks pane on the left, click on View installed updates link. Locate and select Windows Internet Explorer 8.

I’ll install it again (in a virtual machine this time) and try to investigate the problem more when I have time.

Update:

I tried to install it again to see if some updates solved the issue, but once again I had no luck. I decided to spent some time again looking for a solution and I saw that many guys around had the same issue and resolved it just launching IE8 with Administrative privileges. It obviously did not work for me :).

Then I found some posts of people that propose registry hacks, I tried them with no luck until I found this post on eggheadcafe: http://www.eggheadcafe.com/conversation.aspx?messageid=34297087&threadid=32958968

*  open a new "Command Prompt" window by right-clicking and selecting "Run
as administrator";
*  at the prompt, run the command "regsvr32 actxprxy.dll".