Пример #1
0
        /// <summary>
        /// 释放对象
        /// </summary>
        public void FreeObject()
        {
            try
            {
                if (thread != null)
                {
                    thread.Abort();
                    thread = null;
                }

                if (manageMarket != null)
                {
                    manageMarket.ForFreeConnectMarket();
                    manageMarket = null;
                }

                if (manageTrade != null)
                {
                    //manageTrade.ForLogout(password, "");
                    manageTrade.ForFreeClient();
                    manageTrade = null;
                }
            }
            catch (Exception ex)
            {
                PrintLine("释放连接异常:" + ex.Message);
                JHLog.forTradeLog("释放连接异常:" + ex.ToString());
            }
        }
Пример #2
0
        public void OnJHTradeForValSign(Trade_Head msgHead)
        {
            if (printMsg != null)
            {
                printMsg.Print("验证特征码成功!正在进行登陆验证. . .");
            }
            //特征码验证成功后进行登陆
            bool rlogin = manageTrade.ForJHTradeLogin(username, password, JHUtil.GetMacAddress(), JHUtil.GetNaviteIP(), "login");

            if (rlogin == false)
            {
                manageTrade.ForFreeClient();
                manageTrade = null;
            }
        }
Пример #3
0
        //交易接口端
        public void OnJHTradeForConnectinit(string strVer)
        {
            if (printMsg != null)
            {
                printMsg.Print("链接交易服务器成功!正在进行特征码验证. . .");
            }
            //服务器连接成功后进行特征码验证
            bool validate = manageTrade.ForJHTradeValidateSign(valsign, "valsign");

            if (validate == false)
            {
                manageTrade.ForFreeClient();
                manageTrade = null;
                return;
            }
            OnTradeConnect();
        }
Пример #4
0
        public void OnJHMarketLogin(string svrTime)
        {
            if (svrTime == "")
            {
                if (stateNotify != null)
                {
                    stateNotify.OnNotify(this, NotifyCode.MARKET_TIME_ERROR);
                }
                return;
            }
            if (printMsg != null)
            {
                printMsg.Print("登陆行情服务器 成功!");
            }
            if (stateNotify != null)
            {
                stateNotify.OnNotify(this, NotifyCode.MARKET_LOGIN_OK);
            }
            //保存登陆时间
            lastMarketHeartTime = int.Parse(svrTime);
            time_market_dif     = lastMarketHeartTime - GetTimestamp();
            if (manageTrade != null)
            {
                manageTrade.ForFreeClient();
                manageTrade = null;
            }

            manageTrade = new ManageTrade(this);
            manageTrade.SetTradeAddr(trade_addr, trade_port);
            manageTrade.SetUserInfo(username, password);
            manageTrade.SetValSign(valsign);
            //连接交易服务器
            bool mant = manageTrade.ForConnect(trade_addr, trade_port);

            if (mant == false)
            {
                manageTrade = null;
            }
        }