Exemplo n.º 1
0
        /* URL fetching/parsing for cards for a given set */
        public List <MTGCard> GetCardListForSet(MTGSet SetIn)
        {
            if (SetIn == null)
            {
                log.Error("GetCardListForSet supplied null MTGSet");
                return(null);
            }
            List <MTGCard> curCards = new List <MTGCard>();

            if (SetIn.CardListLastUpdate.CompareTo(DateTime.Today) < 0)
            {
                // Need to Update List
                URLFetcher Fetcher = new URLFetcher(startURL + SetIn.URL);
                string     ret     = Fetcher.Fetch();

                curCards = _MTGPriceParser.ParseCardURLs(ret, SetIn.ToString());
                curCards = curCards.OrderBy(card => card.ToString()).ToList();

                SetIn.CardListLastUpdate = DateTime.Today;

                _SQLWrapper.UpdateCardList(curCards, SetIn.ToString());
                _SQLWrapper.UpdateSetLastUpdate(SetIn.ToString(), SetIn.CardListLastUpdate);
            }
            else
            {
                // List is already up to date, parse from SQL
                curCards = _SQLWrapper.GetCardList(SetIn.ToString());
            }

            curCards = curCards.OrderByDescending(card => card.Price).ToList();

            return(curCards);
        }
Exemplo n.º 2
0
        /* When a different set is selected, grab URL for specific cards if required and populate mtgCardsGraphListBox */
        private void mtgSetsGraphListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (mtgSetsGraphListBox.SelectedItem == null)
            {
                return;
            }
            MTGSet curSet = (MTGSet)mtgSetsGraphListBox.SelectedItem;

            UpdateStatusLabel("Status: Fetching info for " + curSet.ToString());
            List <MTGCard> Cards = DM.GetCardListForSet(curSet);

            curSet.Cards = Cards;
            UpdateStatusLabel("Status: Complete");

            if (Cards != null)
            {
                updateMTGCardsGraphListBox(Cards);
            }
            else
            {
                UpdateStatusLabel("Status: Error retrieving card list for set " + curSet.ToString());
            }
        }