/// <summary>
        /// 期货公司认证
        /// </summary>
        public override void AuthorT(string brokerID, string userId, string authCode, string userProductInfo)
        {
            FireOrderDriverStateChanged(USeOrderDriverState.Authoring, "");

            Debug.Assert(m_ctpUser != null, "m_ctpUser is null");

            int requestID = m_requetSeqIDCreator.Next();

            try
            {
                USeResetEvent resetEvent = new USeResetEvent(requestID);
                m_eventDic.Add(resetEvent.EventID, resetEvent);

                ReqAuthenticateField field = new ReqAuthenticateField()
                {
                    BrokerID        = brokerID,
                    UserID          = userId,
                    AuthCode        = authCode,
                    UserProductInfo = userProductInfo
                };

                m_ctpUser.ReqAuthenticate(ref field, requestID);

                if (resetEvent.WaitOne(m_connectTimeOut) == false)
                //if (resetEvent.WaitOne(50000) == false)
                {
                    throw new Exception("AuthorT time out.");
                }
                else
                {
                    if (resetEvent.IsError)
                    {
                        Debug.Assert(resetEvent.Tag != null);
                        ReqAuthenticateField rspInfo = (ReqAuthenticateField)resetEvent.Tag;
                        Debug.Assert(rspInfo.UserProductInfo != null && rspInfo.UserProductInfo != "");
                        throw new Exception(string.Format("({0}){1}", rspInfo.AuthCode, rspInfo.UserProductInfo));
                    }
                }
            }
            catch (Exception ex)
            {
                FireOrderDriverStateChanged(USeOrderDriverState.AuthorFieldOut, ex.Message);
                m_logger.WriteError(string.Format("{0} AuthorT failed,Error: {1}.", ToString(), ex.Message));
                throw ex;
            }
            finally
            {
                m_eventDic.Remove(requestID);
            }

            FireOrderDriverStateChanged(USeOrderDriverState.AuthorSuccessOn, "");
        }
Beispiel #2
0
        private static void OnFrontConnected()
        {
            ReqAuthenticateField authenticateField = new ReqAuthenticateField()
            {
                BrokerID        = "9999",
                UserID          = "",
                UserProductInfo = "",
                AuthCode        = "",
                AppID           = "",
            };

            _tdapi.ReqAuthenticate(authenticateField, _reqId++);
        }