Example #1
0
        private void refreshItem(Models.Models.ClientOrder clientOrder)
        {
            int index = ClientOrders.IndexOf(clientOrder);

            if (index > 0)
            {
                ClientOrders.RemoveAt(index);
                ClientOrders.Insert(index, clientOrder);
            }
        }
Example #2
0
        private void XmlConnector_OnSendNewOrders(string data)
        {
            var orders =
                (Orders)
                new XmlSerializer(typeof(Orders)).Deserialize(
                    new StringReader(data));

            try
            {
                orders.Order = orders.Order.OrderBy(item => DateTime.Parse(item.Time)).ToList();
            }
            catch
            {
            }
            _dispatcher.Invoke(() => {
                foreach (var order in orders.Order)
                {
                    var found = ClientOrders.FirstOrDefault(item => item.Transactionid == order.Transactionid);

                    if (found == null)
                    {
                        ClientOrders.Insert(0, order);
                    }
                    else
                    {
                        ClientOrders[ClientOrders.IndexOf(found)] = order;
                    }
                }
                foreach (var stoporder in orders.Stoporder)
                {
                    var found = ClientStoporders.FirstOrDefault(item => item.Transactionid == stoporder.Transactionid);
                    if (found == null)
                    {
                        ClientStoporders.Insert(0, stoporder);
                    }
                    else
                    {
                        ClientStoporders[ClientStoporders.IndexOf(found)] = stoporder;
                    }
                }
            });

            ActiveOrders     = ClientOrders.Count(o => o.Status == "active");
            ActiveStoporders = ClientStoporders.Count(o => o.Status == "watching");
        }