Skip to content

Instantly share code, notes, and snippets.

@orjan
Created October 20, 2009 20:17
Show Gist options
  • Save orjan/214575 to your computer and use it in GitHub Desktop.
Save orjan/214575 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using Hornalen.Data.NHibernateMaps;
using Hornalen.Migration.Process;
using log4net;
using log4net.Config;
using Rhino.Etl.Core;
using SharpArch.Data.NHibernate;
namespace Hornalen.Migration
{
internal class Program
{
private static SimpleSessionStorage storage;
private readonly ILog log = LogManager.GetLogger(typeof (Program));
protected void InitializeNHibernate()
{
NHibernateInitializer.Instance().InitializeNHibernateOnce(
() => InitializeNHibernateSession());
}
private static void InitializeNHibernateSession()
{
storage = new SimpleSessionStorage();
NHibernateSession.Init(
storage,
new[] {"Hornalen.Data.dll"},
new AutoPersistenceModelGenerator().Generate(),
"d:\\net\\projects\\Hornalen\\app\\Hornalen.Web\\NHibernate.config");
}
private static void Main()
{
var log4NetConfig = new FileInfo("verbose.log4net.config");
if (log4NetConfig.Exists)
XmlConfigurator.Configure(log4NetConfig);
var program = new Program();
program.InitializeNHibernate();
program.Run();
Console.ReadLine();
}
private void Run()
{
var import = new ImportMessages();
import.Execute();
foreach (Exception error in import.GetAllErrors())
{
log.Debug(error);
log.Error(error.Message);
Console.WriteLine(error);
}
}
}
public class ImportMessages : EtlProcess
{
protected override void Initialize()
{
Register(new ReadMessagesFromLegacyDb());
Register(new SaveMessagesToDB());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment