Ejemplo n.º 1
0
        public void Init()
        {
            if (FrontAddrs == null || FrontAddrs.Length == 0)
            {
                HandleErrorInternal("前置机地址不能为空!");
                return;
            }

            try
            {
                if (mdApi == null)
                {
                    mdApi = new FtdcMdAdapter(".\\md", false, false);                   // 创建md目录存放流文件,避免与交易流文件冲突
                    mdApi.OnFrontEvent += MdApi_OnFrontEvent;
                    mdApi.OnRspEvent   += MdApi_OnRspEvent;
                    mdApi.OnRtnEvent   += MdApi_OnRtnEvent;
                }

                foreach (var addr in FrontAddrs)
                {
                    mdApi.RegisterFront(addr);  // 注册所有的可用地址
                }

                mdApi.Init();
            }
            catch (Exception ex)
            {
                HandleErrorInternal("CTPMD.Start()异常:" + ex.Message + "\n" + ex.StackTrace);
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (DataApi == null)
            {
                if (CheckInput() == false)
                {
                    return;
                }

                DataApi = new FtdcMdAdapter("", false, false);
                DataApi.OnFrontEvent += DataApi_OnFrontEvent;
                DataApi.OnRspEvent   += DataApi_OnRspEvent;
                DataApi.OnRtnEvent   += DataApi_OnRtnEvent;

                DataApi.RegisterFront(txtFrontMD.Text);
                DataApi.Init();
            }
        }