public void ChangeLocations() { try { var dataContext = new MusicEntities1(); var songs = dataContext.SONG; foreach (SONG song in songs) { Console.WriteLine(song.LOCATION); song.LOCATION = song.LOCATION.ToLower(); if (song.LOCATION.IndexOf("d:") > -1) { song.LOCATION = song.LOCATION.Replace("d:", "c:"); dataContext.SaveChanges(); } if (song.LOCATION.IndexOf("e:") > -1) { song.LOCATION = song.LOCATION.Replace("e:", "c:"); dataContext.SaveChanges(); } if (song.LOCATION.IndexOf("f:") > -1) { song.LOCATION = song.LOCATION.Replace("f:", "c:"); dataContext.SaveChanges(); } } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } }
public void RatedSongs() { try { var dataContext = new MusicEntities1(); var songs = dataContext.SONG; foreach (SONG song in songs) { int inserts = 0; inserts = inserts + song.RATING; using (SqlConnection con = new SqlConnection(Settings.Default.ConnectionString)) { con.Open(); String sql = "INSERT INTO Song_Rated (Song_Id) VALUES (@SongId)"; SqlCommand command = new SqlCommand(sql, con); command.Parameters.AddWithValue("@SongId", song.ID); for (int i = 1; i < inserts; i++) { command.ExecuteNonQuery(); } } } } catch (Exception ex) { testContextInstance.WriteLine(ex.Message); testContextInstance.WriteLine(ex.StackTrace); throw; } }
public void TestUploadedSongs() { try { List <int> songIds = new List <int>(); IEnumerable <String> uploadedSongs = FtpManager.List(); foreach (String uploadedSong in uploadedSongs) { String songIdString = uploadedSong.Substring(5); songIdString = songIdString.Remove(songIdString.IndexOf(".")); int songId = Convert.ToInt32(songIdString); songIds.Add(songId); } var dataContext = new MusicEntities1(); var songs = from row in dataContext.SONG where (row.UPLOADED == true) select row; foreach (SONG song in songs) { if (!songIds.Contains(song.ID)) { Console.WriteLine(song.TITLE); song.UPLOADED = false; } } dataContext.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); throw; } }
public void DeleteUploadedSongs() { var azureService = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey); using (var dataContext = new MusicEntities1()) { var uploadedSongs = from song in dataContext.SONG where song.UPLOADED select song; foreach (var song in uploadedSongs) { var key = song.ID + ".mp3"; try { azureService.DeleteBlob("public", key); } catch (Exception ex) { if (ex.Message.IndexOf("The specified blob does not exist") == -1) { throw; } } song.UPLOADED = false; } dataContext.SaveChanges(); } }
public void SetUploadedAttributeOnSongs() { AzureService azureService = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey); CloudBlobClient blobClient = azureService.GetCloudBlobContainer(); CloudBlobContainer container = blobClient.GetContainerReference(containerName); IEnumerable <IListBlobItem> blobs = container.ListBlobs(); foreach (var blob in blobs) { testContextInstance.WriteLine("{0}", blob.Uri); String[] s = blob.Uri.ToString().Split(new char[] { '/' }); String key = s[s.Length - 1]; s = key.Split(new char[] { '.' }); key = s[0]; testContextInstance.WriteLine("{0}", key); try { int id = Convert.ToInt32(key); using (var dataContext = new MusicEntities1()) { var songs = from song in dataContext.SONG where song.ID == id select song; foreach (var s1 in songs) { s1.UPLOADED = true; dataContext.SaveChanges(); } } } catch (Exception ex) { testContextInstance.WriteLine("{0} {1}", ex.Message, ex.StackTrace); } } }
public void DeleteDuplicateSongs() { var dataContext = new MusicEntities1(); // Delete songs with the same hash code IQueryable <SONG> songQuery = from s in dataContext.SONG orderby s.HASH where s.HASH != null select s; SONG previousSong = null; foreach (SONG song in songQuery) { if ((previousSong != null) && (previousSong.HASH == song.HASH)) { testContextInstance.WriteLine("{0} : {1}", previousSong.LOCATION, song.LOCATION); if (previousSong.ID < song.ID) { dataContext.SONG.Remove(previousSong); dataContext.SaveChanges(); } else { dataContext.SONG.Remove(song); dataContext.SaveChanges(); } } previousSong = song; } // Delete songs with the same location songQuery = from s in dataContext.SONG orderby s.LOCATION where s.LOCATION != null select s; previousSong = null; foreach (SONG song in songQuery) { if ((previousSong != null) && (previousSong.LOCATION == song.LOCATION)) { testContextInstance.WriteLine("{0} : {1}", previousSong.LOCATION, song.LOCATION); if (previousSong.ID < song.ID) { dataContext.SONG.Remove(previousSong); dataContext.SaveChanges(); } else { dataContext.SONG.Remove(song); dataContext.SaveChanges(); } } previousSong = song; } dataContext.SaveChanges(); }
public void UpdateRecentSongs() { using (var dataContext = new MusicEntities1()) { var songs = from song in dataContext.SONG where song.ID > 53520 select song; foreach (var s in songs) { testContextInstance.WriteLine("{0} : {1} : {2}", s.ARTIST, s.TITLE, s.UPLOADED); } } }
public void Add(string details) { var jobLog = new JobLog(); jobLog.DateRun = DateTime.Now; jobLog.Details = details; using (var context = new MusicEntities1()) { context.JobLog.Add(jobLog); context.SaveChanges(); } }
public void SyncSongTags() { using (var dataContext = new MusicEntities1()) { IQueryable <SONG> songs = from s in dataContext.SONG orderby s.HASH where s.HASH != null select s; foreach (var song in songs) { } } }
public void GetSongsSimple() { using (var context = new MusicEntities1()) { var results = from song in context.SONG where song.ARTIST.IndexOf("Lucius") > -1 select song; foreach (var song in results) { testContextInstance.WriteLine("{0}", song.LOCATION); } } }
public void UpdateSongs() { String container = "songs"; var uploadProcessor = new UploadProcessor(container, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey); var azureService = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey); var musicDao = new MusicDao(Settings.Default.ConnectionString, null, uploadProcessor, azureService); musicDao.OnNewSong += Log; var dataContext = new MusicEntities1(); IQueryable <SONG> songQuery = from s in dataContext.SONG orderby s.HASH where s.HASH != null select s; foreach (SONG song in songQuery) { try { byte[] hash = MusicDao.GenerateHashCode(song.LOCATION); bool hashSame = true; for (int i = 0; i < hash.Length; i++) { if (hash[i] != song.HASH.ToArray()[i]) { hashSame = false; break; } } if (!hashSame) { testContextInstance.WriteLine("{0}", song.LOCATION); musicDao.ProcessFile(song.LOCATION); dataContext.SONG.Remove(song); } dataContext.SaveChanges(); } catch (Exception ex) { testContextInstance.WriteLine("{0}", ex.Message); testContextInstance.WriteLine("{0}", song.LOCATION); } } // uploadProcessor.EndProcess(); }
public void AddIdsToFilenames() { using (var context = new MusicEntities1()) { var songs = from song in context.SONG where song.GDRIVE == null orderby song.ID descending select song; var songsArray = songs.ToArray().Take(200); foreach (var song in songsArray) { int id = song.GetFilenameId(); testContextInstance.WriteLine("{0}", song.LOCATION); } } }
public void SetGDriveUrl(Google.Apis.Drive.v2.Data.File file) { testContextInstance.WriteLine("{0}", file.OriginalFilename); using (var context = new MusicEntities1()) { var songs = from s in context.SONG where ((s.LOCATION.Contains(file.OriginalFilename)) && (s.FILESIZE == file.FileSize)) select s; var songArray = songs.ToArray(); foreach (var song in songArray) { song.GDRIVE = file.WebContentLink; context.SaveChanges(); testContextInstance.WriteLine("Updated: {0} {1}", song.LOCATION, file.WebContentLink); } } }
public JobLog GetLatest() { JobLog jobLog = null; using (var context = new MusicEntities1()) { var jobLogs = from j in context.JobLog orderby j.DateRun select j; foreach (var currentJobLog in jobLogs) { jobLog = currentJobLog; } } return(jobLog); }
public void DeleteMissingFiles() { var dataContext = new MusicEntities1(); var songs = dataContext.SONG; foreach (SONG song in songs) { try { if (!File.Exists(song.LOCATION)) { testContextInstance.WriteLine(song.LOCATION); dataContext.SONG.Remove(song); dataContext.SaveChanges(); } else { // TODO: Compare tags in db against file byte[] hash = MusicDao.GenerateHashCode(song.LOCATION); bool same = true; for (int i = 0; i < hash.Length; i++) { if (hash[i] != song.HASH.ToArray()[i]) { same = false; } } if (!same) { testContextInstance.WriteLine(song.LOCATION); dataContext.SONG.Remove(song); dataContext.SaveChanges(); } } } catch (Exception e) { testContextInstance.WriteLine(e.Message); } } dataContext.SaveChanges(); }
public void UpdateSongMetadata() { try { var azureService = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey); var uploadProcessor = new UploadProcessor(Settings.Default.AzureContainerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey); var musicDao = new MusicDao(Settings.Default.ConnectionString, null, uploadProcessor, azureService); var dataContext = new MusicEntities1(); var songs = dataContext.SONG; foreach (SONG song in songs) { try { if (song.LOCATION.ToUpper().StartsWith("C:")) { song.LOCATION = song.LOCATION.Remove(0, 2); song.LOCATION = "D:" + song.LOCATION; } if (File.Exists(song.LOCATION)) { String title, artist, album, genre; musicDao.GetSongMetadata(song.LOCATION, out title, out artist, out album, out genre); if ((String.IsNullOrEmpty(genre)) && (genre != song.GENRE)) { song.GENRE = genre; } } } catch (Exception e) { testContextInstance.WriteLine(song.LOCATION); } } dataContext.SaveChanges(); } catch (Exception ex) { testContextInstance.WriteLine(ex.Message); testContextInstance.WriteLine(ex.StackTrace); } }
public SONG GetSQLData(Google.Apis.Drive.v2.Data.File file) { if ((file.OriginalFilename == null) || (file.OriginalFilename.IndexOf(".mp3") == -1)) { return(null); } using (var context = new MusicEntities1()) { var songs = from s in context.SONG where ((s.FILESIZE == file.FileSize) && (s.FILESIZE > 0)) select s; var songArray = songs.ToArray(); if (songArray.Length > 0) { return(songArray[0]); } } return(null); }
public static void PopulateArtists() { var artists = new Dictionary <string, int>(); var artistRepository = new ArtistRepository(); artistRepository.Reset(); using (var context = new MusicEntities1()) { var songs = from song in context.SONG where song.GDRIVE != null orderby song.ARTIST select song; foreach (var song in songs) { if (!artists.ContainsKey(song.ARTIST)) { artists[song.ARTIST] = 1; } else { artists[song.ARTIST]++; } } foreach (KeyValuePair <string, int> kvp in artists) { try { artistRepository.Set(kvp.Key, kvp.Value.ToString()); } catch (Exception ex) { Debug.WriteLine("{0}", ex.Message); } } } }
public static void SetGDriveUrl(Google.Apis.Drive.v2.Data.File file) { try { if ((file.OriginalFilename == null) || (file.OriginalFilename.IndexOf(".mp3") == -1)) { return; } Debug.WriteLine("Processing: " + file.OriginalFilename); using (var context = new MusicEntities1()) { bool found = false; var songs = from s in context.SONG // where ((file.OriginalFilename.Contains(s.LOCATION)) && (s.FILESIZE == file.FileSize)) where ((s.FILESIZE == file.FileSize) && (s.FILESIZE > 0)) select s; var songArray = songs.ToArray(); foreach (var song in songArray) { if (song.GDRIVE == null) { song.GDRIVE = file.WebContentLink; context.SaveChanges(); Debug.WriteLine(string.Format("Updated: {0} {1}", file.OriginalFilename, file.WebContentLink)); } found = true; } if (!found) { Debug.WriteLine(string.Format("Not found: {0} {1}", file.OriginalFilename, file.FileSize)); } } } catch (Exception ex) { Debug.WriteLine(string.Format("Error: {0}", ex.Message)); } }
public void GenerateHashCodes() { var dataContext = new MusicEntities1(); IQueryable <SONG> songQuery = from s in dataContext.SONG select s; foreach (SONG song in songQuery) { try { if ((File.Exists(song.LOCATION)) && (song.HASH == null)) { byte[] hash = MusicDao.GenerateHashCode(song.LOCATION); song.HASH = hash; dataContext.SaveChanges(); } } catch (Exception e) { testContextInstance.WriteLine(e.Message); } } }
public void UploadSongs() { string targetLocation = "Natasha Kmeto"; var uploadProcessor = new UploadProcessor(containerName, Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey); uploadProcessor.OnError += (s) => { testContextInstance.WriteLine("Error: {0}", s); }; uploadProcessor.OnStatus += (s) => { testContextInstance.WriteLine("{0}", s); }; using (var dataContext = new MusicEntities1()) { var songs = from song in dataContext.SONG where song.LOCATION.IndexOf(targetLocation) > -1 select song; songs = from song in songs where !song.UPLOADED select song; foreach (var song in songs) { // Change drive to C: if (song.LOCATION.ToLower()[0] != 'c') { song.LOCATION = song.LOCATION.Substring(1); song.LOCATION = "c" + song.LOCATION; } testContextInstance.WriteLine("{0}", song.LOCATION); var fileinfo = new Tuple <string, string>(song.LOCATION, song.ID.ToString()); if (uploadProcessor.UploadFile(fileinfo)) { song.UPLOADED = true; } } dataContext.SaveChanges(); } }
public void PopulateSegments() { var segments = new List <string>(); var segmentRepository = new SegmentRepository(); using (var context = new MusicEntities1()) { var songs = from song in context.SONG where song.GDRIVE != null orderby song.LOCATION select song; foreach (var song in songs) { try { int start = song.LOCATION.IndexOf("\\Music\\") + 7; if (start > -1) { int end = song.LOCATION.LastIndexOf('\\'); string segment = song.LOCATION.Substring(start, end - start); if (!segments.Contains(segment)) { string rowKey = segment.Replace('\\', '_'); segmentRepository.Set(song.GENRE, rowKey, segment); segments.Add(segment); } } } catch (Exception ex) { testContextInstance.WriteLine("{0}", ex.Message); } } } }
public void SetGDriveUrls() { string folder = @"E:\Gdrive\Music"; string musicFolder = @"E:\Gdrive\Music"; var musicDao = GetMusicDao(); var allSongFiles = musicDao.GetSongFiles(folder); var musicFiles = from musicFile in allSongFiles where musicFile.IsMp3File() select musicFile; var songsWithDbInfo = from song in musicFiles select musicDao.GetSongByLocation(song.LOCATION); var existingFiles = from song in songsWithDbInfo where song != null select song; existingFiles = from song in existingFiles where song.GDRIVE == null select song; var gDriveService = new GDriveService(); foreach (var song in existingFiles) { char[] c = { '\\' }; string[] s = song.LOCATION.Split(c); string filename = s[s.Length - 1]; string search = string.Format("title='{0}'", filename); var files = gDriveService.GetFiles(search); foreach (var file in files) { testContextInstance.WriteLine("{0}", file.WebContentLink); try { FileInfo fileInfo = null; if (files.Count > 1) { int start = song.LOCATION.IndexOf("\\Music\\"); string adjustedFilename = musicFolder + song.LOCATION.Substring(start + 6); fileInfo = new FileInfo(adjustedFilename); } if ((fileInfo == null) || (fileInfo.Length == file.FileSize)) { testContextInstance.WriteLine("Found"); using (var context = new MusicEntities1()) { var currentSong = context.SONG.Single(s1 => s1.ID == song.ID); currentSong.GDRIVE = file.WebContentLink; context.SaveChanges(); testContextInstance.WriteLine("{0} {1}", song.LOCATION, file.DownloadUrl); } } } catch (Exception ex) { testContextInstance.WriteLine("Error: {0} {1}", filename, ex.Message); } } } }
public void UpdateTags(string connectionString, string musicDrive) { int songId = 0; int batchSize = 100; while (true) { bool songTaken = false; using (var dataContext = new MusicEntities1()) { IQueryable <SONG> songs = dataContext.SONG.Where(s => s.ID > songId && s.LOCATION.ToLower().Contains(".mp3")).OrderBy(s => s.ID).Take(batchSize); foreach (SONG song in songs) { songTaken = true; try { FileInfo fileInfo = new FileInfo(song.LOCATION); string directoryRoot = Directory.GetDirectoryRoot(song.LOCATION); string filename = song.LOCATION; if (directoryRoot.ToLower().IndexOf(musicDrive) != 0) { filename = filename.Substring(1); filename = musicDrive + filename; } string genre = null; UltraID3 ultraID3 = new UltraID3(); ultraID3.Read(filename); genre = ultraID3.Genre; IID3v2 iD3v2 = ID3v2Helper.CreateID3v2(filename); if (string.IsNullOrWhiteSpace(genre)) { genre = iD3v2.Genre; } IID3v1 iD3v1 = ID3v1Helper.CreateID3v1(filename); if (string.IsNullOrWhiteSpace(genre)) { genre = GenreHelper.GenreByIndex[iD3v1.GenreIndex]; } ID3v2Tag id3v2Tag = ultraID3.ID3v2Tag; if ((genre != song.GENRE) && (!string.IsNullOrWhiteSpace(song.GENRE)) && (song.GENRE.ToLower().IndexOf("blues") == -1) && (song.GENRE.ToLower().IndexOf("other") == -1) && (song.GENRE.ToLower().IndexOf("unknown") == -1) ) { Console.WriteLine(String.Format("{0}, DB genre: {1}, Disk genre: {2}", filename, song.GENRE, genre)); try { ultraID3.Genre = song.GENRE; } catch (Exception e1) { Console.WriteLine(String.Format("Exception, song: {0}, {1}, {2}", song.LOCATION, e1.Message, e1.StackTrace)); } id3v2Tag.Genre = song.GENRE; ultraID3.Write(); } } catch (System.IO.DirectoryNotFoundException) { Console.WriteLine(String.Format("Exception, file not found, song: {0}", song.LOCATION)); } catch (System.IO.FileNotFoundException) { Console.WriteLine(String.Format("Exception, file not found, song: {0}", song.LOCATION)); } catch (Exception ex) { Console.WriteLine(String.Format("Exception, song: {0}, {1}, {2}", song.LOCATION, ex.Message, ex.StackTrace)); } songId = song.ID; } } if (!songTaken) { break; } } }
public void MissingSongs() { int songId = 0; int batchSize = 100; while (true) { bool songTaken = false; using (var dataContext = new MusicEntities1()) { IQueryable <SONG> songs = dataContext.SONG.Where(s => s.ID > songId).OrderBy(s => s.ID).Take(batchSize); foreach (SONG song in songs) { songTaken = true; try { FileInfo fileInfo = new FileInfo(song.LOCATION); string directoryRoot = Directory.GetDirectoryRoot(song.LOCATION); string filename = song.LOCATION; if (directoryRoot.ToLower().IndexOf("e:\\") == -1) { filename = filename.Substring(1); filename = "e" + filename; } if (!File.Exists(filename)) { testContextInstance.WriteLine("File not found: {0}", filename); using (var dataContext1 = new MusicEntities1()) { testContextInstance.WriteLine("Deleting SONG {0}", song.ID); SONG missingSong = dataContext1.SONG.Where(s => s.ID == song.ID).FirstOrDefault(); missingSong.LOCATION = null; dataContext1.SONG.Remove(missingSong); dataContext1.SaveChanges(); } } } catch (System.IO.DirectoryNotFoundException) { testContextInstance.WriteLine("Exception, file not found, song: {0}", song.LOCATION); } catch (System.IO.FileNotFoundException) { testContextInstance.WriteLine("Exception, file not found, song: {0}", song.LOCATION); } catch (Exception ex) { testContextInstance.WriteLine("Exception, song: {0}, {1}, {2} ", song.ID, ex.Message, ex.StackTrace); } songId = song.ID; } } if (!songTaken) { break; } } }
public void SyncTagsToFiles() { using (var dataContext = new MusicEntities1()) { IQueryable <SONG> songs = dataContext.SONG.OrderByDescending(s => s.UPDATED).Take(5000); SONG[] songArray = songs.ToArray(); foreach (SONG song in songArray) { try { if (Regex.IsMatch(song.LOCATION, ".mp3", RegexOptions.IgnoreCase)) { FileInfo fileInfo = new FileInfo(song.LOCATION); string directoryRoot = Directory.GetDirectoryRoot(song.LOCATION); string filename = song.LOCATION; if (directoryRoot.ToLower().IndexOf("e:\\") == -1) { filename = filename.Substring(1); filename = "e" + filename; } string genre = null; IID3v2 iD3v2 = ID3v2Helper.CreateID3v2(filename); genre = iD3v2.Genre; UltraID3 ultraID3 = new UltraID3(); ultraID3.Read(filename); if (string.IsNullOrWhiteSpace(genre)) { genre = ultraID3.Genre; } else if (ultraID3.Genre != genre) { // ultraID3.Genre = genre; } IID3v1 iD3v1 = ID3v1Helper.CreateID3v1(filename); if (Regex.IsMatch(genre, "(")) { genre = GenreHelper.GenreByIndex[iD3v1.GenreIndex]; } // ID3v2Tag id3v2Tag = ultraID3.ID3v2Tag; if ((genre != song.GENRE) && (!string.IsNullOrWhiteSpace(song.GENRE)) //&& (song.GENRE.ToLower().IndexOf("blues")==-1) //&& (song.GENRE.ToLower().IndexOf("other") == -1) //&& (song.GENRE.ToLower().IndexOf("unknown") == -1) ) { testContextInstance.WriteLine("{0}, DB genre: {1}, Disk genre: {2}", filename, song.GENRE, genre); try { ultraID3.Genre = song.GENRE; iD3v2.Genre = song.GENRE; } catch (Exception e1) { testContextInstance.WriteLine("Exception, song: {0}, {1}, {2}", song.LOCATION, e1.Message, e1.StackTrace); } iD3v2.Save(filename); ultraID3.Write(); } } } catch (System.IO.DirectoryNotFoundException) { testContextInstance.WriteLine("Exception, file not found, song: {0}", song.LOCATION); } catch (System.IO.FileNotFoundException) { testContextInstance.WriteLine("Exception, file not found, song: {0}", song.LOCATION); } catch (Exception ex) { testContextInstance.WriteLine("Exception, song: {0}, {1}, {2}", song.LOCATION, ex.Message, ex.StackTrace); } } } }
public void SyncTagsToDb() { using (var dataContext = new MusicEntities1()) { IQueryable <SONG> songs = from s in dataContext.SONG orderby s.ID select s; foreach (SONG song in songs) { try { if (Regex.IsMatch(song.LOCATION, ".mp3", RegexOptions.IgnoreCase)) { FileInfo fileInfo = new FileInfo(song.LOCATION); string directoryRoot = Directory.GetDirectoryRoot(song.LOCATION); string filename = song.LOCATION; if (directoryRoot.ToLower().IndexOf("e:\\") == -1) { filename = filename.Substring(1); filename = "e" + filename; } string genre = null; UltraID3 ultraID3 = new UltraID3(); ultraID3.Read(filename); genre = ultraID3.Genre; IID3v2 iD3v2 = ID3v2Helper.CreateID3v2(filename); if (string.IsNullOrWhiteSpace(genre)) { genre = iD3v2.Genre; } IID3v1 iD3v1 = ID3v1Helper.CreateID3v1(filename); if (string.IsNullOrWhiteSpace(genre)) { genre = GenreHelper.GenreByIndex[iD3v1.GenreIndex]; } ID3v2Tag id3v2Tag = ultraID3.ID3v2Tag; //if ((!string.IsNullOrEmpty(ultraID3.Genre)) && // (!string.IsNullOrEmpty(id3v2Tag.Genre)) && // (ultraID3.Genre != id3v2Tag.Genre) // ) //{ // testContextInstance.WriteLine("{0}, {1}", ultraID3.Genre, id3v2Tag.Genre); //} //genre = id3v2Tag.Genre; //if (string.IsNullOrWhiteSpace(genre)) //{ // genre = ultraID3.Genre; //} //if (!string.IsNullOrWhiteSpace(ultraID3.Genre)) //{ // genre = ultraID3.Genre; //} //if (string.IsNullOrWhiteSpace(genre)) //{ // genre = id3v2Tag.Genre; //} if ((genre != song.GENRE) && (!string.IsNullOrWhiteSpace(song.GENRE)) //&& (song.GENRE.ToLower().IndexOf("blues")==-1) //&& (song.GENRE.ToLower().IndexOf("other") == -1) //&& (song.GENRE.ToLower().IndexOf("unknown") == -1) ) { testContextInstance.WriteLine("{0}, DB genre: {1}, Disk genre: {2}", filename, song.GENRE, genre); try { if ((song.UPDATED > fileInfo.LastWriteTime) && (song.GENRE != "Other")) { id3v2Tag.Genre = song.GENRE; ultraID3.Write(); } else if (genre != "Other") { song.GENRE = genre; } } catch (Exception e1) { testContextInstance.WriteLine("Exception, song: {0}, {1}, {2}", song.LOCATION, e1.Message, e1.StackTrace); } } } } catch (System.IO.DirectoryNotFoundException) { testContextInstance.WriteLine("Exception, file not found, song: {0}", song.LOCATION); } catch (System.IO.FileNotFoundException) { testContextInstance.WriteLine("Exception, file not found, song: {0}", song.LOCATION); } catch (Exception ex) { testContextInstance.WriteLine("Exception, song: {0}, {1}, {2}", song.LOCATION, ex.Message, ex.StackTrace); } } dataContext.SaveChanges(); } }