public void Setup() { _cfg = new Configuration(); _cfg.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider"); _cfg.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver"); _cfg.SetProperty("connection.connection_string", _connectionString); _cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect"); _cfg.SetProperty("default_schema", "bus"); _cfg.SetProperty("show_sql", "true"); _cfg.SetProperty("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"); _cfg.AddAssembly(typeof(NHibernateSagaRepository<>).Assembly); _cfg.AddAssembly(typeof(RegisterUserStateMachine).Assembly); _cfg.AddAssembly(typeof(When_using_the_saga_locator_with_NHibernate).Assembly); ISessionFactory _sessionFactory = _cfg.BuildSessionFactory(); LocalContext.Current.Store(_sessionFactory); NHibernateUnitOfWork.SetSessionProvider(() => LocalContext.Current.Retrieve<ISessionFactory>().OpenSession()); UnitOfWork.SetUnitOfWorkProvider(NHibernateUnitOfWork.Create); _sagaId = CombGuid.Generate(); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); Configuration configuration = new Configuration(); configuration.Configure (); configuration.SetProperty(NHibernate.Cfg.Environment.Hbm2ddlKeyWords, "none"); configuration.AddAssembly(typeof(Categoria).Assembly); configuration.AddAssembly(typeof(Articulo).Assembly); new SchemaExport(configuration).Execute(true, false, false); ISessionFactory sessionFactory = configuration.BuildSessionFactory (); //updateCategoria(sessionFactory); //insertCategoria(sessionFactory); //loadArticulo(sessionFactory); ISession session = sessionFactory.OpenSession(); ICriteria criteria = session.CreateCriteria (typeof(Articulo)); criteria.SetFetchMode("Categoria", FetchMode.Join); IList list = criteria.List(); foreach (Articulo articulo in list) Console.WriteLine("Articulo Id={0} Nombre={1} Precio={2} Categoria={3}", articulo.Id, articulo.Nombre, articulo.Precio, articulo.Categoria); session.Close(); sessionFactory.Close (); }
/// <summary> /// Generates the required schema in the project database /// </summary> public static void GenerateDatabaseSchema() { Configuration config = new Configuration(); config.Configure(); config.AddAssembly(typeof(PhoneNumber).Assembly); config.AddAssembly(typeof(Person).Assembly); SchemaExport exporter = new SchemaExport(config); exporter.Execute(false, true, false); }
static NHConfig() { var modelAssembly = typeof(Zza.Model.Customer).Assembly; var mappingAssembly = typeof(NHConfig).Assembly; // Configure NHibernate _configuration = new Configuration(); _configuration.Configure(); //configure from the app.config _configuration.AddAssembly(modelAssembly); _configuration.AddAssembly(mappingAssembly); _sessionFactory = _configuration.BuildSessionFactory(); }
public void Setup() { _cfg = new Configuration(); _cfg.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider"); _cfg.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver"); _cfg.SetProperty("connection.connection_string", _connectionString); _cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect"); _cfg.SetProperty("default_schema", "bus"); _cfg.AddAssembly(typeof (NHibernateSagaRepository<>).Assembly); _cfg.AddAssembly(typeof (RegisterUserStateMachine).Assembly); _cfg.AddAssembly(typeof (SagaRepository_Specs).Assembly); }
public static void NHibernateConfiguration(TestContext context) { log4net.Config.XmlConfigurator.Configure(); Configuration = new Configuration(); // lendo o arquivo hibernate.cfg.xml Configuration.Configure(); FilterDefinition filterDef = new FilterDefinition( "Empresa","EMPRESA = :EMPRESA", new Dictionary<string, IType>() {{"EMPRESA", NHibernateUtil.Int32}}, false); Configuration.AddFilterDefinition(filterDef); filterDef = new FilterDefinition( "Ativa", "ATIVO = 'Y'", new Dictionary<string, IType>(), false); Configuration.AddFilterDefinition(filterDef); // Mapeamento por código var mapper = new ModelMapper(); mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes()); HbmMapping mapping = mapper.CompileMappingForAllExplicitlyAddedEntities(); Configuration.AddMapping(mapping); // Gerar o XML a partir do mapeamento de codigo. //var mappingXMl = mapping.AsString(); // Mapeamento por arquivo, in resource. Configuration.AddAssembly(Assembly.GetExecutingAssembly()); // Gerando o SessionFactory SessionFactory = Configuration.BuildSessionFactory(); }
/// <summary> /// Adds mappings for this model to a NHibernate configuration object. /// </summary> /// <param name="configuration">A NHibernate configuration object to which to add mappings for this model.</param> public static void ApplyConfiguration(Configuration configuration) { configuration.AddXml(Libro.MappingXml.ToString()); configuration.AddXml(Resenha.MappingXml.ToString()); configuration.AddXml(Autor.MappingXml.ToString()); configuration.AddAssembly(typeof(ConfigurationHelper).Assembly); }
//�������ݿ� public static void CreateDataBase(string AssemblyName) { cfg = new Configuration(); cfg.AddAssembly(AssemblyName); SchemaExport sch = new SchemaExport(cfg); sch.Create(true, true); }
private static void Init() { nhConfiguration = new Configuration(); //nhConfiguration.Configure("NhibernateUtils/NHibernate.cfg.xml"); nhConfiguration.AddAssembly("Activos"); sessionFactory = nhConfiguration.BuildSessionFactory(); }
public static void TestClassSetup(TestContext context) { _configuration = new Configuration(); _configuration.Configure(); _configuration.AddAssembly(typeof(Draft).Assembly); _sessionFactory = _configuration.BuildSessionFactory(); }
static void Main(string[] args) { Console.WriteLine("Started publisher and inserting data."); Publisher.Start(); var config = new Configuration(); config.Configure("nh.sqlserver.config"); config.SessionFactoryName("Test session factory"); config.AddAssembly(typeof(Dog).Assembly); new SchemaUpdate(config).Execute(false, true); using(var sessionFactory = config.BuildSessionFactory()) { Stopwatch sw = new Stopwatch(); sw.Start(); InsertData(sessionFactory); Console.WriteLine("Inserting data with logging took: {0}", sw.Elapsed); sw.Restart(); Publisher.Shutdown(); Console.WriteLine("Publisher shutdown complete in {0}", sw.Elapsed); Console.WriteLine("inserting data with publisher shutdown"); sw.Restart(); InsertData(sessionFactory); Console.WriteLine("Inserting data without logging took: {0}", sw.Elapsed); } Console.ReadLine(); }
static NHibernateHelper() { Configuration configuration = new Configuration(); configuration.Configure(); configuration.AddAssembly(typeof(Manufacturer).Assembly); SessionFactory = configuration.BuildSessionFactory(); }
static DataAccessLayer() { _hibernateConfiguration = new Configuration(); Assembly thisAssembly = typeof (DataAccessLayer).Assembly; string thisAssemblyName = thisAssembly.GetName().Name; string exePath = AppDomain.CurrentDomain.BaseDirectory; string thisAssemblyPath = Path.GetDirectoryName(thisAssembly.Location); string configPath = Path.Combine(exePath, thisAssemblyName) + ".cfg.xml"; if (!File.Exists(configPath)) { Platform.Log(LogLevel.Debug, "NHibernate config file '{0}' does not exist; checking assembly location ...", configPath); configPath = Path.Combine(thisAssemblyPath, thisAssemblyName) + ".cfg.xml"; if (!File.Exists(configPath)) { string message = String.Format("NHibernate config file '{0}' does not exist; database cannot be initialized.", configPath); Platform.Log(LogLevel.Debug, message); throw new FileNotFoundException(message, configPath); } } _hibernateConfiguration.Configure(configPath); _hibernateConfiguration.AddAssembly(thisAssemblyName); _sessionFactory = _hibernateConfiguration.BuildSessionFactory(); }
/// <summary> /// Create a customer factory based on the configuration given in the configuration file /// </summary> public OrderDetailsFactory() { config = new Configuration(); config.AddAssembly("nhibernator"); factory = config.BuildSessionFactory(); session = factory.OpenSession(); }
protected static ISessionFactory CreateSessionFactory() { Configuration configuration = new Configuration(); configuration.Configure(); configuration.AddAssembly(typeof(CIServer).Assembly); return configuration.BuildSessionFactory(); }
private static void RunSample(int sampleToRun) { var cfg = new Configuration(); cfg.AddAssembly(typeof(Customer).Assembly); using (ISessionFactory factory = cfg.BuildSessionFactory()) { DatabaseCleaner.ClearDatabase(cfg, factory); switch (sampleToRun) { case 1: Save_Load_and_Delete_Example.Run(factory); break; case 2: Save_MTO_And_Lazy_Load_Example.Run(factory); break; case 3: CRUD_with_Collections.Run(factory); break; case 4: Querying_Examples.Run(factory); break; default: Console.WriteLine("Unknown sample {0}. Please try another", sampleToRun); break; } } }
private Configuration createConfiguration() { Configuration cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof(Mesto).Assembly); return cfg; }
public IList<INotification> GetAll() { // webbikäyttöön // App_Start.NHibernateProfilerBootstrapper.PreStart(); // konsolissa // NHibernateProfiler.Initialize(); IList<INotification> notifications; var cfg = new Configuration(); cfg.DataBaseIntegration(x => { x.ConnectionString = "Server=localhost;Database=NHibernateDemo;Integrated Security=SSPI;"; x.Driver<SqlClientDriver>(); x.Dialect<MsSql2008Dialect>(); //x.LogFormattedSql = true; //x.LogSqlInConsole = true; }); cfg.SessionFactory().GenerateStatistics(); cfg.AddAssembly(Assembly.Load("Domain")); var sessionFactory = cfg.BuildSessionFactory(); var session = sessionFactory.OpenSession(); var notificationsQueryable = from customer in session.Query<INotification>() //where customer.FirstName.Contains("e") orderby customer.FirstName select customer; notifications = notificationsQueryable.ToList(); return notifications; }
public global::NHibernate.Cfg.Configuration GetCfg(string[] addAssemblies) { SessionFactoryImpl sessionFactoryImpl = SpringHelper.ApplicationContext["NHibernateSessionFactory"] as SessionFactoryImpl; IDictionary springObjectDic = getSpringObjectPropertyValue("NHibernateSessionFactory", "HibernateProperties") as IDictionary; IDictionary<string, string> dic = new Dictionary<string, string>(); foreach (DictionaryEntry de in springObjectDic) { dic.Add(de.Key.ToString(), de.Value.ToString()); //if (de.Key.ToString().Equals("hibernate.dialect")) //{ // dialectName = de.Value.ToString(); //} } #region //真正抓取設定檔的內容 ISession session = sessionFactoryImpl.OpenSession(); string connectionStr = session.Connection.ConnectionString; #endregion dic.Add("connection.connection_string", connectionStr); Configuration cfg = new Configuration(); cfg.AddProperties(dic); foreach (string assembly in addAssemblies) { cfg.AddAssembly(assembly); } return cfg; }
public void TestFixtureSetUp() { _configuration = new Configuration(); _configuration.Configure(); _configuration.AddAssembly(typeof(Product).Assembly); _sessionFactory = _configuration.BuildSessionFactory(); }
private void button1_Click(object sender, EventArgs e) { var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof(Domain.User).Assembly); var sessions = cfg.BuildSessionFactory(); var sess = sessions.OpenSession(); var new_user = new Domain.User { Name = textBox1.Text, Surname = textBox2.Text, Patronymic = textBox3.Text, Role_id = 1, Login = textBox4.Text, Pass = textBox5.Text }; if (new_user.Name.Length > 0 && new_user.Surname.Length > 0 && new_user.Patronymic.Length > 0 && new_user.Login.Length > 0 && new_user.Pass.Length > 0) { sess.Save(new_user); sess.Flush(); this.Hide(); } else { label6.Text = "Не все поля заполнены!"; } }
public static Configuration InitConfiguration() { Configuration = new Configuration(); Configuration.Configure(@"Config\NHibernate.cfg.xml"); Configuration.AddAssembly("Org.Limingnihao.Application"); return Configuration; }
private void button3_Click(object sender, EventArgs e) { var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof(Domain.User).Assembly); var sessions = cfg.BuildSessionFactory(); var sess = sessions.OpenSession(); var login = textBox1.Text; IQuery q = sess.CreateQuery("FROM User u where u.Login=:login").SetParameter("login",login); var list = q.List<Domain.User>(); if (list.Count > 0 && list[0].Pass == textBox2.Text) { var role_id = list[0].Role_id; IQuery q_role = sess.CreateQuery("FROM Role u where u.Id=:role_id").SetParameter("role_id", role_id); var list_role = q_role.List<Domain.Role>(); if (list_role[0].Name.Equals("reader")) { LibraryForm lib_form = new LibraryForm(list[0]); lib_form.ShowDialog(); } else { AdminForm admin_form = new AdminForm(); admin_form.ShowDialog(); } } else { MessageBox.Show("Неверный логин или пароль"); } }
/// <summary> /// Constructor /// </summary> /// <param name="assemblyNames">The names of the assemblies containing object-relational mapping information</param> /// <exception cref="Exception">Thrown if an error occurred while constructing the factory</exception> public ReaderFactory(IEnumerable<string> assemblyNames) { Exception exception = null; // If SessionFactory build fails then retry for (int tryNumber = 1; tryNumber <= 3; tryNumber++) { try { Configuration config = new Configuration(); // Add assemblies containing mapping definitions foreach (string assemblyName in assemblyNames) { config.AddAssembly(assemblyName); } config.Configure(); sessionFactory = config.BuildSessionFactory(); // SessionFactory built successfully exception = null; break; } catch (Exception ex) { exception = ex; } } if (exception != null) { throw new FingertipsException("Could not construct ReaderFactory instance", exception); } }
public void Gerar_schema() { var cgc = new Configuration(); cgc.Configure(); cgc.AddAssembly("Comercio.Mapeamento"); new SchemaExport(cgc).Execute(false, true, false); }
/// <summary> /// Wrapper class to produce an Ado.Net Datatable from any entity, /// and perform SqlBulkCopy operations /// </summary> public SqlEntityBulkCopy(string sqlCnnString, Type entityType) { if (Cfg == null) { //Note: The NHibernate.Cfg.Configuration is meant only as an initialization-time object. //Note: NHibernate.ISessionFactory is immutable and does not retain any association back to the Session Cfg = new Configuration(); //Cfg.SetProperty("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"); Cfg.SetProperty("dialect", "NHibernate.Dialect.MsSql2008Dialect"); Cfg.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider"); Cfg.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver"); Cfg.SetProperty("connection.connection_string", sqlCnnString); //add all the mappings embedded in this assembly Cfg.AddAssembly(typeof(SqlEntityBulkCopy).Assembly); var sessionFactory = Cfg.BuildSessionFactory(); SessionFactoryImpl = (ISessionFactoryImplementor)sessionFactory; } EntityType = entityType; //_session = SessionFactoryImpl.OpenSession(); _metaData = SessionFactoryImpl.GetClassMetadata(EntityType); _persistentClass = Cfg.GetClassMapping(EntityType); _sqlCnn = new SqlConnection(sqlCnnString); _sqlBulkCopy = new SqlBulkCopy(_sqlCnn); //Debug.WriteLine("EntityName = " + _metaData.EntityName); //Debug.WriteLine("IdentifierPropertyName = " + _metaData.IdentifierPropertyName); //Debug.WriteLine("IdentifierType = " + _metaData.IdentifierType); BuildDataTable(); BuildAndMapSqlBulkCopy(); }
public void generate() { var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof(Question).Assembly); new SchemaExport(cfg).Execute(false, true, false); }
private static void Init() { var config = new Configuration(); config.Configure(); config.AddAssembly(Assembly.GetCallingAssembly()); _sessionFactory = config.BuildSessionFactory(); }
private SessionManager() { var configuration = new Configuration(); configuration.Configure(); configuration.AddAssembly(typeof(Equipment).Assembly); _sessionFactory = configuration.BuildSessionFactory(); }
public static Configuration RecuperaConfiguracao() { Configuration cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(Assembly.GetExecutingAssembly()); return cfg; }
/// <summary>Adds default assemblies to NHibernate configuration.</summary> /// <param name="cfg"></param> protected virtual void AddAssemblies(NHibernate.Cfg.Configuration cfg) { foreach (Assembly a in Assemblies) { cfg.AddAssembly(a); } Debug.WriteLine(String.Format("Added {0} assemblies to configuration", Assemblies.Count)); }
static BaseTestFixture() { _config = new NHibernate.Cfg.Configuration(); _config.AddAssembly("DomainObjects"); if (_sessionFactory == null) { _sessionFactory = _config.BuildSessionFactory(); } }
public static ISessionFactory GetSessionFactory() { var configuration = new NHibernate.Cfg.Configuration(); configuration.Configure(); configuration.AddAssembly(typeof(SessionFactoryFactory).Assembly.GetName().Name); log4net.Config.XmlConfigurator.Configure(); var sessionFactory = configuration.BuildSessionFactory(); return(sessionFactory); }
public SQLiteDBFactory() { var cfg = new NHibernate.Cfg.Configuration(); cfg.Properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider"); cfg.Properties.Add("connection.driver_class", "NHibernate.Driver.SQLite20Driver"); cfg.Properties.Add("dialect", "NHibernate.Dialect.SQLiteDialect"); cfg.Properties.Add("connection.connection_string", GetConnectionString()); cfg.AddAssembly("AuditLogDB"); _sf = cfg.BuildSessionFactory(); }
private static void CreateConfiguration() { _config = new NHibernate.Cfg.Configuration(); if (_config.Properties["hibernate.dialect"] == null) { _config.Properties.Add("hibernate.dialect", "NHibernate.Dialect.MsSql2005Dialect"); } if (_config.Properties["hibernate.connection.provider"] == null) { _config.Properties.Add("hibernate.connection.provider", "NHibernate.Connection.DriverConnectionProvider"); } if (_config.Properties["hibernate.connection.driver_class"] == null) { _config.Properties.Add("hibernate.connection.driver_class", "NHibernate.Driver.SqlClientDriver"); } if (_config.Properties["hibernate.connection.connection_string"] == null) { _config.Properties.Add("hibernate.connection.connection_string", "Server=localhost;initial catalog=SnCore;Integrated Security=SSPI"); } _config.AddAssembly("SnCore.Data"); _config.AddAssembly("SnCore.Data.Hibernate"); }
public static ISessionFactory CreateSessionFactory() { Configuration config; ISessionFactory factory; HttpContext currentContext = HttpContext.Current; cAppConfig oApp; Utility oUtil = new Utility(); config = new NHibernate.Cfg.Configuration(); if (HttpContext.Current == null) { oApp = new cAppConfig(ConfigFileType.AppConfig); config.SetProperty("hibernate.connection.connection_string", oApp.GetValue("hibernate.connection.connection_string")); } else { oApp = new cAppConfig(ConfigFileType.WebConfig); // string strDesEnc = oUtil.Decrypt(oApp.GetValue("hibernate.connection.connection_string")); config.SetProperty("hibernate.connection.connection_string", oApp.GetValue("hibernate.connection.connection_string")); } if (config == null) { throw new InvalidOperationException("NHibernate configuration is null."); } if (HttpContext.Current == null) { config.SetProperty("hibernate.connection.connection_string", oApp.GetValue("hibernate.connection.connection_string")); } config.AddAssembly("Business"); factory = config.BuildSessionFactory(); if (currentContext != null) { currentContext.Items[KEY_NHIBERNATE_FACTORY] = factory; } if (factory == null) { throw new InvalidOperationException("Call to Configuration.BuildSessionFactory() returned null."); } else { return(factory); } }
public static ISessionFactory GetSessionFactory() { var configuration = new NHibernate.Cfg.Configuration(); configuration.Configure(); configuration.AddAssembly(typeof(SessionFactoryFactory).Assembly.GetName().Name); configuration.SetProperty(Environment.ConnectionString, ConfigurationManager.ConnectionStrings["ProjectTemplate"].ConnectionString); log4net.Config.XmlConfigurator.Configure(); var sessionFactory = configuration.BuildSessionFactory(); return(sessionFactory); }
static TestSessionContext() { if (null == Context.SessionFactory) { try { NHibernate.Cfg.Configuration hibernateConfig = new NHibernate.Cfg.Configuration().Configure(); hibernateConfig.AddAssembly("SurveyORM"); Context.SessionFactory = hibernateConfig.BuildSessionFactory(); } catch (Exception exc) { throw exc; } } }
public static CoreNHibernate.ISessionFactory CreateSessionFactoryFromXML(string assemblyPath) { CoreNHibernate.Cfg.Configuration config = new CoreNHibernate.Cfg.Configuration(); config.Configure(); //config.AddFile(@"D:\Bilisim\SVN\bilisimHR\Web\trunk\bilisimHR.DataLayer.NHibernate.Tests\bin\x64\Debug\Mappings\HBM\Roles.hbm.xml"); //config.AddFile(@"D:\Bilisim\SVN\bilisimHR\Web\trunk\bilisimHR.DataLayer.NHibernate.Tests\bin\x64\Debug\Mappings\HBM\Users.hbm.xml"); //config.AddFile(@"D:\Bilisim\SVN\bilisimHR\Web\trunk\bilisimHR.DataLayer.NHibernate.Tests\bin\x64\Debug\Mappings\HBM\Category.hbm.xml"); //config.AddFile(@"D:\Bilisim\SVN\bilisimHR\Web\trunk\bilisimHR.DataLayer.NHibernate.Tests\bin\x64\Debug\Mappings\HBM\Item.hbm.xml"); config.AddAssembly("bilisimHR.DataLayer.Core"); //..Todo..... new SchemaExport(config).Execute(true, false, false); //new SchemaUpdate(config).Execute(false, true); return(config.BuildSessionFactory()); }
private void InitSessionFactory() { Cfg.Configuration cfg = new Cfg.Configuration(); // The following makes sure the the web.config contains a declaration for the HBM_ASSEMBLY appSetting if (ConfigurationManager.AppSettings["HBM_ASSEMBLY"] == null || ConfigurationManager.AppSettings["HBM_ASSEMBLY"] == "") { throw new ConfigurationErrorsException("NHibernateManager.InitSessionFactory: “HBM_ASSEMBLY” must be " + "provided as an appSetting within your config file. “HBM_ASSEMBLY” informs NHibernate which assembly " + "contains the HBM files. It is assumed that the HBM files are embedded resources. An example config " + "declaration is <add key=”HBM_ASSEMBLY” value=”MyProject.Core” />"); } cfg.AddAssembly(ConfigurationManager.AppSettings["HBM_ASSEMBLY"]); sessionFactory = cfg.BuildSessionFactory(); }
public static ISessionFactory GetNhibernateSessionFactory() { var configure = new NHibernate.Cfg.Configuration(); configure.DataBaseIntegration(delegate(NHibernate.Cfg.Loquacious.IDbIntegrationConfigurationProperties dbi) { dbi.ConnectionString = "mvcWithNHibernate"; dbi.Dialect <NHibernate.Dialect.MsSql2012Dialect>(); dbi.Driver <NHibernate.Driver.SqlClientDriver>(); dbi.Timeout = 255; }); configure.AddAssembly(typeof(Address).Assembly); configure.CurrentSessionContext <WebSessionContext>(); return(configure.BuildSessionFactory()); }
public PersistenceManager() { dataDir = System.Configuration.ConfigurationManager.AppSettings["DataDir"]; schemaDir = System.Configuration.ConfigurationManager.AppSettings["SchemaDir"]; cfg = new NHibernate.Cfg.Configuration(); cfg.AddAssembly("Persistence"); factory = cfg.BuildSessionFactory(); try { problemList = ListAllProblems(); coolerList = ListAllCoolers(); materialList = ListAllMaterials(); } catch (Exception ex) { problemList = new P_Problem[0]; coolerList = new P_Cooler[0]; materialList = new P_Material[0]; } }
private static NHibernate.Cfg.Configuration NHibernateConfiguration() { var cfg = new NHibernate.Cfg.Configuration(); cfg.DataBaseIntegration(x => { x.ConnectionString = @"Server=(localdb)\MSSQLLocalDB;Integrated Security=true;AttachDbFileName=C:\Data\FinanceDB.mdf"; x.Driver <SqlClientDriver>(); x.Dialect <MsSql2012Dialect>(); x.Timeout = 10; x.LogSqlInConsole = true; x.LogFormattedSql = true; }); cfg.AddAssembly(Assembly.GetExecutingAssembly()); return(cfg); }
public static Configuration CreateSQLLite(string sConnectionName, string[] lstMappingAssemblyName) { string connectionString = ConfigurationManager.ConnectionStrings[sConnectionName].ConnectionString; Configuration configuration = new Configuration() .SetProperty(Environment.ReleaseConnections, "on_close") .SetProperty(Environment.Dialect, "NHibernate.Dialect.SQLiteDialect") .SetProperty(Environment.ConnectionDriver, "NHibernate.Driver.SQLite20Driver") .SetProperty(Environment.ConnectionString, connectionString) .SetProperty(Environment.ShowSql, "true") .SetProperty(Environment.ProxyFactoryFactoryClass, "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"); foreach (string mappingAssemblyName in lstMappingAssemblyName) { configuration.AddAssembly(mappingAssemblyName); } return(configuration); }
public static void ResetSessionFactory() { Configuration config; HttpContext currentContext = HttpContext.Current; cAppConfig oApp = new cAppConfig(ConfigFileType.AppConfig); config = new NHibernate.Cfg.Configuration(); config.SetProperty("hibernate.connection.connection_string", oApp.GetValue("hibernate.connection.connection_string")); config.AddAssembly("Business"); NHibernateHttpModule.m_factory = config.BuildSessionFactory(); NHibernateHttpModule.m_session = NHibernateHttpModule.m_factory.OpenSession(); if (NHibernateHttpModule.m_factory == null) { throw new InvalidOperationException("Call to Configuration.BuildSessionFactory() returned null."); } }
public Configuration CreateSQLServer2005(string[] lstMappingAssemblyName) { string connectionString = @"Data Source=HUGO-PC\SQLEXPRESS;Initial Catalog=NetBPM;Integrated Security=SSPI;"; Configuration configuration = new Configuration() .SetProperty(Environment.ReleaseConnections, "on_close") .SetProperty(Environment.Dialect, "NHibernate.Dialect.MsSql2005Dialect") .SetProperty(Environment.ConnectionDriver, "NHibernate.Driver.SqlClientDriver") .SetProperty(Environment.ConnectionString, connectionString) .SetProperty(Environment.ShowSql, "true") .SetProperty(Environment.ProxyFactoryFactoryClass, "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle") .SetProperty(Environment.CacheProvider, "NHibernate.Cache.HashtableCacheProvider"); foreach (string mappingAssemblyName in lstMappingAssemblyName) { configuration.AddAssembly(mappingAssemblyName); } return(configuration); }
public static Configuration CreateSQLServer2005(string sConnectionName, string[] lstMappingAssemblyName) { string connectionString = ConfigurationManager.ConnectionStrings[sConnectionName].ConnectionString; Configuration configuration = new Configuration() .SetProperty(Environment.ReleaseConnections, "on_close") .SetProperty(Environment.Dialect, "NHibernate.Dialect.MsSql2005Dialect") .SetProperty(Environment.ConnectionDriver, "NHibernate.Driver.SqlClientDriver") .SetProperty(Environment.ConnectionString, connectionString) .SetProperty(Environment.ShowSql, "true") .SetProperty(Environment.ProxyFactoryFactoryClass, "NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu") .SetProperty(Environment.CacheProvider, "NHibernate.Cache.HashtableCacheProvider") .SetProperty(Environment.UseSecondLevelCache, "true") //這個是用ID去查 .SetProperty(Environment.UseQueryCache, "true"); //這個是用查詢語法,外加指定名稱去查 foreach (string mappingAssemblyName in lstMappingAssemblyName) { configuration.AddAssembly(mappingAssemblyName); } return(configuration); }
public static ISession GetSession() { try { if (_sessionFactory == null) { lock (typeof(NHibernateHelper)) { if (_sessionFactory == null) { Configuration cfg = new Configuration(); string connectionString = "Server=GMEPN000749\\SQLSERVER;Database=TESTE;Trusted_Connection=True;"; NHibernate.Cfg.Configuration nHibernateConfiguration = new NHibernate.Cfg.Configuration(); nHibernateConfiguration.SetProperty(NHibernate.Cfg.Environment.ProxyFactoryFactoryClass, typeof(NHibernate.ByteCode.Castle.ProxyFactoryFactory).AssemblyQualifiedName); nHibernateConfiguration.SetProperty(NHibernate.Cfg.Environment.Dialect, typeof(NHibernate.Dialect.MsSql2008Dialect).AssemblyQualifiedName); nHibernateConfiguration.SetProperty(NHibernate.Cfg.Environment.ConnectionString, connectionString); nHibernateConfiguration.SetProperty(NHibernate.Cfg.Environment.ShowSql, "true"); nHibernateConfiguration.AddAssembly("MapeamentoOR"); //objProperties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"); ISessionFactory oneISessionFactory = nHibernateConfiguration .BuildSessionFactory(); //cfg.AddProperties("") //cfg.AddAssembly("MapeamentoOR"); //_sessionFactory = cfg.BuildSessionFactory(); return(oneISessionFactory.OpenSession()); } } } } catch (Exception e) { } return(null); }
public static ISessionFactory ReturnSessionFactory() { ISessionFactory SF = null; var config = new NHibernate.Cfg.Configuration(); try { config.DataBaseIntegration(delegate(NHibernate.Cfg.Loquacious.IDbIntegrationConfigurationProperties cfgbbi) { cfgbbi.ConnectionStringName = "ConnectionMysql"; cfgbbi.Driver <NHibernate.Driver.MySqlDataDriver>(); cfgbbi.Dialect <NHibernate.Dialect.MySQL55Dialect>(); cfgbbi.Timeout = 120; }); config.CurrentSessionContext <WebSessionContext>(); config.AddAssembly(typeof(TblAdmin).Assembly); SF = config.BuildSessionFactory(); } catch (Exception ex) { } return(SF); }
/// <summary> /// /// </summary> /// <param name="properties"></param> /// <param name="resources"></param> public void Configure(NameValueCollection properties, IDictionary resources) { string mapping = string.Empty; try { NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration(); // Set the connection string retrieve on the datasource config.SetProperty(CONNECTION_STRING, (resources["DataSource"] as DataSource).ConnectionString); foreach (DictionaryEntry entry in resources) { if ((entry.Key.ToString()).StartsWith("class.")) { config.AddClass(Resources.TypeForName(entry.Value.ToString())); } if ((entry.Key.ToString()) == "mapping") { mapping = entry.Value.ToString(); } config.SetProperty(entry.Key.ToString(), entry.Value.ToString()); } if (mapping.Length > 0) { config.AddAssembly(mapping); } _factory = config.BuildSessionFactory(); } catch (Exception e) { throw new ConfigurationException(string.Format("DaoManager could not configure NHibernateDaoSessionHandler. Cause: {0}", e.Message), e); } }
/// <summary> /// Initialize the SessionFactory for the given or the /// default location. /// </summary> public virtual void AfterPropertiesSet() { // Create Configuration instance. Configuration config = NewConfiguration(); if (this.dbProvider != null) { config.SetProperty(Environment.ConnectionString, dbProvider.ConnectionString); config.SetProperty(Environment.ConnectionProvider, typeof(DbProviderWrapper).AssemblyQualifiedName); configTimeDbProvider = this.dbProvider; } if (ExposeTransactionAwareSessionFactory) { // Set ICurrentSessionContext implementation, // providing the Spring-managed ISession s current Session. // Can be overridden by a custom value for the corresponding Hibernate property // config.SetProperty(Environment.CurrentSessionContextClass, typeof(SpringSessionContext).AssemblyQualifiedName); config.SetProperty(Environment.CurrentSessionContextClass, typeof(WcfOperationSessionContext).AssemblyQualifiedName); } if (this.entityInterceptor != null) { // Set given entity interceptor at SessionFactory level. config.SetInterceptor(this.entityInterceptor); } if (this.namingStrategy != null) { // Pass given naming strategy to Hibernate Configuration. config.SetNamingStrategy(this.namingStrategy); } if (this.filterDefinitions != null) { // Register specified NHibernate FilterDefinitions. for (int i = 0; i < this.filterDefinitions.Length; i++) { config.AddFilterDefinition(this.filterDefinitions[i]); } } if (this.hibernateProperties != null) { if (config.GetProperty(Environment.ConnectionProvider) != null && hibernateProperties.Contains(Environment.ConnectionProvider)) { #region Logging if (log.IsInfoEnabled) { log.Info("Overriding use of Spring's Hibernate Connection Provider with [" + hibernateProperties[Environment.ConnectionProvider] + "]"); } #endregion config.Properties.Remove(Environment.ConnectionProvider); } Dictionary <string, string> genericHibernateProperties = new Dictionary <string, string>(); foreach (DictionaryEntry entry in hibernateProperties) { genericHibernateProperties.Add((string)entry.Key, (string)entry.Value); } config.AddProperties(genericHibernateProperties); } if (this.mappingAssemblies != null) { foreach (string assemblyName in mappingAssemblies) { config.AddAssembly(assemblyName); } } if (this.mappingResources != null) { IResourceLoader loader = this.ResourceLoader; if (loader == null) { loader = this.applicationContext; } foreach (string resourceName in mappingResources) { config.AddInputStream(loader.GetResource(resourceName).InputStream); } } if (configFilenames != null) { foreach (string configFilename in configFilenames) { config.Configure(configFilename); } } if (this.eventListeners != null) { // Register specified NHibernate event listeners. foreach (DictionaryEntry entry in eventListeners) { ListenerType listenerType; try { listenerType = (ListenerType)Enum.Parse(typeof(ListenerType), (string)entry.Key); } catch { throw new ArgumentException(string.Format("Unable to parse string '{0}' as valid {1}", entry.Key, typeof(ListenerType))); } object listenerObject = entry.Value; if (listenerObject is ICollection) { ICollection listeners = (ICollection)listenerObject; EventListeners listenerRegistry = config.EventListeners; // create the array and check that types are valid at the same time ArrayList items = new ArrayList(listeners); object[] listenerArray = (object[])items.ToArray(listenerRegistry.GetListenerClassFor(listenerType)); config.SetListeners(listenerType, listenerArray); } else { config.SetListener(listenerType, listenerObject); } } } // Perform custom post-processing in subclasses. PostProcessConfiguration(config); // Build SessionFactory instance. log.Info("Building new Hibernate SessionFactory"); this.configuration = config; this.sessionFactory = NewSessionFactory(config); AfterSessionFactoryCreation(); // set config time DB provider back to null configTimeDbProvider = null; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(option => option.EnableEndpointRouting = false); var mvcBuilder = services.AddMvc(); services.AddControllers().AddNewtonsoftJson(); services.AddControllers().AddNewtonsoftJson(opt => { var ss = JsonSerializationFns.UpdateWithDefaults(opt.SerializerSettings); var resolver = ss.ContractResolver; if (resolver != null) { var res = resolver as DefaultContractResolver; res.NamingStrategy = null; // <<!-- this removes the camelcasing } #if NHIBERNATE // NHibernate settings var settings = opt.SerializerSettings; settings.ContractResolver = NHibernateContractResolver.Instance; settings.Error = delegate(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args) { // When the NHibernate session is closed, NH proxies throw LazyInitializationException when // the serializer tries to access them. We want to ignore those exceptions. var error = args.ErrorContext.Error; if (error is NHibernate.LazyInitializationException || error is System.ObjectDisposedException) { args.ErrorContext.Handled = true; } }; if (!settings.Converters.Any(c => c is NHibernateProxyJsonConverter)) { settings.Converters.Add(new NHibernateProxyJsonConverter()); } #endif }); mvcBuilder.AddMvcOptions(o => { o.Filters.Add(new GlobalExceptionFilter()); }); var tmp = Configuration.GetConnectionString("NorthwindIB_CF"); #if EFCORE services.AddDbContext <NorthwindIBContext_CF>(options => options.UseSqlServer(tmp)); #endif #if NHIBERNATE services.AddSingleton <NHibernate.ISessionFactory>(factory => { var cfg = new NHibernate.Cfg.Configuration(); cfg.DataBaseIntegration(db => { db.ConnectionString = tmp; db.Dialect <MsSql2008Dialect>(); db.Driver <Sql2008ClientDriver>(); db.LogFormattedSql = true; db.LogSqlInConsole = true; }); cfg.Properties.Add(Environment.DefaultBatchFetchSize, "32"); cfg.CurrentSessionContext <NHibernate.Context.ThreadStaticSessionContext>(); var modelAssembly = typeof(Models.NorthwindIB.NH.Customer).Assembly; cfg.AddAssembly(modelAssembly); // mapping is in this assembly var sessionFactory = cfg.BuildSessionFactory(); return(sessionFactory); }); #endif }
static NHibernator() { string configurationFilePath = null; string connectionStringName = null; string[] configurationFilePathArray = null; string nhibernateConfigFile; Assembly mappingAssembly = GetAssemblyFromName(Config.MappingAssembly); if (mappingAssembly == null) { throw new NHibernatorException(String.Format("Mapping Assembly Could Not Be Found, check appSettings>{0} in web.config", Config.NHIBERNATE_MAPPING_ASSEMBLY_KEY)); } if (ConfigurationManager.AppSettings != null) { configurationFilePath = ConfigurationManager.AppSettings[NHIBERNATE_CFG_FILE_KEY]; connectionStringName = Config.ConnStringName; } if (connectionStringName != null) { // Fluent NHibernate Support ISessionFactory sf = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2012 .ConnectionString(c => c.FromConnectionStringWithKey(connectionStringName))) .Cache(c => c.UseQueryCache() .ProviderClass <HashtableCacheProvider>()) //.ShowSql()) .Mappings(m => m.FluentMappings.AddFromAssembly(mappingAssembly)) .ExposeConfiguration(BuildSchema) .BuildSessionFactory(); sessionFactories.Add(connectionStringName, sf); } else if (configurationFilePath != null) { configurationFilePathArray = configurationFilePath.Split(';'); foreach (string configFilePath in configurationFilePathArray) { if (configFilePath.StartsWith("~")) { nhibernateConfigFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configFilePath.Substring(1)); } else { nhibernateConfigFile = configFilePath; } if (File.Exists(nhibernateConfigFile)) { string factoryName = null; configuration = new NHibernate.Cfg.Configuration(); configuration.Configure(nhibernateConfigFile); configuration.AddAssembly(mappingAssembly); var sf = (ISessionFactoryImplementor)configuration.BuildSessionFactory(); if (!String.IsNullOrEmpty(sf.Settings.SessionFactoryName)) { factoryName = sf.Settings.SessionFactoryName; } else if (configuration.Properties.ContainsKey("hibernate.session_factory_name")) { factoryName = configuration.Properties["hibernate.session_factory_name"]; } else { // default session factory key factoryName = string.Empty; } if (!sessionFactories.ContainsKey(factoryName)) { sessionFactories.Add(factoryName, sf); } } } } if (sessionFactories.Count == 0) { configuration = new NHibernate.Cfg.Configuration(); nhibernateConfigFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, NHIBERNATE_DEFAULT_FILENAME_KEY); if (File.Exists(nhibernateConfigFile)) { configuration.Configure(nhibernateConfigFile); } else { configuration.Configure(); } ISessionFactory sf = configuration.BuildSessionFactory(); sessionFactories.Add(string.Empty, sf); } InitSessionStorge(); }
/// <summary> /// Initialize the SessionFactory for the given or the /// default location. /// </summary> public virtual void AfterPropertiesSet() { // Create Configuration instance. Configuration config = NewConfiguration(); if (this.dbProvider != null) { config.SetProperty(Environment.ConnectionString, dbProvider.ConnectionString); config.SetProperty(Environment.ConnectionProvider, typeof(DbProviderWrapper).AssemblyQualifiedName); configTimeDbProvider = this.dbProvider; } if (ExposeTransactionAwareSessionFactory) { // Set ICurrentSessionContext implementation, // providing the Spring-managed ISession s current Session. // Can be overridden by a custom value for the corresponding Hibernate property config.SetProperty(Environment.CurrentSessionContextClass, typeof(SpringSessionContext).AssemblyQualifiedName); } if (this.entityInterceptor != null) { // Set given entity interceptor at SessionFactory level. config.SetInterceptor(this.entityInterceptor); } if (this.namingStrategy != null) { // Pass given naming strategy to Hibernate Configuration. config.SetNamingStrategy(this.namingStrategy); } #if NH_2_1 if (this.typeDefinitions != null) { // Register specified Hibernate type definitions. IDictionary <string, string> typedProperties = new Dictionary <string, string>(); foreach (DictionaryEntry entry in hibernateProperties) { typedProperties.Add((string)entry.Key, (string)entry.Value); } Dialect dialect = Dialect.GetDialect(typedProperties); Mappings mappings = config.CreateMappings(dialect); for (int i = 0; i < this.typeDefinitions.Length; i++) { IObjectDefinition typeDef = this.typeDefinitions[i]; Dictionary <string, string> typedParamMap = new Dictionary <string, string>(); foreach (DictionaryEntry entry in typeDef.PropertyValues) { typedParamMap.Add((string)entry.Key, (string)entry.Value); } mappings.AddTypeDef(typeDef.ObjectTypeName, typeDef.ObjectTypeName, typedParamMap); } } #endif if (this.filterDefinitions != null) { // Register specified NHibernate FilterDefinitions. for (int i = 0; i < this.filterDefinitions.Length; i++) { config.AddFilterDefinition(this.filterDefinitions[i]); } } #if NH_2_1 // check whether proxy factory has been initialized if (config.GetProperty(Environment.ProxyFactoryFactoryClass) == null && (hibernateProperties == null || !hibernateProperties.Contains(Environment.ProxyFactoryFactoryClass))) { // nothing set by user, lets use Spring.NET's proxy factory factory #region Logging if (log.IsInfoEnabled) { log.Info("Setting proxy factory to Spring provided one as user did not specify any"); } #endregion config.Properties.Add( Environment.ProxyFactoryFactoryClass, typeof(Bytecode.ProxyFactoryFactory).AssemblyQualifiedName); } #endif if (this.hibernateProperties != null) { if (config.GetProperty(Environment.ConnectionProvider) != null && hibernateProperties.Contains(Environment.ConnectionProvider)) { #region Logging if (log.IsInfoEnabled) { log.Info("Overriding use of Spring's Hibernate Connection Provider with [" + hibernateProperties[Environment.ConnectionProvider] + "]"); } #endregion config.Properties.Remove(Environment.ConnectionProvider); } Dictionary <string, string> genericHibernateProperties = new Dictionary <string, string>(); foreach (DictionaryEntry entry in hibernateProperties) { genericHibernateProperties.Add((string)entry.Key, (string)entry.Value); } config.AddProperties(genericHibernateProperties); } if (this.mappingAssemblies != null) { foreach (string assemblyName in mappingAssemblies) { config.AddAssembly(assemblyName); } } if (this.mappingResources != null) { IResourceLoader loader = this.ResourceLoader; if (loader == null) { loader = this.applicationContext; } foreach (string resourceName in mappingResources) { config.AddInputStream(loader.GetResource(resourceName).InputStream); } } if (configFilenames != null) { foreach (string configFilename in configFilenames) { config.Configure(configFilename); } } #if NH_2_1 // Tell Hibernate to eagerly compile the mappings that we registered, // for availability of the mapping information in further processing. PostProcessMappings(config); config.BuildMappings(); if (this.entityCacheStrategies != null) { // Register cache strategies for mapped entities. foreach (string className in this.entityCacheStrategies.Keys) { String[] strategyAndRegion = StringUtils.CommaDelimitedListToStringArray(this.entityCacheStrategies.GetProperty(className)); if (strategyAndRegion.Length > 1) { config.SetCacheConcurrencyStrategy(className, strategyAndRegion[0], strategyAndRegion[1]); } else if (strategyAndRegion.Length > 0) { config.SetCacheConcurrencyStrategy(className, strategyAndRegion[0]); } } } if (this.collectionCacheStrategies != null) { // Register cache strategies for mapped collections. foreach (string collRole in collectionCacheStrategies.Keys) { string[] strategyAndRegion = StringUtils.CommaDelimitedListToStringArray(this.collectionCacheStrategies.GetProperty(collRole)); if (strategyAndRegion.Length > 1) { throw new Exception("Collection cache concurrency strategy region definition not supported yet"); //config.SetCollectionCacheConcurrencyStrategy(collRole, strategyAndRegion[0], strategyAndRegion[1]); } else if (strategyAndRegion.Length > 0) { config.SetCollectionCacheConcurrencyStrategy(collRole, strategyAndRegion[0]); } } } #endif if (this.eventListeners != null) { // Register specified NHibernate event listeners. foreach (DictionaryEntry entry in eventListeners) { ListenerType listenerType; try { listenerType = (ListenerType)Enum.Parse(typeof(ListenerType), (string)entry.Key); } catch { throw new ArgumentException(string.Format("Unable to parse string '{0}' as valid {1}", entry.Key, typeof(ListenerType))); } object listenerObject = entry.Value; if (listenerObject is ICollection) { ICollection listeners = (ICollection)listenerObject; EventListeners listenerRegistry = config.EventListeners; // create the array and check that types are valid at the same time ArrayList items = new ArrayList(listeners); object[] listenerArray = (object[])items.ToArray(listenerRegistry.GetListenerClassFor(listenerType)); config.SetListeners(listenerType, listenerArray); } else { config.SetListener(listenerType, listenerObject); } } } // Perform custom post-processing in subclasses. PostProcessConfiguration(config); #if NH_2_1 if (BytecodeProvider != null) { // set custom IBytecodeProvider Environment.BytecodeProvider = BytecodeProvider; } else { // use Spring's as default // Environment.BytecodeProvider = new Bytecode.BytecodeProvider(this.applicationContext); } #endif // Build SessionFactory instance. log.Info("Building new Hibernate SessionFactory"); this.configuration = config; this.sessionFactory = NewSessionFactory(config); AfterSessionFactoryCreation(); // set config time DB provider back to null configTimeDbProvider = null; }
static void Main(string[] args) { IApplicationContext context = new XmlApplicationContext("IrcBot-applicationContext.xml"); XmlConfigurator.Configure(new System.IO.FileInfo("log4net.xml")); botResponders = (List <Responder>)context.GetObject("responderList"); pollers = (List <Poller>)context.GetObject("pollerList"); managers = (Dictionary <String, AbstractManager>)context.GetObject("managers"); connection = ((IrcConnectionManager)getManager(IrcConnectionManager.MANAGER_NAME)).connection; CHANNEL = (String)context.GetObject("IrcChannel"); NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration(); config.Configure(); config.AddAssembly(typeof(User).Assembly); ISessionFactory sessionFactory = config.BuildSessionFactory(); //var schema = new SchemaExport(config); //schema.Create(true, true); mySession = sessionFactory.OpenSession(); List <User> savedUsers = (List <User>)mySession.CreateCriteria <User>().List <User>(); users.AddRange(savedUsers); //Start pollers //set the channel and connection objects. foreach (Poller poller in pollers) { poller.connection = connection; poller.channel = CHANNEL; } pollerManager = new PollerManager(pollers); log.Debug("Starting Skill Enumeration"); skillList = getSkillList(); foreach (SkillTree.Skill skill in skillList) { try { skillIds.Add(skill.TypeName.ToLower(), skill.TypeId); } catch (ArgumentException ae) { log.Warn("Argument exception: " + ae.Message); } } foreach (User user in users) { log.Debug("Adding user " + user.userName); nickDict.Add(user.userName, user); } string inputLine; while (true) { try { PingSender ping = new PingSender(connection); ping.setServer(connection.server); ping.start(); ActionThread actionThread = new ActionThread(); actionThread.start(); connection.joinChannel(CHANNEL); connection.privmsg(CHANNEL, "Reporting for duty!"); ArrayList results = new ArrayList(); while (true) { while ((inputLine = connection.ReadLine()) != null) { inputQueue.Enqueue(inputLine); } } } catch (Exception e) { log.Error("Caught exception in operation: " + e.Message); Thread.Sleep(5000); string[] argv = { }; } } }