Пример #1
0
            private SessionManager()
            {
                var configuration = new NHibernate.Cfg.Configuration();

                configuration.AddAssembly(Assembly.GetCallingAssembly());
                IDictionary <string, string> properties = new Dictionary <string, string>();

                properties[NHibernate.Cfg.Environment.ConnectionString] = ApplicationConfiguration.DBConnectionString(ApplicationConfiguration.DBType.Swdb);
                properties.Add(NHibernate.Cfg.Environment.ConnectionDriver, HibernateUtil.HibernateDriverName(ApplicationConfiguration.DBType.Swdb));
                properties.Add(NHibernate.Cfg.Environment.Dialect, HibernateUtil.HibernateDialect(ApplicationConfiguration.DBType.Swdb));
                properties.Add(NHibernate.Cfg.Environment.ShowSql, "false");
                properties.Add(NHibernate.Cfg.Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
                properties.Add(NHibernate.Cfg.Environment.ProxyFactoryFactoryClass, "NHibernate.Bytecode.DefaultProxyFactoryFactory, NHibernate");
                properties.Add(NHibernate.Cfg.Environment.CurrentSessionContextClass, "managed_web");



                configuration.SetProperties(properties);
                //TODO: make this modular
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(User)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(Role)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(RoleGroup)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(DataConstraint)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(UserProfile)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(UserCustomConstraint)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(UserCustomRole)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(Category)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(PropertyDefinition)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(PropertyValue)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(Condition)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(WhereClauseCondition)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(PersonGroup)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(PersonGroupAssociation)));

                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(AuditTrail)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(ISMAuditTrail)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(ExtraAttributes)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(HistWorkorder)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(HistTicket)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(R0042AssetHistory)));
                configuration.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(typeof(CiSpecMapping)));

                _sessionFactory = configuration.BuildSessionFactory();
            }
Пример #2
0
            private SessionManager()
            {
                var configuration = new NHibernate.Cfg.Configuration();
                //Create a dictionary to hold the properties
                IDictionary <string, string> properties = new Dictionary <string, string>();

                //Populate with some default properties
                properties.Add(NHibernate.Cfg.Environment.ConnectionDriver, HibernateUtil.HibernateDriverName(ApplicationConfiguration.DBType.Maximo));
                properties.Add(NHibernate.Cfg.Environment.Dialect, HibernateUtil.HibernateDialect(ApplicationConfiguration.DBType.Maximo));
                properties.Add(NHibernate.Cfg.Environment.ShowSql, "false");
                properties.Add(NHibernate.Cfg.Environment.ConnectionProvider, "NHibernate.Connection.DriverConnectionProvider");
                //                      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
                //      <property name="proxyfactory.factory_class">NHibernate.Bytecode.DefaultProxyFactoryFactory, NHibernate</property>
                //      <property name="current_session_context_class">managed_web</property>

                //Add the connection and default schema
                properties[NHibernate.Cfg.Environment.ConnectionString] =
                    ApplicationConfiguration.DBConnectionString(ApplicationConfiguration.DBType.Maximo);
                //                properties[NHibernate.Cfg.Environment.DefaultSchema] = defaultSchema;
                configuration.SetProperties(properties);

                _sessionFactory = configuration.BuildSessionFactory();
            }