Пример #1
0
        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);
        }
Пример #2
0
        int MergeMarketObservations(Item source, Item target)
        {
            var toChange = _marketObservationRepository.GetByItem(source).ToArray();

            foreach (var obs in toChange)
            {
                obs.Item = target;
                _marketObservationRepository.Save(obs);
            }
            return(toChange.Length);
        }
Пример #3
0
        public static void ImportMarket()
        {
            var    path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "market import.csv");
            string obs;

            using (var sr = new StreamReader(path))
                obs = sr.ReadToEnd();

            using (var repo = new ItemRepository())
            {
                var parser = new MarketObservationParser(new MarketObservationParserSettings(), repo, obs);
                using (var mRepo = new MarketObservationRepository())
                {
                    mRepo.Begin();
                    foreach (var o in parser.Observations)
                    {
                        mRepo.Save(o);
                    }
                    mRepo.End();
                }
            }
        }