Ejemplo n.º 1
0
        private void Button_SearchAccountInfo_Click(object sender, RoutedEventArgs e)
        {
            var entity = this.GetPageEntity();

            ImsApi.Init(ImsNotify);
            string errMsg = string.Empty;

            bool isLogin = ImsApi.Login(entity.交易帐号, Cryptor.MD5Decrypt(entity.交易密码), entity.版本号, out errMsg);

            if (!string.IsNullOrEmpty(errMsg) || isLogin)
            {
                MessageBox.Show(errMsg);
                return;
            }

            StringBuilder Result  = new StringBuilder(1024);
            StringBuilder ErrInfo = new StringBuilder(1024);

            if (string.IsNullOrEmpty(txt产品信息.Text))
            {
                ImsApi.ImsPbClient_RequestProductList(0, Result, ErrInfo);
                lblErrInfo产品信息.Text = ErrInfo.ToString();
                var dt = CommonUtils.ChangeDataStringToTable(Result.ToString());
                if (dt != null && dt.Rows.Count > 0 && dt.Columns.Contains("productid"))
                {
                    this.txt产品信息.Text = dt.Rows[0]["productid"] + "";
                }
            }

            if (string.IsNullOrEmpty(txt资产单元.Text))
            {
                ImsApi.ImsPbClient_RequestProductList(1, Result, ErrInfo);
                //this.txt资产单元.Text = Result.ToString();
                this.lblErrInfo资产单元.Text = ErrInfo.ToString();
                var dt = CommonUtils.ChangeDataStringToTable(Result.ToString());
                if (dt != null && dt.Rows.Count > 0 && dt.Columns.Contains("productunitid"))
                {
                    this.txt资产单元.Text = dt.Rows[0]["productunitid"] + "";
                }
            }

            if (string.IsNullOrEmpty(txt投资组合.Text))
            {
                ImsApi.ImsPbClient_RequestProductList(2, Result, ErrInfo);
                //this.txt投资组合.Text = Result.ToString();
                this.lblErrInfo投资组合.Text = ErrInfo.ToString();
                var dt = CommonUtils.ChangeDataStringToTable(Result.ToString());
                if (dt != null && dt.Rows.Count > 0 && dt.Columns.Contains("portfolioid"))
                {
                    this.txt投资组合.Text = dt.Rows[0]["portfolioid"] + "";
                }
            }

            btnSave.IsEnabled = true;
        }
Ejemplo n.º 2
0
        public string Logon()
        {
            StringBuilder ErrInfo = new StringBuilder(256);

            if (IsIMSAccount)
            {
                string Msg;
                ImsApi.Init(ImsNotify);
                bool isLogin = ImsApi.Login(this.交易帐号, Cryptor.MD5Decrypt(this.交易密码), this.版本号, out Msg);
                if (isLogin)
                {
                    this.ClientID = 0;
                    return("登录成功");
                }
                else
                {
                    return(Msg);
                }
            }
            else
            {
                try
                {
                    this.ClientID = TdxApi.Logon(this.IP, this.Port, this.版本号, this.营业部代码, this.登录帐号, this.交易帐号, Cryptor.MD5Decrypt(this.交易密码), Cryptor.MD5Decrypt(this.通讯密码), ErrInfo);
                }
                catch (Exception ex)
                {
                    CommonUtils.Log("组合号登录异常", ex);
                }

                string strError = ErrInfo.ToString();
                if (!string.IsNullOrEmpty(strError))
                {
                    //交易中心(-10016):您使用的版本太低已因为安全原因停止使用,请到官网上下载最新版本重新安装。
                    if (strError.Contains("密码") || strError.Contains("您使用的版本太低已因为安全原因停止使用"))
                    {
                        //ErrInfo.Append("登录异常,将自动禁用,请检查组合号信息!");
                        CommonUtils.Log("登录密码错误或版本过低导致登录失败,将自动停用,错误信息:{0}", strError);
                        this.启用 = false;
                    }
                    return("登录失败:" + ErrInfo.ToString());
                }
                else
                {
                    return("登录成功");
                }
            }
        }