private void TryLoadFile() { string fileName = FileLocations.HistoryFullFileName; if (!string.IsNullOrEmpty(fileName)) { Logging.InfoFormat("Loading History from: {0}", fileName); if (File.Exists(fileName)) { LoadFile(); return; } } this.currentHistory = new HistoryByFavorite { Favorites = this.favorites }; }
private void LoadFile() { try { fileLock.WaitOne(); var loadedHistory = Serialize.DeserializeXMLFromDisk(FileLocations.HistoryFullFileName, typeof(HistoryByFavorite)) as HistoryByFavorite; loadedHistory.Favorites = this.favorites; this.currentHistory = loadedHistory; } catch // fails also in case of history upgrade, we don't upgrade history file { this.currentHistory = new HistoryByFavorite { Favorites = this.favorites }; } finally { fileLock.ReleaseMutex(); } }
private void LoadFile() { try { fileLock.WaitOne(); var loadedHistory = Serialize.DeserializeXMLFromDisk(FileLocations.HistoryFullFileName, typeof(HistoryByFavorite)) as HistoryByFavorite; loadedHistory.Favorites = this.favorites; this.currentHistory = loadedHistory; } catch // fails also in case of history upgrade, we don't upgrade history file { this.currentHistory = new HistoryByFavorite{ Favorites = this.favorites}; } finally { fileLock.ReleaseMutex(); } }
private void TryToRecoverHistoryFile() { try { this.fileLock.WaitOne(); this.fileWatcher.StopObservation(); if (File.Exists(Path.Combine(AssemblyInfo.DirectoryConfigFiles, FILENAME))) File.Delete(Path.Combine(AssemblyInfo.DirectoryConfigFiles, FILENAME)); this._currentHistory = new HistoryByFavorite(); } catch (Exception ex1) { Log.Error("Try to recover History file failed.", ex1); } finally { this.fileLock.ReleaseMutex(); this.fileWatcher.StartObservation(); } }
private void LoadFile() { this.fileLock.WaitOne(); Log.Debug("Deserializing history file."); this._currentHistory = Serialize.DeserializeXmlFromDisk(Path.Combine(AssemblyInfo.DirectoryConfigFiles, FILENAME), typeof(HistoryByFavorite)) as HistoryByFavorite; this.fileLock.ReleaseMutex(); }