示例#1
0
        private void CTPOnRspUserLogin(ref CThostFtdcRspUserLoginField pRspUserLogin, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            //避免登录错误后不断重连
            if (pRspInfo.ErrorID != 0)
            {
                _t.SetOnFrontDisconnected(null);
            }
            //else //正常登录时注册连接事件(后续自动重连时可自行登录)
            //_t.SetOnFrontConnected(CTPOnFrontConnected);

            if (pRspInfo.ErrorID == 0)
            {
                //IsLogin = true; //position中完成
                this.TradingDay = Marshal.PtrToStringAnsi(_t.GetTradingDay());
                _session        = pRspUserLogin.SessionID;
                _front          = pRspUserLogin.FrontID;
                //_orderref = pRspUserLogin.MaxOrderRef;
                _broker   = pRspUserLogin.BrokerID;
                _investor = pRspUserLogin.UserID;
                _t.ReqQrySettlementInfo(_broker, _investor);
            }
            else
            {
                _OnRspUserLogin?.Invoke(this, new IntEventArgs {
                    Value = pRspInfo.ErrorID
                });
            }
        }