public BusinessSafeSessionFactory()
        {
            var hibernateConfigFilePath = new NHibernateConfigPathGenerator(Database.BusinessSafe).GetConfigFilePath();
            Log4NetHelper.Logger.Debug("BusinessSafeSessionFactory() - NHibernate Configuration File path: " + hibernateConfigFilePath);

            var configuration = new Configuration();
            configuration.Configure(hibernateConfigFilePath);
            configuration.SetProperty(Environment.ConnectionStringName, "BusinessSafe");

            configuration.EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[]
                                                                        {
                                                                            new AuditUpdateListener()
                                                                        };
            configuration.EventListeners.PostInsertEventListeners = new IPostInsertEventListener[]
                                                                        {
                                                                            new AuditUpdateListener()
                                                                        };
            configuration.EventListeners.PostDeleteEventListeners = new IPostDeleteEventListener[]
                                                                        {
                                                                            new AuditUpdateListener()
                                                                        };
            configuration.EventListeners.PostCollectionUpdateEventListeners = new IPostCollectionUpdateEventListener[]
                                                                        {
                                                                            new AuditUpdateListener()
                                                                        };

            _sessionFactory = configuration.BuildSessionFactory();
        }
Example #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        private ISessionFactory GetSessionFactory(string connectionString)
        {
            var hibernateConfigFilePath = new NHibernateConfigPathGenerator(Database.BusinessSafe).GetConfigFilePath();

            var configuration = new Configuration();
            configuration.Configure(hibernateConfigFilePath);

            configuration.SetProperty(NHibernate.Cfg.Environment.ConnectionString, connectionString);

            configuration.EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[] {new AuditUpdateListener() };
            configuration.EventListeners.PostInsertEventListeners = new IPostInsertEventListener[] { new AuditUpdateListener() };
            configuration.EventListeners.PostDeleteEventListeners = new IPostDeleteEventListener[] { new AuditUpdateListener() };
            configuration.EventListeners.PostCollectionUpdateEventListeners = new IPostCollectionUpdateEventListener[] { new AuditUpdateListener() };
            return configuration.BuildSessionFactory();
        }