public AudioBooksDbContainerSqLite() { ExecuteWithLock executeWithLockDelegate = AudioBooksDbContainerSQLiteConfig.ExecuteWithLockDelegate; _audioBooks = new Lazy <AudioBookSet>(() => { var needVacuum = _config.LastAudioBooksVacuum.AddDays(3) < DateTime.Now; var result = new AudioBookSet(_config.AudioBooksFilePath, executeWithLockDelegate, needVacuum); if (needVacuum) { executeWithLockDelegate(() => { _config.LastAudioBooksVacuum = DateTime.Now; _config.Save(); }); } return(result); }, true); _replacementStringSet = new Lazy <ReplacementStringSet>( () => new ReplacementStringSet(_config.ProcessingSettingsFilePath, executeWithLockDelegate), true); _userDataSet = new Lazy <UserDataSet>( () => new UserDataSet(_config.UserDataFilePath, executeWithLockDelegate), true); _binaryDataSet = new Lazy <BinaryDataSet>( () => new BinaryDataSet(_config.BinaryDataFilePath, executeWithLockDelegate), true); }
public void Import(string dbFilePath) { using (var audioBookSet = new AudioBookSet(dbFilePath, ExecuteWithLockDelegate, true)) { var groups = audioBookSet.GetRecordGroupsAll(); var records = audioBookSet.GetRecordsAll(); var existedGroups = new HashSet <string>(GetRecordGroupsAll().Select(item => item.Key)); var existedRecords = new HashSet <string>(GetRecordsAll().Select(item => item.Key)); var newGroups = groups.Where(group => !existedGroups.Contains(group.Key)); var newRecords = records.Where(record => !existedRecords.Contains(record.Key)); foreach (var audioBookGroup in newGroups) { AddRecordGroup(audioBookGroup); } foreach (var newRecord in newRecords) { AddRecord(newRecord); } } }
public void SaveChanges() { AudioBookSet.SaveAudioBooks(); AudioBookGroupSet.SaveAudioBookGroups(); BinaryDataSet.SaveBinaryData(); }