public string Test(string IP, short Port, string Version, short YybID, string AccountNo, string TradeAccount, string JyPassword, string TxPassword) { try { StringBuilder Result = new StringBuilder(1024 * 1024); StringBuilder ErrInfo = new StringBuilder(256); int ClientID = TdxApi.Logon(IP, Port, Version, YybID, AccountNo, TradeAccount, JyPassword, TxPassword, ErrInfo); if (ClientID == -1) { return(string.Format("{0}|{1}", ClientID, ErrInfo)); } TdxApi.QueryData(ClientID, 5, Result, ErrInfo); TdxApi.Logoff(ClientID); return(string.Format("{0}|{1}", Result, ErrInfo)); } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// /// </summary> /// <param name="dataType">表示查询信息的种类,0资金 1股份 2当日委托 3当日成交 4可撤单 5股东代码 6融资余额 7融券余额 8可融证券</param> /// <returns></returns> internal void QueryAccountData(int dataType, GroupClient.GroupService.Queryinfo QueryResult) { StringBuilder result = new StringBuilder(1024 * 1024); StringBuilder errInfo = new StringBuilder(256); try { if (this.ClientID == -1) { this.ClientID = TdxApi.Logon(this.IP, this.Port, this.版本号, this.营业部代码, this.登录帐号, this.交易帐号, Cryptor.MD5Decrypt(this.交易密码), Cryptor.MD5Decrypt(this.通讯密码), errInfo); isLogonInterim = this.ClientID > -1; } if (this.ClientID > -1) { TdxApi.QueryData(this.ClientID, dataType, result, errInfo); } } catch (Exception ex) { errInfo.AppendFormat("查询接口异常:{0}", ex.Message); } QueryResult.Error = errInfo.ToString(); QueryResult.Result = result.ToString(); if (isLogonInterim) { isLogonInterim = false; } }
public bool Test(string IP, short Port, string Version, short YybID, string AccountNo, string TradeAccount, string JyPassword, string TxPassword) { try { StringBuilder Result = new StringBuilder(1024 * 1024); StringBuilder ErrInfo = new StringBuilder(256); int ClientID = TdxApi.Logon(IP, Port, Version, YybID, AccountNo, TradeAccount, JyPassword, TxPassword, ErrInfo); if (ClientID == -1) { MessageBox.Show("登录测试失败:" + ErrInfo.ToString()); return(false); } TdxApi.QueryData(ClientID, 5, Result, ErrInfo); TdxApi.Logoff(ClientID); return(true); } catch (Exception ex) { CommonUtils.Log("组合号添加异常:" + ex.Message); return(false); } }
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("登录成功"); } } }
public void Repay(string amount, StringBuilder Result, StringBuilder ErrInfo) { try { if (this.ClientID == -1) { this.ClientID = TdxApi.Logon(this.IP, this.Port, this.版本号, this.营业部代码, this.登录帐号, this.交易帐号, Cryptor.MD5Decrypt(this.交易密码), Cryptor.MD5Decrypt(this.通讯密码), ErrInfo); isLogonInterim = this.ClientID > -1; } if (this.ClientID > -1) { TdxApi.Repay(this.ClientID, amount, Result, ErrInfo); } } catch (Exception ex) { ErrInfo.AppendFormat("Repay异常:{0}", ex.Message); } if (isLogonInterim) { isLogonInterim = false; } }