private void AddOrder() { AppJournal.Write("MainVM", "Add order record"); if (modeType == 2) { orderData.Add(new Order { Number = (orderData.Count + 1), FirmBroker = dataMananger.firmData, Client = dataMananger.clientData, Issue = dataMananger.issueData, BottomPrice = 0, Step = 0, LastPrice = 0, CurrentPrice = 0, ModeType = dataMananger.modeData, Place = 0, StartCmdName = "Запуск" }); OrdersVM orderVM = new OrdersVM(); orderVM.Orders = orderData; OrdersVM = orderVM; } else if (modeType == 1) { autoOrderData.Add(new AutoOrder { Number = (autoOrderData.Count + 1) }); AutoOrdersVM autoOrderVM = new AutoOrdersVM(); autoOrderVM.AutoOrders = autoOrderData; AutoOrdersVM = autoOrderVM; } else { scenaryOrderData.Add(new ScenaryOrder { Number = (scenaryOrderData.Count + 1), TimeWhen = DateTime.Now.ToLongTimeString() }); ScenaryOrdersVM scenaryOrderVM = new ScenaryOrdersVM(); scenaryOrderVM.ScenaryOrders = scenaryOrderData; ScenaryOrdersVM = scenaryOrderVM; if (curBroker.name == null) { SetBroker("ALTA"); } ScenaryOrdersVM.ScenaryOrders[ScenaryOrdersVM.ScenaryOrders.Count - 1].Broker.FindLast(x => x.name == curBroker.name).name = "ALTA"; ScenaryOrdersVM.ScenaryOrders[ScenaryOrdersVM.ScenaryOrders.Count - 1].Broker.FindLast(x => x.id == curBroker.id).id = 430; ScenaryOrdersVM.ScenaryOrders[ScenaryOrdersVM.ScenaryOrders.Count - 1].Broker[0].name = curBroker.name; ScenaryOrdersVM.ScenaryOrders[ScenaryOrdersVM.ScenaryOrders.Count - 1].Broker[0].id = curBroker.id; } ServerLogsTxt += "Заявка добавлена\n"; }
private void ScenaryLoad() { OpenFileDialog openFD = new OpenFileDialog(); openFD.Filter = "Scenary files (*.scn)|*.scn"; if (openFD.ShowDialog() == DialogResult.OK) { ObservableCollection <ScenaryOrder> tmpSO = new ObservableCollection <ScenaryOrder>(); XmlSerializer xmlSerializer = new XmlSerializer(typeof(ObservableCollection <ScenaryOrder>)); TextReader FileStream = new StreamReader(openFD.FileName); tmpSO = (ObservableCollection <ScenaryOrder>)xmlSerializer.Deserialize(FileStream); FileStream.Close(); scenaryOrderData.Clear(); int iCount = 0; foreach (var item in tmpSO) { scenaryOrderData.Add(new ScenaryOrder { Number = item.Number, ClientCode = item.ClientCode, LotNumber = item.LotNumber, PriceTo = item.PriceTo, SelectedBroker = item.SelectedBroker, TimeWhen = item.TimeWhen }); ScenaryOrdersVM scenaryOrderVM = new ScenaryOrdersVM(); scenaryOrderVM.ScenaryOrders = scenaryOrderData; ScenaryOrdersVM = scenaryOrderVM; ScenaryOrdersVM.ScenaryOrders[iCount].Broker.FindLast(x => x.name == item.SelectedBroker.name).name = "ALTA"; ScenaryOrdersVM.ScenaryOrders[iCount].Broker.FindLast(x => x.id == item.SelectedBroker.id).id = 430; ScenaryOrdersVM.ScenaryOrders[iCount].Broker[0].name = item.SelectedBroker.name; ScenaryOrdersVM.ScenaryOrders[iCount].Broker[0].id = item.SelectedBroker.id; iCount++; } } }