private void RecursiveSearch(DirectoryInfo dir) { foreach (var fsinfo in dir.EnumerateFileSystemInfos()) { if (fsinfo is DirectoryInfo) { RecursiveSearch(fsinfo as DirectoryInfo); } else if (fsinfo is FileInfo) { var file = fsinfo as FileInfo; if (Extensions.Any(ext => file.Extension == ext)) { var aimpFile = new AimpFile { Name = file.Name }; var list = new List <string>(); list.Add(file.FullName.Substring(2)); try { Files.Add(aimpFile, list); } catch (ArgumentException) { Files[aimpFile].Add(file.FullName.Substring(2)); } } } } }
public void Run() { Result = new Dictionary <long, string>(); foreach (var dbEntry in LogicalFiles) { int workingIndex = 0; if (dbEntry.Value.Count > 1) { workingIndex = m_dbColFunc(dbEntry.Key, dbEntry.Value); // -1 - stahp, 0..n - wórk if (workingIndex == -1) { continue; } } AimpFile key = dbEntry.Key; IList <string> phyEntries; lookup: if (PhysicalFiles.TryGetValue(key, out phyEntries) == false) // No entries { var ret = m_fnfFunc(key, dbEntry.Value[workingIndex]); if (ret == "") { continue; } key.Name = ret; goto lookup; } else // 1+ entries { int workingPhyIndex = 0; if (phyEntries.Count > 1) { workingPhyIndex = m_phyColFunc(key, dbEntry.Value[workingIndex], phyEntries); if (workingPhyIndex == -1) { continue; } } if (key.PlaylistNo == -1) { Result[key.Id] = phyEntries[workingPhyIndex]; } else { Result[key.Id] = string.Join(":", phyEntries[workingPhyIndex], key.PlaylistNo); } Console.WriteLine("'{0}' -> '{1}'", dbEntry.Value[workingIndex].Length > 50 ? (dbEntry.Value[workingIndex].Substring(0, 50) + "...") : dbEntry.Value[workingIndex], phyEntries[workingPhyIndex].Length > 50 ? (phyEntries[workingPhyIndex].Substring(0, 50) + "...") : phyEntries[workingPhyIndex]); } } }
public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } AimpFile o = (AimpFile)obj; bool result = this.Name == o.Name; if (this.Id != 0 && o.Id != 0) { result &= this.Id == o.Id; } //if (Playlist == true) //result &= o.Playlist == true; return(result); }
public void RetrieveData(DirectoryInfo folder) { Files = new Dictionary <AimpFile, IList <string> >(); using (SQLiteCommand com = new SQLiteCommand(string.Format("SELECT ID, sName FROM MediaBase WHERE iDriveID = {0} AND sName LIKE '{1}%'", DiskId, folder.FullName.Substring(2)), m_conn)) { SQLiteDataReader reader = com.ExecuteReader(); while (reader.Read()) { AimpFile file = new AimpFile { Id = (long)reader["ID"], Name = (string)reader["sName"] }; int plsIndex = file.Name.LastIndexOf(':'); if (plsIndex != -1) { file.PlaylistNo = Convert.ToInt32(file.Name.Substring(plsIndex + 1)); file.Name = file.Name.Substring(0, plsIndex); } else { file.PlaylistNo = -1; } file.Name = Path.GetFileName(file.Name); var list = new List <string>(); list.Add((string)reader[1]); try { Files.Add(file, list); } catch (ArgumentException) // Same file exists twice { Files[file].Add((string)reader[1]); } } } }