Created
October 20, 2009 20:17
-
-
Save orjan/214575 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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