public void LoadDataBaseFromMongo() { MongoHistoryCSGO mongoHistory = new MongoHistoryCSGO(); List <MongoHistoryItem> items = mongoHistory.FindAll().ToEnumerable().OrderBy(x => x.id.Timestamp).ToList(); __database__.EnterWriteLock(); try { foreach (MongoHistoryItem item in items) { if (!__database__.newDataBase.TryGetValue(item.i_market_name, out BasicSalesHistory temp)) { temp = new BasicSalesHistory(); __database__.newDataBase.Add(item.i_market_name, temp); } temp.Add(item); } foreach (var kv in __database__.newDataBase) { kv.Value.Recalculate(); } } finally { __database__.ExitWriteLock(); } }
public void ProcessItem(NewHistoryItem item) { if (!hasStickers(item)) { if (needOrderUnstickered.Count < Consts.MAXORDERQUEUESIZE) { needOrderUnstickered.Enqueue(item); } return; } //Console.WriteLine(item.i_market_name); __database__.EnterWriteLock(); try { if (!__database__.newDataBase.TryGetValue(item.i_market_name, out BasicSalesHistory salesHistory)) { salesHistory = new BasicSalesHistory(); __database__.newDataBase.Add(item.i_market_name, salesHistory); } salesHistory.Add(item); salesHistory.Recalculate(); if (salesHistory.GetCnt() >= Consts.MINSIZE && !blackList.Contains(item.i_market_name)) { if (needOrder.Count <= Consts.MAXORDERQUEUESIZE) { needOrder.Enqueue(item); } } } finally { __database__.ExitWriteLock(); } }