private static void ReadLogicalFolderItems(SQLiteConnection conn, VolumeDatabase mem) { string txt = "SELECT * FROM [LFoldMap]"; using (SQLiteCommand cmd = new SQLiteCommand(txt, conn)) { using (SQLiteDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { int lFoldId = rdr.GetInt32(1); int iidId = rdr.GetInt32(2); int typeId = rdr.GetInt16(3); LogicalFolder lfold = _lfoldHash[lFoldId] as LogicalFolder; ItemInDatabase iid = null; switch (typeId) { case 1: // folder iid = _foldHash[iidId] as ItemInDatabase; break; case 2: // file iid = _fileHash[iidId] as ItemInDatabase; break; case 3: // disc. brute it. foreach (var discInDatabase in mem.GetDiscs()) { if (-discInDatabase.DbId == iidId) { iid = discInDatabase as ItemInDatabase; break; } } break; } lfold.AddItem(iid); // TODO make sure the two-way mapping is set! } } } }
internal void AddItemAsDvd(IFolder folderInDatabase) { LogicalFolder newFolder = new LogicalFolder((folderInDatabase as ItemInDatabase).Name, LogicalFolderType.Disc, 0, 0); AddFolder(newFolder); foreach (FileInDatabase file in folderInDatabase.Files) { newFolder.AddItem(file); } foreach (IFolder folder in folderInDatabase.Folders) { if (folder is FolderInDatabase) { // nie dodajemy CompressedFile newFolder.AddItemAsFolder(folder, null); } } }
internal void AddItemAsFolder(IFolder folderInDatabase, string asName) { LogicalFolder newFolder = new LogicalFolder(folderType, asName != null ? asName : (folderInDatabase as ItemInDatabase).Name); AddFolder(newFolder); foreach (FileInDatabase file in folderInDatabase.Files) { newFolder.AddItem(file); } foreach (IFolder folder in folderInDatabase.Folders) { if (folder is FolderInDatabase) { // nie dodajemy CompressedFile newFolder.AddItemAsFolder(folder, null); } } }