Exemple #1
0
        private void PrevButton_Click(object sender, RoutedEventArgs e)
        {
            if (releaseCurrentPage != 0)
            {
                releaseCurrentPage--;
                releaseStack.Children.Clear();
                int masterSearchCount = 0;
                if (releaseCurrentPage < (masterResultSize) / 20 - 1)
                {
                    using (var cursor = discogsDatabase.GetCollection <BsonDocument>("masters").Find(masterSearchFilter).Skip(releaseCurrentPage * 20).Limit(20).ToCursor())
                    {
                        while (cursor.MoveNext())
                        {
                            foreach (var doc in cursor.Current)
                            {
                                Master currentMaster = new Master(doc, HelperStructs.ParentNode.Master, discogsDatabase);
                                var    list          = new MasterListView(currentMaster, discogsDatabase);
                                releaseStack.Children.Add(list);
                                masterSearchCount++;
                            }
                        }
                    }
                }

                //Search for Releases released by this artist:
                if (masterSearchCount < 20)
                {
                    using (var cursor = discogsDatabase.GetCollection <BsonDocument>("releases").Find(releaseSearchFilter).
                                        Skip(Convert.ToInt32(releaseCurrentPage - (masterResultSize) / 20 + 1) * 20).Limit(20 - masterSearchCount).ToCursor())
                    {
                        while (cursor.MoveNext())
                        {
                            foreach (var doc in cursor.Current)
                            {
                                Release currentMaster = new Release(doc, HelperStructs.ParentNode.Release, discogsDatabase);
                                var     list          = new ReleaseListView(currentMaster, discogsDatabase);
                                releaseStack.Children.Add(list);
                            }
                        }
                    }
                }
                if (releaseResultSize + masterResultSize < 20)
                {
                    PageStatus.Text = String.Format($"Showing {releaseCurrentPage * 20 + 1} - {releaseResultSize + masterResultSize} of {releaseResultSize + masterResultSize}");
                }
                else
                {
                    PageStatus.Text = String.Format($"Showing {releaseCurrentPage * 20 + 1} - {releaseCurrentPage * 20 + 20} of {releaseResultSize + masterResultSize}");
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Constructs a view for an individual artist.
        /// </summary>
        /// <param name="artist"></param>
        /// <param name="discogsDatabase"></param>
        public ArtistWindowView(Artist artist, IMongoDatabase discogsDatabase)
        {
            InitializeComponent();
            this.Title           = artist.Name;
            this.artist          = artist;
            this.discogsDatabase = discogsDatabase;
            /////////
            var artistJoinFilter = Builders <BsonDocument> .Filter.Eq("artistJoins.artist_id", artist.Id.ToString());

            var extraArtistFilter = Builders <BsonDocument> .Filter.Eq("extraartists.artist_id", artist.Id.ToString());

            var ArtistsFilter = Builders <BsonDocument> .Filter.Eq("artists", artist.Name);

            var ArtistFilter = Builders <BsonDocument> .Filter.Eq("l_artist", artist.Name.ToLower());

            masterSearchFilter = artistJoinFilter | extraArtistFilter | ArtistsFilter | ArtistFilter;
            /////////
            var releaseSearch = Builders <BsonDocument> .Filter.Eq("master_id", 0);

            var releaseSearch2 = Builders <BsonDocument> .Filter.Eq("master_id", "0");

            releaseSearchFilter = (artistJoinFilter | extraArtistFilter) & (releaseSearch | releaseSearch2);
            //////////
            artistName.Text = artist.Name;
            profile.Text    = "Profile: " + artist.Profile;
            ///////
            nameVariations.Text = helperMethods.listOutput <string>("Name Variations:", artist.NameVariations);
            ///////////
            Uris.Text = helperMethods.listOutput <Uri>("URLs:", artist.Urls);
            ///////////
            aliases.Text = helperMethods.listOutput <string>("Aliases:", artist.Aliases);
            ////////////
            if (artist.Members.Count == 0)
            {
                members.Text = helperMethods.listOutput <string>("Groups:", artist.Groups);
            }
            else
            {
                members.Text = helperMethods.listOutput <string>("Members:", artist.Members);
            }
            ///////////
            dataQuality.Text = "Data Quality: " + artist.DataQuality;
            ///////////
            lastUpdated.Text = "Last Updated: " + artist.LastUpdated;
            ///////////
            realName.Text = "Real Name: " + artist.RealName;
            //Search for Masters and Releases:
            //Search for all Masters released by this artist:

            int masterSearchCount = 0;

            using (var cursor = discogsDatabase.GetCollection <BsonDocument>("masters").Find(masterSearchFilter).Limit(20).ToCursor())
            {
                while (cursor.MoveNext())
                {
                    foreach (var doc in cursor.Current)
                    {
                        Master currentMaster = new Master(doc, HelperStructs.ParentNode.Master, discogsDatabase);
                        var    list          = new MasterListView(currentMaster, discogsDatabase);
                        releaseStack.Children.Add(list);
                        masterSearchCount++;
                    }
                }
            }
            //Search for Releases released by this artist:
            if (masterSearchCount < 20)
            {
                using (var cursor = discogsDatabase.GetCollection <BsonDocument>("releases").Find(releaseSearchFilter).Limit(20 - masterSearchCount).ToCursor())
                {
                    while (cursor.MoveNext())
                    {
                        foreach (var doc in cursor.Current)
                        {
                            Release currentMaster = new Release(doc, HelperStructs.ParentNode.Release, discogsDatabase);
                            var     list          = new ReleaseListView(currentMaster, discogsDatabase);
                            releaseStack.Children.Add(list);
                        }
                    }
                }
            }
            masterResultSize  = discogsDatabase.GetCollection <BsonDocument>("masters").Find(masterSearchFilter).Count();
            releaseResultSize = discogsDatabase.GetCollection <BsonDocument>("releases").Find(releaseSearchFilter).Count();
            if (releaseResultSize + masterResultSize < 20)
            {
                PageStatus.Text = String.Format($"Showing {releaseCurrentPage * 20 + 1} - {releaseResultSize + masterResultSize} of {releaseResultSize + masterResultSize}");
            }
            else
            {
                PageStatus.Text = String.Format($"Showing {releaseCurrentPage * 20 + 1} - {releaseCurrentPage * 20 + 20} of {releaseResultSize + masterResultSize}");
            }
        }