public void EnqueueUpdateMoneyData(int botId)
        {
            var res = _dictBotIdConnId.FirstOrDefault(a => a.Key == botId);

            if (res.Key == 0)
            {
                return;               //not found
            }
            int connId = res.Value;


            CUserMoney userMon = new CUserMoney();

            CUtil.CopyObjProperties(_client.AccountsMoney[botId], userMon.AccountMoney);



            CAccountTrade accTr = new CAccountTrade();

            CUtil.CopyObjProperties(_client.AccountsTrade[botId], accTr);

            //injection !
            //TODO normal in the future
            accTr.money_sess_limit = _client.GetSessionLimit(botId);

            userMon.ListAccountTrade.Add(accTr);



            _bqTraderData.Add(new CTradingData
            {
                ConnId = connId,
                Data   = (object)userMon,
                Event  = enmTradingEvent.UpdateMoneyData
            }
                              );
        }
Ejemplo n.º 2
0
        private void ProcessUpdateMoneyData(byte[] arrMsgBody)
        {
            CUserMoney um = CUtilProto.DeserializeProto <CUserMoney>(arrMsgBody);

            _childWinDataUpdater.Update(um, _connId);
        }
 private void SendUpadateAccountMoney(int connId, CUserMoney accMoney)
 {
     SendDataToClients(accMoney, enmTradingEvent.UpdateMoneyData, "", connId);
 }
Ejemplo n.º 4
0
        public override void UpdateData(object data, int conId)
        {
            CUserMoney userMoney = (CUserMoney)data;

            _money = userMoney.AccountMoney.money_avail;

            //  List<CAccountMoney> lstMonRcvd = new List<CAccountMoney>();
            //lstMonRcvd.Add(userMoney.AccountMoney);

            bool bNeedBindGrid = false;

            if (userMoney.ListAccountTrade.Count > 0)
            {
                int stockExchId = userMoney.ListAccountTrade[0].stock_exchange_id;


                if (ListAcoountsMoney.Count == 0)
                {
                    //changed 2018-04-06
                    //   ListAcoountsMoney = lstMon;
                    bNeedBindGrid = true;
                    _bElemVisible = true;
                }

                var res = ListAcoountsMoney.Find(el => el.StockExchId == stockExchId);


                if (res == null)
                {
                    ListAcoountsMoney.Add(new CUserMoneyWithStockExch(userMoney.AccountMoney, stockExchId));
                    bNeedBindGrid = true;
                }
                else
                {
                    res.money_avail      = userMoney.AccountMoney.money_avail;
                    res.money_sess_limit = userMoney.AccountMoney.money_sess_limit;
                }
            }



            List <CAccountTrade> lstAccTradeRcvd = new List <CAccountTrade>();

            lstAccTradeRcvd = userMoney.ListAccountTrade;


            if (ListAccountsTrade.Count == 0 || ListAccountsTrade.Except(lstAccTradeRcvd).Any())
            {
                //canged 2018-04-06
                //    ListAccountsTrade = lstAccTrade;
                bNeedBindGrid = true;
                _bElemVisible = true;
            }

            //added 2018-04-06
            foreach (var elRcvLst in lstAccTradeRcvd)
            {
                var res = ListAccountsTrade.Find(el => el.stock_exchange_id == elRcvLst.stock_exchange_id);
                if (res == null) //new do add
                {
                    ListAccountsTrade.Add(elRcvLst);
                    bNeedBindGrid = true;
                }
                else //exist do update
                {
                    res.name             = elRcvLst.name;
                    res.money_avail      = elRcvLst.money_avail;
                    res.money_sess_limit = elRcvLst.money_sess_limit;
                }
            }


            //var res = ListAccountsTrade.Find ( el => el.stock_exchange_id == l)



            if (bNeedBindGrid)
            {
                BindGrid();
            }
        }