Monthly Archives: June 2010

Community server to blogml code

I wrote some custom code to convert the community server blog entries to a blogml version so that I could import it into blogengine.net. I considered using the blogml assembly to create the code, but decided to hand-code it instead.

The way to use this is to create a blog, write one post, export it out (settings->export), and then hand-insert the categories and post sections into that exported file, then re-import it back. I decided to skip comments to make things easier.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.IO;

namespace blogconverter
{
    class Program
    {
        static SqlDataReader Execute(string query)
        {
            SqlCommand command = GetConnection().CreateCommand();
            command.CommandText = query;
            SqlDataReader reader = command.ExecuteReader();
            return reader;
        }

        static SqlConnection GetConnection()
        {
            SqlConnection connection =
                new SqlConnection(@"Data Source=HOMELAPTOP\SQLEXPRESS;Database=BCCommunityServer;Integrated Security=SSPI;");
            connection.Open();

            return connection;
        }

        static void Main(string[] args)
        {
            using (StreamWriter writer = File.CreateText(@"c:\data\website\posts.xml"))
            {
                string categories = GetCategories();

                string posts = GetPosts();

                writer.WriteLine(categories);
                writer.WriteLine(posts);
            }

        }

        static Dictionary _CategoryLookup = 
            new Dictionary();

        static string GetCategories()
        {
            StringBuilder b = new StringBuilder();
            b.Append("");
            SqlDataReader reader = Execute(QueryCategory);

            while (reader.Read())
            {
                int categoryId = (int) reader.GetValue(0);
                string name = (string) reader.GetValue(1);

                Guid id = Guid.NewGuid();

                _CategoryLookup.Add(categoryId, id);

                b.Append(String.Format(
                    @"
                       

Welcome 2.0

My hosting company, Webhost4life, has basically imploded – they have been upgrading all their user sites and apparently killing most of them in the process, so I’ve decided to switch to a different provider (the hard-to-pronounce arvixe.com), and I’ve also switched over from commumity server.com to blogengine.net to make thing simpler. I’m going to have to do some hand-work to get the old posts to show up.

I’ve also decided to merge together my two blogs, just to make things easier. I’m not sure yet what’s going to live on thegunnersons.com, as soon as I get the domain transferred over.

That’s my second lesson on this – park your domains on a domain company, not with your service provider. If you do that, it takes 5 minutes to make them point to a new set of servers. If one of your domains is registered by your service provider and they get in trouble, you have to work to get it back.