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();
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }