private void InitAsync(object sender, ElapsedEventArgs args) { ISQLDatabase database; lock (_timer) { database = ServiceRegistration.Get <ISQLDatabase>(false); if (database == null) { return; } _timer.Close(); _timer.Dispose(); } using (var transaction = database.BeginTransaction()) if (transaction.Connection.GetCloneFactory(TVDB_NAME, out _dbProviderFactory, out _cloneConnection)) { EntityFrameworkHelper.AssureKnownFactory(_dbProviderFactory); // Register our factory to create new cloned connections ObjectContextManager.SetDbConnectionCreator(ClonedConnectionFactory); } IntegrationProviderHelper.Register(@"Plugins\SlimTv.Service", @"Plugins\SlimTv.Service\castle.config"); _tvServiceThread = new TvServiceThread(Environment.GetCommandLineArgs()[0]); _tvServiceThread.Start(); }
protected override void PrepareConnection(ITransaction transaction) { if (transaction.Connection.GetCloneFactory(TVDB_NAME, out _dbProviderFactory, out _cloneConnection)) { EntityFrameworkHelper.AssureKnownFactory(_dbProviderFactory); // Register our factory to create new cloned connections ObjectContextManager.SetDbConnectionCreator(ClonedConnectionFactory); } }
private void InitAsync(object sender, ElapsedEventArgs args) { ISQLDatabase database; lock (_timer) { database = ServiceRegistration.Get <ISQLDatabase>(false); if (database == null) { return; } _timer.Close(); _timer.Dispose(); } using (var transaction = database.BeginTransaction()) { // Prepare TV database if required. PrepareTvDatabase(transaction); #if !TVE3 if (transaction.Connection.GetCloneFactory(TVDB_NAME, out _dbProviderFactory, out _cloneConnection)) { EntityFrameworkHelper.AssureKnownFactory(_dbProviderFactory); // Register our factory to create new cloned connections ObjectContextManager.SetDbConnectionCreator(ClonedConnectionFactory); } #endif } // TODO: Get this from project config somehow #if TVE3 string servicename = "SlimTv.Service3"; #else string servicename = "SlimTv.Service35"; #endif IntegrationProviderHelper.Register(@"Plugins\" + servicename, "Plugins\\" + servicename + "\\castle.config"); var pm = GlobalServiceProvider.Instance.Get <IIntegrationProvider>().PathManager; // Needs to be done after the IntegrationProvider is registered, so the TVCORE folder is defined. PrepareProgramData(); _tvServiceThread = new TvServiceThread(Environment.GetCommandLineArgs()[0]); #if TVE3 InitializeGentle(); Start(); #else _tvServiceThread.Start(); #endif if (!_tvServiceThread.InitializedEvent.WaitOne(MAX_WAIT_MS)) { ServiceRegistration.Get <ILogger>().Error("SlimTvService: Failed to start TV service thread within {0} seconds.", MAX_WAIT_MS / 1000); } #if TVE3 InitializeTVE(); #endif // Handle events from TvEngine if (!RegisterEvents()) { ServiceRegistration.Get <ILogger>().Error("SlimTvService: Failed to register events. This happens only if startup failed. Stopping plugin now."); DeInit(); } }