protected void Application_Start() { try { _logger.Info("App is starting..."); // AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); // DB Database.SetInitializer(new CreateDatabaseIfNotExists<DataModelContext>()); var ctx = new DataModelContext(); try { _logger.Info("Database inited. Version: {0}", ctx.GetDbVersion()); _logger.Info("Transactions count: {0}", this.Application["TransactionsCount"] = ctx.GetTransactionsCount()); } finally { ctx.Dispose(); } // StatsExample.ValidPeriod = Settings.Default.ExampleValidPeriod; // _logger.Info("App started."); } catch(Exception ex) { _logger.Error(ex); throw; } }
public static bool Start() { try { // DB init _logger.Info("Database initialization started..."); Database.SetInitializer(new MigrateDatabaseToLatestVersion<DataModelContext, Configuration>()); var ctx = new DataModelContext(); try { _logger.Info("Database inited. Version: {0}", ctx.GetDbVersion()); _logger.Info("Transactions count: {0}", ctx.GetTransactionsCount()); } finally { ctx.Dispose(); } // StatsExample.ValidPeriod = Settings.Default.ExampleValidPeriod; // Start WCF hosts StartHosts(); // Start schedulers StartSchedulers(); // PricesProvider.Start(); OrderManager.Start(); // return true; } catch(Exception ex) { _logger.Info(string.Format("Error while starting server: {0}", ex)); // Stop(); // return false; } }