private void OnResetDatabase() { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(GUILocalizeStrings.Get(927)); // Warning dlgYesNo.SetLine(1, GUILocalizeStrings.Get(300026)); //Are you sure... dlgYesNo.DoModal(GetID); if (dlgYesNo.IsConfirmed) { string database = Config.GetFile(Config.Dir.Database, "PictureDatabase.db3"); if (File.Exists(database)) { PictureDatabase.Dispose(); try { File.Delete(database); } catch (Exception ex) { Log.Error("GUISettingsPictures: OnResetDatabase {0}", ex.Message); } finally { PictureDatabase.ReOpen(); } } } } }
private static void DisposeDBs() { string dbPath = FolderSettings.DatabaseName; bool isRemotePath = (!string.IsNullOrEmpty(dbPath) && PathIsNetworkPath(dbPath)); if (isRemotePath) { Log.Info("Settings: disposing FolderDatabase3 sqllite database."); FolderSettings.Dispose(); } dbPath = PictureDatabase.DatabaseName; isRemotePath = (!string.IsNullOrEmpty(dbPath) && PathIsNetworkPath(dbPath)); if (isRemotePath) { Log.Info("Settings: disposing PictureDatabase sqllite database."); PictureDatabase.Dispose(); } dbPath = MediaPortal.Video.Database.VideoDatabase.DatabaseName; isRemotePath = (!string.IsNullOrEmpty(dbPath) && PathIsNetworkPath(dbPath)); if (isRemotePath) { Log.Info("Settings: disposing VideoDatabaseV5.db3 sqllite database."); MediaPortal.Video.Database.VideoDatabase.Dispose(); } dbPath = MediaPortal.Music.Database.MusicDatabase.Instance.DatabaseName; isRemotePath = (!string.IsNullOrEmpty(dbPath) && PathIsNetworkPath(dbPath)); if (isRemotePath) { Log.Info("Settings: disposing MusicDatabase db3 sqllite database."); MediaPortal.Music.Database.MusicDatabase.Dispose(); } }
public static void RestartMP() { bool hideTaskBar = false; using (Settings xmlreader = new MPSettings()) { hideTaskBar = xmlreader.GetValueAsBool("general", "hidetaskbar", false); } if (hideTaskBar) { Win32API.EnableStartBar(true); Win32API.ShowStartBar(true); } Log.Info("argustv: OnRestart - prepare for restart!"); File.Delete(Config.GetFile(Config.Dir.Config, "mediaportal.running")); Log.Info("argustv: OnRestart - saving settings..."); Settings.SaveCache(); Log.Info("argustv: disposing databases."); FolderSettings.Dispose(); PictureDatabase.Dispose(); VideoDatabase.Dispose(); MusicDatabase.Dispose(); VolumeHandler.Dispose(); System.Diagnostics.Process restartScript = new System.Diagnostics.Process(); restartScript.EnableRaisingEvents = false; restartScript.StartInfo.WorkingDirectory = Config.GetFolder(Config.Dir.Base); restartScript.StartInfo.FileName = Config.GetFile(Config.Dir.Base, @"restart.vbs"); Log.Debug("argustv: OnRestart - executing script {0}", restartScript.StartInfo.FileName); restartScript.Start(); try { // Maybe the scripting host is not available therefore do not wait infinitely. if (!restartScript.HasExited) { restartScript.WaitForExit(); } } catch (Exception ex) { Log.Error("argustv: OnRestart - WaitForExit: {0}", ex.Message); } }
/// <summary> /// /// </summary> private bool ClearDatabase() { string database = Config.GetFile(Config.Dir.Database, PictureDatabase.DatabaseName); if (File.Exists(database)) { PictureDatabase.Dispose(); try { File.Delete(database); } catch (Exception) { return(false); } finally { PictureDatabase.ReOpen(); } } return(true); }