bool SaveObservation(ItemAnalysis analysis, Item item) { var recentObs = _marketObservationRepository.GetByItemAndDate(item, DateTime.Now - ObservationSaveThreshold, DateTime.Today.AddDays(1)); if (recentObs.Any()) { return(false); } var obs = new MarketObservation(); obs.Item = item; obs.EntryTime = DateTime.Now; obs.High = analysis.Highest; obs.Low = analysis.Lowest; obs.LastSalePrice = analysis.LastPrice; obs.Price = analysis.MarketPrice; obs.TotalTrades = analysis.TotalTrades; obs.UnitsOnMarket = analysis.CurrentListings; _marketObservationRepository.Save(obs); return(true); }
public ItemAnalysis Analyze(ItemListing itemListing, TesseractEngine engine) { var analysis = new ItemAnalysis(); double conf; analysis.ItemName = GetText(itemListing.Name, engine, out conf); analysis.ItemNameConfidence = conf; analysis.Highest = TryParse(GetText(itemListing.Highest, engine, out conf)); analysis.HighestConfidence = conf; if (analysis.Highest == -1) { analysis.HighestConfidence = 0; } analysis.Lowest = TryParse(GetText(itemListing.Lowest, engine, out conf)); analysis.LowestConfidence = conf; if (analysis.Lowest == -1) { analysis.LowestConfidence = 0; } analysis.MarketPrice = TryParse(GetText(itemListing.MarketPrice, engine, out conf)); analysis.MarketPriceConfidence = conf; if (analysis.MarketPrice == -1) { analysis.MarketPriceConfidence = 0; } analysis.LastPrice = TryParse(GetText(itemListing.LastSalePrice, engine, out conf)); analysis.LastPriceConfidence = conf; if (analysis.LastPrice == -1) { analysis.LastPriceConfidence = 0; } analysis.TotalTrades = TryParse(GetText(itemListing.TotalSales, engine, out conf)); analysis.TotalTradesConfidence = conf; if (analysis.TotalTrades == -1) { analysis.TotalTradesConfidence = 0; } analysis.CurrentListings = TryParse(GetText(itemListing.CurrentListings, engine, out conf)); analysis.CurrentListingsConfidence = conf; if (analysis.CurrentListings == -1) { analysis.CurrentListingsConfidence = 0; } analysis.Icon = itemListing.Icon.GetColorData(); //analysis.IsEnhanced = IsEnhanced(analysis.Icon, analysis.ItemName); return(analysis); }
bool ItemPasses(ItemAnalysis itemAnalysis) { if (string.IsNullOrEmpty(itemAnalysis.ItemName)) { return(false); } if (itemAnalysis.ItemNameConfidence < MinimumConfidence) { return(false); } if (itemAnalysis.HighestConfidence < MinimumConfidence && RequireHighest) { return(false); } if (itemAnalysis.LowestConfidence < MinimumConfidence && RequirestLowest) { return(false); } if (itemAnalysis.MarketPriceConfidence < MinimumConfidence && RequireMarketPrice) { return(false); } if (itemAnalysis.LastPriceConfidence < MinimumConfidence && RequireLastSalesPrice) { return(false); } if (itemAnalysis.TotalTradesConfidence < MinimumConfidence && RequireTotalTrades) { return(false); } if (itemAnalysis.CurrentListingsConfidence < MinimumConfidence && RequireCurrentListings) { return(false); } return(true); }
public void SaveToDatabase(ItemAnalysis itemAnalysis) { var item = _itemRepository.GetByName(itemAnalysis.ItemName).FirstOrDefault(); if (item == null) { if (AutoAddNewItemsToDatabase) { item = new Item(); item.Name = itemAnalysis.ItemName; _itemRepository.Save(item); } } if (item != null) { SaveObservation(itemAnalysis, item); } }
public ItemAnalysisViewModel(ItemAnalysis analysis) { Analysis = analysis; IconSource = LoadBitmap(analysis.Icon); }