private void App_Startup(object sender, StartupEventArgs e) { // Set the directory to use to store the local database AppDomain.CurrentDomain.SetData("DataDirectory", dataDir); // Check to see if the database exists already. If not, copy the template from the application directory. // Note that this DOES NOT replace an existing version, so any updates aren't copied (yet). if(!File.Exists(Path.Combine(dataDir, dbName))) { if (!Directory.Exists(dataDir)) { Directory.CreateDirectory(dataDir); } File.Copy(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dbName), Path.Combine(dataDir, dbName)); } if (e.Args.Length >= 1) { if (e.Args[0] == "/runnow") { // Update the Watchlist from Trakt and schedule recordings, but skip the UI (for scheduled tasks) bool success = false; SchedulerController scheduler = null; try { scheduler = new SchedulerController(); scheduler.Init(); scheduler.DoAutoUpdate(); success = true; } catch { } finally { if (scheduler != null) { scheduler.Dispose(); } } Shutdown(success ? 0 : 1); } } // Put up the main UI window new MainWindow().Show(); }
private void MainWindow_Load(object sender, RoutedEventArgs e) { Scheduler = new SchedulerController(); Scheduler.LogMessage += Scheduler_LogMessage; this.DataContext = Scheduler; try { Scheduler.Init(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Exception"); } }