private void CreatePlaylist(object o, EventArgs args) { if (finished) { return; } finished = true; try { PlaylistSource playlist = new PlaylistSource(name, source); playlist.Save(); source.AddChildSource(playlist); HyenaSqliteCommand insert_command = new HyenaSqliteCommand(String.Format( @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID) VALUES ({0}, ?)", playlist.DbId)); //ServiceManager.DbConnection.BeginTransaction (); foreach (string uri in uris) { // FIXME: Does the following call work if the source is just a PrimarySource (not LibrarySource)? int track_id = source.GetTrackIdForUri(uri); if (track_id > 0) { ServiceManager.DbConnection.Execute(insert_command, track_id); } } playlist.Reload(); playlist.NotifyUser(); } catch (Exception e) { Hyena.Log.Exception(e); } }
protected override void OnResponse(ResponseType response) { //int w = -1, h = -1; //dialog.GetSize (out w, out h); //Console.WriteLine ("w = {0}, h = {1}", w, h); QueryNode node = builder.QueryNode; if (node == null) { //Console.WriteLine ("Editor query is null"); } else { //Console.WriteLine ("Editor query is: {0}", node.ToXml (BansheeQuery.FieldSet, true)); } if (response == ResponseType.Ok) { string name = PlaylistName; QueryNode condition_tree = Condition; QueryLimit limit = Limit; QueryOrder order = Order; IntegerQueryValue limit_value = LimitValue; ThreadAssist.Spawn(delegate { //Console.WriteLine ("Name = {0}, Cond = {1}, OrderAndLimit = {2}", name, condition, order_by, limit_number); if (playlist == null) { playlist = new SmartPlaylistSource(name, primary_source); playlist.ConditionTree = condition_tree; playlist.QueryOrder = order; playlist.Limit = limit; playlist.LimitValue = limit_value; playlist.Save(); primary_source.AddChildSource(playlist); playlist.RefreshAndReload(); //SmartPlaylistCore.Instance.StartTimer (playlist); } else { playlist.ConditionTree = condition_tree; playlist.QueryOrder = order; playlist.LimitValue = limit_value; playlist.Limit = limit; playlist.Name = name; playlist.Save(); playlist.RefreshAndReload(); /*if (playlist.TimeDependent) * SmartPlaylistCore.Instance.StartTimer (playlist); * else * SmartPlaylistCore.Instance.StopTimer ();*/ //playlist.ListenToPlaylists (); //SmartPlaylistCore.Instance.SortPlaylists (); } }); } currently_editing = null; }