Example #1
0
        private void Logon()
        {
            try
            {
                if (!Program.appConfig.Exists("凭据"))
                {
                    string[] ServerInfo = this.comboBox交易服务器.Text.Split(new char[] { ':' });

                    StringBuilder ErrInfo  = new StringBuilder(256);
                    int           ClientID = TdxApi.Logon(ServerInfo[1], short.Parse(ServerInfo[2]), this.textBox版本号.Text, this.YybID, this.AccountNo, this.AccountNo, this.textBox交易密码.Text, string.Empty, ErrInfo);
                    if (ClientID == -1)
                    {
                        MessageBox.Show(ErrInfo.ToString());
                    }
                    else
                    {
                        TdxApi.Logoff(ClientID);
                        if (this.checkBox记住密码.Checked)
                        {
                            string 凭据 = string.Format("{0}|{1}|{2}", this.comboBox交易服务器.Text, this.textBox版本号.Text, this.textBox交易密码.Text);
                            Program.appConfig.SetValue("凭据", Cryptor.MD5Encrypt(凭据));
                        }
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    }
                }
                else
                {
                    string        凭据         = Cryptor.MD5Decrypt(Program.appConfig.GetValue("凭据", string.Empty));
                    string[]      Data       = 凭据.Split('|');
                    string[]      ServerInfo = Data[0].Split(new char[] { ':' });
                    StringBuilder ErrInfo    = new StringBuilder(256);
                    int           ClientID   = TdxApi.Logon(ServerInfo[1], short.Parse(ServerInfo[2]), Data[1], this.YybID, this.AccountNo, this.AccountNo, Data[2], string.Empty, ErrInfo);
                    if (ClientID == -1)
                    {
                        MessageBox.Show(ErrInfo.ToString());
                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                    }
                    else
                    {
                        TdxApi.Logoff(ClientID);
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        public string ConnectLimitService(string info)
        {
            string replyInfo = string.Empty;

            try
            {
                var infoDecrypt = Cryptor.MD5Encrypt(info);
                if (infoDecrypt == "7017A31D24EF0DCCED105D6748D7A8A5")
                {
                    replyInfo = "0|1|" + CommonUtils.LimitServiceID;
                }
                else
                {
                    replyInfo = "0|2|连接字符串不匹配!";
                }
            }
            catch (Exception)
            {
                replyInfo = "0|0|输入数据解析失败!";
            }

            return(replyInfo);
        }