protected void Application_Start(object sender, EventArgs e) { //atribui o idioma Português-brasil ao contexto do sistema. com isso o sistema irá reconhecer os formatos de numero, //datra e moedas no padrão Portugues-Brasil System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("pt-BR"); //Lê o arquivo de configuração do NHibernate. var config = new XmlConfigurationSource(Assembly.GetExecutingAssembly().CodeBase.Replace("Web.DLL", "config.xml")); //Inicializa o NHibernate ActiveRecordStarter.Initialize(new Assembly[] { Assembly.GetAssembly(typeof(Usuario)) }, config, new Type[] { }); //ActiveRecordStarter.DropSchema(); //ActiveRecordStarter.CreateSchema();// criar tabela //Usuario usuario = new Usuario(); //usuario.Nome = "administrador"; //usuario.NomeUsuario = "admin"; //usuario.Email = "*****@*****.**"; //usuario.TipoDoUsuario = Usuario.TipoUsuario.AdministradorCondominio; //usuario.StatusDoUsuario = Usuario.Status.Ativo; //usuario.Senha = Criptografia.EncriptMD5("admin"); //usuario.CreateAndFlush(); }
public static void Init() { lock (sync) { if (initialized) return; // This is a complete hack, which will attempt to load the config file from the bin directory of the current application string dllLocation = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Replace(@"file:///", "").Replace(@"/", @"\"); FileInfo file = new FileInfo(dllLocation); XmlConfigurationSource config = null; if (File.Exists(file.Directory + @"\ARConfig.xml")) { config = new XmlConfigurationSource(file.Directory + @"\ARConfig.xml"); } else if (File.Exists(file.Directory.Parent.FullName + @"\ARConfig.xml")) { config = new XmlConfigurationSource(file.Directory.Parent.FullName + @"\ARConfig.xml"); } if (!ActiveRecordStarter.IsInitialized) ActiveRecordStarter.Initialize(config, typeof(CredentialData), typeof(ModelData), typeof(ApiKey)); initialized = true; } }
private void btnSelect_Click(object sender, EventArgs e) { ConfigHelper.current_seam = (CoalSeam)cboCoalSeam.SelectedItem; Hide(); XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(Application.StartupPath + "\\" + "ARConfig.xml"); XmlElement root = xmldoc.DocumentElement; var a = root.SelectNodes("/activerecord/config/add"); var sqlcons = a[3].Attributes["value"].InnerText.Split(';'); string str = ""; for (int i = 0; i < sqlcons.Length; i++) { switch (i) { case 0: str += "data Source=" + ConfigHelper.current_seam.db_name; break; default: str += sqlcons[i]; break; } str += ";"; } a[3].Attributes["value"].InnerText = str; xmldoc.Save(Application.StartupPath + "\\" + "ARConfig.xml"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-Hans"); Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-Hans"); IConfigurationSource config = new XmlConfigurationSource("ARConfig.xml"); var asm = Assembly.Load("LibEntity"); ActiveRecordStarter.Initialize(asm, config); Form.ShowDialog(); }
public static void Main() { XmlConfigurationSource source = new XmlConfigurationSource ("test_castle_config.xml"); Assembly ass = Assembly.Load ("MomaTool.Database"); ActiveRecordStarter.Initialize (ass, source); ActiveRecordStarter.CreateSchema (); }
public object ServiceInit() { string configPath = string.Format("{0}/Config/Appconfig.xml", AppDomain.CurrentDomain.BaseDirectory); string assemblyPath = string.Format("{0}/Config/ActiveRecordAssemblies.xml", AppDomain.CurrentDomain.BaseDirectory); IConfigurationSource source = new XmlConfigurationSource(configPath); Assembly[] assemblies = LoadAssemblies(assemblyPath); ActiveRecordStarter.Initialize(assemblies, source); return null; }
static void Main() { XmlConfigurationSource source = new XmlConfigurationSource("appconfig.xml"); ActiveRecordStarter.Initialize(source, typeof(AppData.Menu), typeof(AppData.CustomerProfile), typeof(AppData.MenuSchedule),typeof(AppData.CustomerOrder),typeof(AppData.CustomerOrderDetail)); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FrmMain()); }
static void Main() { Type[] t = { typeof(Lable), typeof(Album), typeof(AlbumFormat), typeof(Artist), typeof(Genre), typeof(PlayList), typeof(TrackList), typeof(YearTable)}; XmlConfigurationSource source = new XmlConfigurationSource("appconfig.xml"); ActiveRecordStarter.Initialize(source, t); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm main = MainForm.Instance(); Application.Run(main); }
public static void Initialize() { FileInfo fileInfo = new FileInfo("log4net.xml"); log4net.Config.XmlConfigurator.Configure(fileInfo); log.Info("Inicializando app"); XmlConfigurationSource arConfig = new XmlConfigurationSource("arconfig.xml"); ActiveRecordStarter.Initialize(arConfig, typeof(User), typeof(Question)); }
public static void Main() { // 1. Step Configure and Initialize ActiveRecord: // If you want to use the InPlaceConfigurationSource: // Hashtable properties = new Hashtable(); // properties.Add("hibernate.connection.driver_class", "NHibernate.Driver.SqlClientDriver"); // properties.Add("hibernate.dialect", "NHibernate.Dialect.MsSql2000Dialect"); // properties.Add("hibernate.connection.provider", "NHibernate.Connection.DriverConnectionProvider"); // properties.Add("hibernate.connection.connection_string", "Data Source=.;Initial Catalog=test;Integrated Security=SSPI"); // InPlaceConfigurationSource source = new InPlaceConfigurationSource(); // source.Add(typeof(ActiveRecordBase), properties); // We are using XmlConfigurationSource: XmlConfigurationSource source = new XmlConfigurationSource("../appconfig.xml"); ActiveRecordStarter.Initialize( source, typeof(Blog), typeof(Post), typeof(User) ); // 2. Create the schema // If you want to let AR to create the schema if (MessageBox.Show("Do you want to let ActiveRecord create the database tables?", "Schema", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ActiveRecordStarter.CreateSchema(); } // 3. Create the first user (so you can log in) if (User.GetUsersCount()== 0) { User user = new User("admin", "123"); user.Create(); } // 4. Bring the Login Form using(LoginForm login = new LoginForm()) { if (login.ShowDialog() != DialogResult.OK) { return; } } // 5. Show the main form using(BlogManagement mainForm = new BlogManagement()) { Application.Run(mainForm); } }
public virtual XmlConfigurationSource GetSource() { FileInfo xmlConfig = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin", "ActiveRecord.xml")); if (!xmlConfig.Exists) { xmlConfig = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ActiveRecord.xml")); if (!xmlConfig.Exists) throw new Exception(String.Format("Não foi encontrado o arquivo \"ActiveRecord.xml\" de configuração")); } XmlConfigurationSource source = new XmlConfigurationSource(xmlConfig.FullName); return source; }
public static void Init () { XmlConfigurationSource config; string location = Assembly.GetExecutingAssembly().Location; Environment.CurrentDirectory = Path.GetDirectoryName (location); config = new XmlConfigurationSource("Config/ARConfig.xml"); Assembly asm = Assembly.Load("Models"); ActiveRecordStarter.SessionFactoryHolderCreated += ActiveRecordStarter_SessionFactoryHolderCreated; ActiveRecordStarter.Initialize(asm, config); }
public static void ini() { XmlConfigurationSource ARConfig = new XmlConfigurationSource("ARConfig.xml"); try { ActiveRecordStarter.Initialize(ARConfig, typeof(Placa), typeof(Licencia), typeof(Direccion), typeof(Multa), typeof(OrdAprehension)); } catch (Exception e) { Console.WriteLine("ocurrio excepcion: " + e.Message); } Console.WriteLine("Inicializando Aplicacion"); }
static void Main(string[] args) { XmlConfigurationSource source = new XmlConfigurationSource("appconfig.xml"); ActiveRecordStarter.Initialize(source, typeof(Address), typeof(Employee), typeof(SalariedEmployee), typeof(HourlyPaidEmployee) ); using (new SessionScope()) // need this for lazy loading to work { // query for Addresses Address add = Address.FindFirst(); Console.WriteLine(add.AddressID); List<Address> addresses = Address.FindAll().ToList(); foreach (Address ad in addresses) { Console.WriteLine(ad.PropertyName); } // query for Employees Employee emp = Employee.FindByUsername("felipe"); Console.WriteLine(emp.EmployeeID); Employee emp2 = Employee.FindNewestEmployee(); Console.WriteLine(emp2.EmployeeID); List<Employee> employees = Employee.FindAll().ToList(); foreach (Employee em in employees) { Console.WriteLine(em.Name + ", " + em.Address.PropertyName); } } // wait for key press before ending Console.ReadLine(); }
private static void Main() { Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-Hans"); // The following line provides localization for data formats. Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-Hans"); IConfigurationSource config = new XmlConfigurationSource("ARConfig.xml"); var asm = Assembly.Load("LibEntity"); ActiveRecordStarter.Initialize(asm, config); RuntimeManager.Bind(ProductCode.EngineOrDesktop); var mf = new MainForm_OP(); Application.Run(mf); }
private static void Init() { XmlConfigurationSource arConfig = new XmlConfigurationSource("arconfig.xml"); try{ ActiveRecordStarter.Initialize(arConfig, typeof(Bus), typeof(Driver), typeof(Route), typeof(Station), typeof(TimeCheck), typeof(User) ); } catch( Exception ex) { Console.WriteLine("excepcion" + ex.Message); } Console.WriteLine("inicializando..."); }
protected void Application_Start(object sender, EventArgs e) { try { XmlConfigurationSource src = new XmlConfigurationSource(Server.MapPath("~/arconfig.xml")); ActiveRecordStarter.Initialize(src, typeof(Bus), typeof(Driver), typeof(Route), typeof(Station), typeof(MonRut.Domain.User) ); } catch (Exception ex) { // Console.WriteLine("excepcion" + ex.Message); EventLog el = new EventLog(); el.Source = "Application"; el.WriteEntry(ex.Message); } }
private void RemoveSearchProperties(XmlConfigurationSource configSource) { var cfg = configSource.GetConfiguration(typeof(ActiveRecordBase)); foreach (var prop in searchConfig) { cfg.Children.Remove(prop); } }
public static void initActiveRecord() { XmlConfigurationSource config = new XmlConfigurationSource(AppDomain.CurrentDomain.BaseDirectory.ToString() + "ARConfig.xml"); Assembly asm = Assembly.Load("Antares.model"); ActiveRecordStarter.Initialize(new Assembly[] { asm }, config); // Se crea la instancia de configuracion //IConfigurationSource config = ActiveRecordSectionHandler.Instance; // Se inicializa el framework //ActiveRecordStarter.Initialize(config,typeof(Gos.Usuarios.User)); /*Assembly asm = Assembly.Load("Gos.Usuarios"); ActiveRecordStarter.Initialize(asm, config); */ //Assembly asm1 = Assembly.Load("Gos.Usuarios"); //Assembly asm2 = Assembly.Load("Antares.model"); //ActiveRecordStarter.Initialize(new Assembly[] { asm1, asm2 }, config); // Se elimna el esquema de la base de datos //ActiveRecordStarter.DropSchema(); // Se crea el equema en la base de datos y te borra todos los datos //ActiveRecordStarter.CreateSchema(); //ActiveRecordStarter.GenerateCreationScripts(@"d:\webAntares.sql"); //ActiveRecordStarter.CreateSchema(typeof(Cajas.Model.Empresas)); CrearDefaults(); }
public void TestFixtureSetUp() { ActiveRecordStarter.ResetInitializationFlag(); IConfigurationSource source = new XmlConfigurationSource("Activerecord.config"); ActiveRecordStarter.Initialize(Assembly.GetAssembly(typeof(User)), source); }
public void BeforeEach() { var source = new XmlConfigurationSource("lejr_dk.cfg.xml"); ActiveRecordStarter.Initialize(source, typeof (Camp)); }
/// <summary> /// Called to initialize setup NHibernate and ActiveRecord /// </summary> /// <param name="asm"></param> /// <param name="dbType"></param> /// <param name="connStr"></param> /// <returns>Whether its a fatal error</returns> public static bool InitAR(Assembly asm) { if (s_configReader == null) { s_configReader = DatabaseConfiguration.GetARConfiguration(DBType, ConnectionString); if (s_configReader == null) { throw new Exception("Invalid Database Type: " + DBType); } } s_config = new XmlConfigurationSource(s_configReader); var types = new List<Type>(); ActiveRecordStarter.CollectValidActiveRecordTypesFromAssembly(asm, types, s_config); var typeArr = types.ToArray(); Types.Add(asm, typeArr); NHibernate.Cfg.Environment.UseReflectionOptimizer = true; ActiveRecordStarter.Initialize(s_config, typeArr); if (!IsConnected) { throw new Exception(string.Format("Failed to connect to Database.")); } var hibCfg = Config; s_dialect = Dialect.GetDialect(hibCfg.Properties) ?? Dialect.GetDialect(); // get all exports *before* the content system or other Addons register their ActiveRecords // so we don't accidently dump/create any outside table schemas foreach (var cfg in ActiveRecordBase.Holder.GetAllConfigurations()) { s_exports.Add(ActiveRecordStarter.CreateSchemaExport(cfg)); } return true; }
/// <summary> /// Called to initialize setup NHibernate and ActiveRecord /// </summary> /// <param name="asm"></param> /// <param name="dbType"></param> /// <param name="connStr"></param> /// <returns>Whether its a fatal error</returns> public static bool InitAR(Assembly asm) { if (s_configReader == null) { s_configReader = DatabaseConfiguration.GetARConfiguration(DBType, ConnectionString); if (s_configReader == null) { throw new Exception("Invalid Database Type: " + DBType); } } s_config = new XmlConfigurationSource(s_configReader); NHibernate.Cfg.Environment.UseReflectionOptimizer = true; ActiveRecordStarter.Initialize(asm, s_config); if (!IsConnected) { throw new Exception(string.Format("Failed to connect to Database.")); } s_dialect = Dialect.GetDialect(Config.Properties) ?? Dialect.GetDialect(); return true; }
public void Can_initialize_and_create_schema() { var configurationSource = new XmlConfigurationSource("ActiveRecord.cfg.xml"); ActiveRecordStarter.Initialize(typeof(Customer).Assembly, configurationSource); ActiveRecordStarter.CreateSchema(); }
/// <summary> /// Mains the specified args. /// </summary> /// <param name="args">The args.</param> public static void Main(string[] args) { string option; if (args.Length == 0) { Console.WriteLine("Please specify a valid option..."); Console.WriteLine("Valid parameter values are: -update|-bootstrap|-tests [-show_workflow]"); option = Console.ReadLine(); } else { option = args[0]; } Console.WriteLine("Initializing framework..."); var source = new XmlConfigurationSource(@"SchemaConfig.xml"); RedCelularActiveRecordBase<Product>.Initialize(source); __sessionScope = new SessionScope(); switch (option) { case "-update": UpdateSchema(); break; case "-bootstrap": BootstrapDatabase(); break; case "-fill": // The database needs to be already created (bootstrap) FillDatabase(); break; case "-tests": PrepareTestsDatabase(); break; default: Console.WriteLine("Valid parameter values are: -update|-bootstrap|-tests [-show_workflow]"); Console.ReadKey(); return; } __sessionScope.Flush(); }
private void AddSearchProperties(XmlConfigurationSource configSource) { searchConfig = new MutableConfiguration[3]; searchConfig[0] = new MutableConfiguration("hibernate.search.default.directory_provider", "NHibernate.Search.Storage.FSDirectoryProvider, NHibernate.Search"); searchConfig[1] = new MutableConfiguration("hibernate.search.default.indexBase", "~/index"); searchConfig[2] = new MutableConfiguration("hibernate.search.analyzer", "Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"); var cfg = configSource.GetConfiguration(typeof(ActiveRecordBase)); cfg.Children.AddRange(searchConfig); }
private static void AssertConfig(string xmlConfig, Type webinfotype, Type sessionFactoryHolderType, bool isDebug, bool pluralize, bool verifyModelsAgainstDBSchema, DefaultFlushType defaultFlushType, bool searchable) { StringReader sr = new StringReader(xmlConfig); XmlConfigurationSource c = new XmlConfigurationSource(sr); if (null != webinfotype) { Assert.IsTrue(c.ThreadScopeInfoImplementation == webinfotype, "Expected {0}, Got {1}", webinfotype, c.ThreadScopeInfoImplementation); } if (null != sessionFactoryHolderType) { Assert.IsTrue(c.SessionFactoryHolderImplementation == sessionFactoryHolderType, "Expected {0}, Got {1}", sessionFactoryHolderType, c.SessionFactoryHolderImplementation); } Assert.IsTrue(c.Debug == isDebug); Assert.IsTrue(c.PluralizeTableNames == pluralize); Assert.IsTrue(c.VerifyModelsAgainstDBSchema == verifyModelsAgainstDBSchema); Assert.IsTrue(c.DefaultFlushType == defaultFlushType); Assert.IsTrue(c.Searchable == searchable); }
public void TestFixtureSetUp() { var configurationSource = new XmlConfigurationSource("ActiveRecord.cfg.xml"); ActiveRecordStarter.ResetInitializationFlag(); ActiveRecordStarter.Initialize(typeof(Customer).Assembly, configurationSource); }