public void RemoveAlbumFromDatabase(int albumId)
        {
            ZuneQueryList zuneQueryList = _zuneLibrary.GetTracksByAlbum(0, albumId,
                                                                        EQuerySortType.eQuerySortOrderAscending,
                                                                        (uint)SchemaMap.kiIndex_AlbumID);

            for (int i = 0; i < zuneQueryList.Count; i++)
            {
                var track = new ZuneQueryItem(zuneQueryList, i);
                //TODO: see if we can delete the actual album
                _zuneLibrary.DeleteMedia(new[] { track.ID }, EMediaTypes.eMediaTypeAudio, false);
            }

            _zuneLibrary.CleanupTransientMedia();
            zuneQueryList.Dispose();
        }
        public IEnumerable <DbAlbum> ReadAlbums(SortOrder sortOrder)
        {
            this.StartedReadingAlbums.Invoke();

            uint sortAtom = 0;

            switch (sortOrder)
            {
            case SortOrder.DateAdded:
                sortAtom = (uint)SchemaMap.kiIndex_DateAdded;
                break;

            case SortOrder.Album:
                sortAtom = (uint)SchemaMap.kiIndex_Title;
                break;

            case SortOrder.Artist:
                sortAtom = (uint)SchemaMap.kiIndex_DisplayArtist;
                break;

            default:
                throw new ArgumentOutOfRangeException("sortOrder");
            }

            //querying all albums, creates a property bag inside this method to query the database
            ZuneQueryList albums = GetAlbumQueryListSorted(sortAtom);

            albums.AddRef();

            var uniqueIds = albums.GetUniqueIds();

            for (int i = 0; i < uniqueIds.Count; i++)
            {
                object uniqueId = uniqueIds[i];
                yield return(GetAlbumMin((int)uniqueId));

                ProgressChanged.Invoke(i, uniqueIds.Count - 1);
            }

            FinishedReadingAlbums.Invoke();

            albums.Release();
            albums.Dispose();
        }
Esempio n. 3
0
        public static void MergeAlbumsToGenre(string targetGenre, IList sourceAlbums)
        {
            IList albumIds = new ArrayList(sourceAlbums.Count);

            foreach (LibraryDataProviderListItem sourceAlbum in sourceAlbums)
            {
                albumIds.Add((int)sourceAlbum.GetProperty("LibraryId"));
            }
            ZuneQueryList tracksByAlbums = ZuneApplication.ZuneLibrary.GetTracksByAlbums(albumIds, null);
            int           num1           = (int)tracksByAlbums.AddRef();
            uint          count          = (uint)tracksByAlbums.Count;

            for (uint index = 0; index < count; ++index)
            {
                tracksByAlbums.SetFieldValue(index, 398U, targetGenre);
            }
            int num2 = (int)tracksByAlbums.Release();

            tracksByAlbums.Dispose();
        }
Esempio n. 4
0
        public static void MergeArtistsToArtist(string targetArtist, IList sourceArtists)
        {
            IList artistIds = new ArrayList(sourceArtists.Count);

            foreach (LibraryDataProviderListItem sourceArtist in sourceArtists)
            {
                artistIds.Add((int)sourceArtist.GetProperty("LibraryId"));
            }
            ZuneQueryList albumsByArtists = ZuneApplication.ZuneLibrary.GetAlbumsByArtists(artistIds, null);
            int           num1            = (int)albumsByArtists.AddRef();
            uint          count           = (uint)albumsByArtists.Count;

            for (uint index = 0; index < count; ++index)
            {
                albumsByArtists.SetFieldValue(index, 380U, targetArtist);
            }
            int num2 = (int)albumsByArtists.Release();

            albumsByArtists.Dispose();
        }
        public IEnumerable <DbTrack> GetTracksForAlbum(int albumId)
        {
            ZuneQueryList zuneQueryList = _zuneLibrary.GetTracksByAlbum(0, albumId,
                                                                        EQuerySortType.eQuerySortOrderAscending,
                                                                        (uint)SchemaMap.kiIndex_AlbumID);

            for (int i = 0; i < zuneQueryList.Count; i++)
            {
                var track = new ZuneQueryItem(zuneQueryList, i);

                //for (int j = 0; j < 2000; j++)
                //{
                //    try
                //    {
                //        var test = track.GetFieldValue(typeof(long), (uint)j);

                //        if (test != null)
                //        {
                //            Trace.WriteLine(ZuneQueryList.AtomToAtomName(j));
                //            Trace.WriteLine(test);
                //        }
                //    }
                //    catch (Exception ex)
                //    {
                //        Trace.WriteLine("FAILED ON");
                //    }
                //}

                yield return(new DbTrack
                {
                    FilePath = GetTrackValue <string>(track, "SourceURL"),
                    MediaId = GetTrackValue <Guid>(track, "ZuneMediaID"),
                    Title = GetTrackValue <string>(track, "Title"),
                    TrackNumber = GetTrackValue <long>(track, "WM/TrackNumber").ToString()
                });
            }

            zuneQueryList.Dispose();
        }