Exemplo n.º 1
0
        public void on_login_resp(login_resp data)
        {
            Invoke((MethodInvoker) delegate
            {
                if (data.success != 0)
                {
                    MessageBox.Show("登陆失败:" + data.ErrorMsg);
                    return;
                }
                if (data.symbol != comb_Instrument.Text)
                {
                    MessageBox.Show("登陆失败:服务器返回symbol与前端symbol不一致");
                    return;
                }
                common.CompareVersion();

                order_easy.Show();
                ZMQControl.Instance().heart_beat_timer_start();
                order_easy.start_sub_recv(comb_product.Text, comb_Instrument.Text);
                order_easy.start_data_init(data);
                saveConfig();

                order_easy.operation_log("登陆成功 " + " 子帐号:" + comb_account.Text + " 合约:" + comb_Instrument.Text
                                         + " tip:" + this.current_tick + " Server:"
                                         + common.AccountDic[comb_account.Text].sertverIp + ":" + common.AccountDic[comb_account.Text].ipPort);

                this.Hide();
            });
        }
Exemplo n.º 2
0
 public void zmqTerm()
 {
     ZMQControl.Instance().stopHeartBeatTimer();
     ZMQControl.Instance().zmqTerm();
     //if (testThread != null && (testThread.ThreadState & ThreadState.Background) != 0)
     //testThread.Join();
 }
Exemplo n.º 3
0
 private void initMdfSub()
 {
     ZMQControl.Instance().Init(ZeroMQ.SocketType.SUB, "");
     foreach (KeyValuePair <string, bool> pair in common.addrDic)
     {
         if (pair.Value)
         {
             ZMQControl.Instance().Connect(pair.Key);
         }
     }
 }
Exemplo n.º 4
0
 private void runZMQ()
 {
     if (testThread == null)
     {
         testThread = new Thread((ThreadStart) delegate { ZMQControl.Instance().run(this, order_easy); });
         testThread.IsBackground = true;
         testThread.Start();
         //Thread.Sleep(1000);
         //ZMQControl.Instance().zmqTerm();
         //testThread.Join();
     }
 }
Exemplo n.º 5
0
 private void AddrConHandle()
 {
     foreach (KeyValuePair <string, bool> pair in comon.addrDic)
     {
         if (pair.Value)
         {
             ZMQControl.Instance().Connect(pair.Key);
         }
         else
         {
             ZMQControl.Instance().DisConnect(pair.Key);
         }
     }
 }
Exemplo n.º 6
0
        private void button_login_Click(object sender, EventArgs e)
        {
            if (!pswCheck(comb_account.Text, passwordBox.Text))
            {
                return;
            }
            if (!accountCheck(comb_account.Text))
            {
                MessageBox.Show("未找到数据库对应的母帐号信息");
                return;
            }

            string control_id = "easy_" + comb_account.Text + "_" + comb_product.Text;

            common.set_control_id(control_id);
            ZMQControl.Instance().setControlId(common.control_id);
            //zmqTerm();
            initZmqDealer();
            runZMQ();
            login();
        }
Exemplo n.º 7
0
        private void btnSub_Click(object sender, EventArgs e)
        {
            string name = tabControl1.SelectedTab.Name;

            if ("tab_addr_m".Equals(name))
            {
                int deleteIndex = DeleteRow(grid_addr);
                ZMQControl.Instance().DisConnect(grid_addr[deleteIndex, 0].Value + "");

                return;
            }
            else if ("tab_account_m".Equals(name))
            {
                DeleteRow(grid_account);
                //return;
            }
            else
            {
                DeleteRow(grid_category);
            }
        }
Exemplo n.º 8
0
        private void login()
        {
            login_req data = new login_req();

            data.version    = common.currentVersion;
            data.account    = common.AccountDic[comb_account.Text].motherAccount;
            data.symbol     = comb_Instrument.Text;
            data.symbol_tip = this.current_tick;

            Future temp = new Future();

            if (comb_product.Text == "stock" && common.stockDic.TryGetValue(comb_Instrument.Text, out temp))
            {
                data.exchange_type = common.stockDic[comb_Instrument.Text].exchangeId;
            }

            MemoryStream sParam = new MemoryStream();

            sParam.Seek(0, SeekOrigin.Begin);
            Serializer.Serialize <login_req>(sParam, data);
            ZMQControl.Instance().Send2Router(sParam, MessageType.OE_LOGIN_REQ);
        }
Exemplo n.º 9
0
        private void initZmqDealer()
        {
            if (!common.AccountDic.ContainsKey(comb_account.Text))
            {
                MessageBox.Show("初始化失败,数据库未找到帐号信息");
                return;
            }
            string temAddr = "tcp://" + common.AccountDic[comb_account.Text].sertverIp + ":" + common.AccountDic[comb_account.Text].ipPort;

            if (routerAddr != "" && temAddr != routerAddr)
            {
                ZMQControl.Instance().dealerDisConnect(routerAddr);
                ZMQControl.Instance().dealerConnect(temAddr);
            }
            else
            {
                if (routerAddr == "")
                {
                    ZMQControl.Instance().InitDealer(SocketType.DEALER, temAddr, common.control_id);
                }
            }
            routerAddr = temAddr;
        }
Exemplo n.º 10
0
 private void LoginForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     ZMQControl.Instance().sendReqLogout();
     zmqTerm();
 }