public void SaveHistory() { try { string currentPath = Directory.GetCurrentDirectory(); string path = Path.Combine(currentPath, "History Data"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path, DateTime.Now.ToShortDateString()); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string n = MarketName; DateTime dt = Mbi.Last().LastByte; int h = dt.Hour; int m = dt.Minute; int s = dt.Second; string filename = path + @"\" + n + " " + h + "." + m + "." + s + ".xml"; if (File.Exists(filename)) { File.Delete(filename); } XmlDocument xmlDocument = new XmlDocument(); XmlSerializer serializer = new XmlSerializer(typeof(MarketInformation)); using (MemoryStream stream = new MemoryStream()) { serializer.Serialize(stream, this); stream.Position = 0; xmlDocument.Load(stream); xmlDocument.Save(filename); //stream.Close(); } } catch (Exception e) { MessageBox.Show(e.ToString()); } }
public void UpdateMarket() { List <MarketInformation> marketBook = modelCore.GetMarketBook(new List <string> { MarketId }); MarketBookInformation recordJustReceived = marketBook[0].Mbi.Last(); recordJustReceived.MarketName = MarketName; //проброс MarketName в MarketBookInformation при добавлении новых рыночных данных //добавляем только в том случае, если полученные данные отличаются от уже полученных ранее if (Mbi.LastOrDefault() != recordJustReceived) { Mbi.Add(recordJustReceived); //MessageBox.Show("Дык!"); } }
public MarketInformation() { _mbi = new ObservableCollection <MarketBookInformation>(); MarketBookInformation mbi = new MarketBookInformation() { MarketName = this.MarketName, Runner0Name = this.Runner0Name, Runner1Name = this.Runner1Name, ExPricesRunner0 = new ExchangePrices() { AvailableToBack = new ObservableCollection <PriceSize> { new PriceSize(), new PriceSize(), new PriceSize() }, AvailableToLay = new ObservableCollection <PriceSize> { new PriceSize(), new PriceSize(), new PriceSize() } }, ExPricesRunner1 = new ExchangePrices() { AvailableToBack = new ObservableCollection <PriceSize> { new PriceSize(), new PriceSize(), new PriceSize() }, AvailableToLay = new ObservableCollection <PriceSize> { new PriceSize(), new PriceSize(), new PriceSize() } } }; Mbi.Add(mbi); //обработчик изменений внутри Mdi _mbiChangeHandler = (sender, e) => OnPropertyChanged("Mbi"); _mbiChangeItemHandler = (sender, e) => OnPropertyChanged("Mbi"); }