Exemplo n.º 1
0
 public void Update(bool resort)
 {
     guiInterface.InProgress = true;
     ThreadPool.QueueUserWorkItem(parameters =>
     {
         var currentLowData      = exileToolsClient.GetCurrentLow(guiInterface.SelectedLeague);
         var historicalData      = exileToolsClient.GetHistoricalStats(guiInterface.SelectedLeague);
         var exaltedPrice        = exileToolsClient.GetExaltPrice(guiInterface.SelectedLeague);
         guiInterface.ExaltPrice = exaltedPrice;
         exaltedPrice            = exaltedPrice == 0 ? 60 : exaltedPrice;
         guiInterface.InvokeGrid(() =>
         {
             foreach (var item in currentLowData)
             {
                 var itemData = historicalData.SingleOrDefault(historicalItem => historicalItem.name == item.name);
                 if (itemData == null)
                 {
                     continue;
                 }
                 var newItem = new StatsGuiItem
                 {
                     Name        = item.name,
                     CurrentLow  = priceFinder.GetMinPrice(item.minPriceChaos, item.minPriceExalted, exaltedPrice),
                     SoldLast24h = itemData.dateRanges.buckets.Last().count,
                     Note        = appConfig.GetValue(item.name)
                 };
                 newItem.Low24h         = Math.Min(newItem.CurrentLow, priceFinder.GetMinPrice(itemData.dateRanges.buckets.Last().minPriceChaos, itemData.dateRanges.buckets.Last().minPriceExalted, exaltedPrice));
                 newItem.OneDayAgoAvg   = itemData.dateRanges.buckets[2].avgPrice.values.TenPercent;
                 newItem.TwoDayAgoAvg   = itemData.dateRanges.buckets[1].avgPrice.values.TenPercent;
                 newItem.ThreeDayAgoAvg = itemData.dateRanges.buckets[0].avgPrice.values.TenPercent;
                 guiInterface.UpdateItem(newItem);
             }
             if (resort)
             {
                 guiInterface.SortByMarketValue();
             }
             guiInterface.ClearGridSelection();
             guiInterface.InProgress = false;
         });
     });
 }
Exemplo n.º 2
0
 public void UpdateItem(StatsGuiItem item)
 {
     if (statsGuiItems.Contains(item))
     {
         var existingItem = (from StatsGuiItem guiItem in statsGuiItems
                             where guiItem.Name == item.Name
                             select guiItem).Single();
         if (existingItem != null)
         {
             existingItem.SoldLast24h    = item.SoldLast24h;
             existingItem.CurrentLow     = item.CurrentLow;
             existingItem.OneDayAgoAvg   = item.OneDayAgoAvg;
             existingItem.TwoDayAgoAvg   = item.TwoDayAgoAvg;
             existingItem.ThreeDayAgoAvg = item.ThreeDayAgoAvg;
         }
     }
     else
     {
         statsGuiItems.Add(item);
     }
 }