Ejemplo n.º 1
0
        /// <summary>
        /// Creates a Song object reading its data from the file's ID3 tags and adds it to the database if it is not already present.
        /// </summary>
        /// <param name="filename">Path to any mp3 file. Other types of files are not rejected if a valid ID3 tag is found within them.</param>
        public Song CreateFromFile(string filename)
        {
            Song song = (this.UseNewStandard) ? this.CreateFromNewId3Standard(filename) : this.CreateFromOldId3Standard(filename);

            if (song != null)
            {
                int?duration = song.Duration;
                song.Format   = this.CreateFromAudioFrameHeader(filename, ref duration);
                song.Duration = duration;
                database.SaveChanges();
                return(song);
            }
            else
            {
                song = this.CreateFromWaveTagger(filename);
            }

            if (song == null)
            {
                Song zeroInfoSong = database.Song.FindByName(GuessSongName(filename));
                zeroInfoSong.Filename = filename;

                return(zeroInfoSong);
            }

            return(song);
        }
Ejemplo n.º 2
0
 private void SaveIntoDatabase() //non qua, è un metodo generale, non riferito esclusivamente a echomanager
 {
     try
     {
         database.SaveChanges();
     }
     catch (System.Data.UpdateException ue)
     {
         database.DeleteObject(ue.StateEntries[0].Entity);
         return;
     }
 }