public void RefreshMembers() { if (Condition == null) { return; } //Console.WriteLine ("Refreshing smart playlist {0} with condition {1}", Source.Name, Condition); // Delete existing tracks Globals.Library.Db.Execute(String.Format( "DELETE FROM PlaylistEntries WHERE PlaylistId = {0}", Source.Id )); // Add matching tracks Globals.Library.Db.Execute(String.Format( @"INSERT INTO PlaylistEntries SELECT NULL as EntryId, {0} as PlaylistId, TrackId FROM Tracks {1} {2}", Source.Id, PrependCondition("WHERE"), OrderAndLimit )); Source.ClearTracks(); // Load the new tracks in IDataReader reader = Globals.Library.Db.Query(String.Format( @"SELECT TrackID FROM PlaylistEntries WHERE PlaylistID = '{0}'", Source.Id )); while (reader.Read()) { Source.AddTrack(Globals.Library.Tracks[Convert.ToInt32(reader[0])] as TrackInfo); } reader.Dispose(); }
private void AddToPlaylist(PlaylistSource playlist) { if (!FilterFocused) { var track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo; if (chosen_from_playing_track_submenu && track != null) { playlist.AddTrack(track); } else { playlist.AddSelectedTracks(ActiveSource); } } else { playlist.AddAllTracks(ActiveSource); } }