Exemple #1
0
        public static void UpdatePrice(
            IMagicCardDefinition definition,
            MagicCardPrice price,
            bool autoWrite,
            string additionalLogText,
            bool forcePriceUpdate)
        {
            try
            {
                lock (_sync)
                {
                    if (!forcePriceUpdate && price.IsPriceUpToDate())
                    {
                        return;
                    }

                    var request = new CardPriceRequest(_notificationCenter);
                    request.PerformRequest(definition, price, true, additionalLogText);

                    if (autoWrite)
                    {
                        Write();
                    }
                }
            }
            catch (Exception error)
            {
                _notificationCenter.FireNotification(
                    LogLevel.Error,
                    string.Format("Error getting price for {0}({1}): {2} ", definition.NameEN, definition.SetCode, error.Message) + additionalLogText);
            }
        }
 public void UpdatePriceData()
 {
     if (CurrentCards != null && CurrentCards.Any())
     {
         Task.Factory.StartNew(() =>
         {
             var all = CurrentCards.ToList();
             foreach (var card in all)
             {
                 var request = new CardPriceRequest(card);
                 request.PerformRequest();
                 card.Price        = request.PriceLow;
                 card.ImagePathMkm = request.ImagePath;
                 card.WebSiteMkm   = request.WebSite;
             }
         });
     }
 }
Exemple #3
0
        public void PriceBinder()
        {
            Task.Factory.StartNew(() =>
            {
                var stopwatch = Stopwatch.StartNew();

                _notificationCenter.FireNotification(LogLevel.Info, "Starting price current binder...");

                var cards = _cards.DistinctBy(c => c.CardId).ToList();

                var request = new CardPriceRequest(_notificationCenter);
                request.PerformRequest(cards);
                StaticPriceDatabase.Write();
                CalculateTotals();

                stopwatch.Stop();
                _notificationCenter.FireNotification(LogLevel.Info, string.Format("Done price current binder ({0}).", stopwatch.Elapsed));
            });
        }