public ConnectionCode Connect() { //新建连接 _config = new CT2Configinterface(); int iRet = _config.Load("config/t2sdk-subscriber.ini"); if (iRet != 0) { string msg = "主推业务读取[config/t2sdk-subscriber.ini]连接配置对象失败!"; logger.Error(msg); return(ConnectionCode.ErrorReadConf); } _conn = new CT2Connection(_config); //使用Create2BizMsg调用,则收到业务回调是OnReceivedBizMsg iRet = _conn.Create2BizMsg(this); if (iRet != 0) { string msg = string.Format("主推业务连接对象初始化失败: {0}, {1}", iRet, _conn.GetErrorMsg(iRet)); logger.Error(msg); return(ConnectionCode.ErrorInitConn); } try { iRet = _conn.Connect(_timeOut); } catch (Exception e) { string msg = e.Message; logger.Error(msg); } if (iRet != 0) { string msg = string.Format("主推业务连接失败: {0}, {1}", iRet, _conn.GetErrorMsg(iRet)); logger.Error(msg); return(ConnectionCode.ErrorConn); } else { string msg = "主推业务连接成功"; logger.Info(msg); } _isInit = true; return(ConnectionCode.Success); }
public ConnectionCode Init() { ///新建连接 //_config = new CT2Configinterface(); //int iRet = _config.Load("config/t2sdk.ini"); //if (iRet != 0) //{ // string msg = "读取连接配置对象失败!"; // logger.Error(msg); // return ConnectionCode.ErrorReadConf; //} _conn = new CT2Connection(_config); T2SDKCallbackImpl callbackImpl = new T2SDKCallbackImpl(this); //使用Create2BizMsg调用,则收到业务回调是OnReceivedBizMsg int iRet = _conn.Create2BizMsg(callbackImpl); if (iRet != 0) { string msg = string.Format("连接对象初始化失败: {0}, {1}", iRet, _conn.GetErrorMsg(iRet)); logger.Error(msg); return(ConnectionCode.ErrorInitConn); } try { iRet = _conn.Connect(_timeOut); } catch (Exception e) { Console.WriteLine(e.Message); } if (iRet != 0) { string msg = string.Format("连接失败: {0}, {1}", iRet, _conn.GetErrorMsg(iRet)); logger.Error(msg); return(ConnectionCode.ErrorConn); } else { string msg = "连接成功"; logger.Info(msg); } _isInit = true; return(ConnectionCode.Success); }
public EntrustHunsun() { try { CT2Configinterface config = new CT2Configinterface(); config.Load("t2sdk.ini"); //连接主 connMain = new CT2Connection(config); connMain.Create2BizMsg(this); int ret = connMain.Connect(5000); if (ret != 0) { Debug.Print(string.Format("Main:连接{0}失败 错误号 {1} 错误信息 {2}", config.GetString("t2sdk", "servers", ""), ret, connMain.GetErrorMsg(ret))); } else { Debug.Print((string.Format("Main:连接{0}成功", config.GetString("t2sdk", "servers", "")))); } //连接子 connSub = new CT2Connection(config); connSub.Create(null); ret = connSub.Connect(5000); if (ret != 0) { Debug.Print(string.Format("Sub:连接{0}失败 错误号 {1} 错误信息 {2}", config.GetString("t2sdk", "servers", ""), ret, connSub.GetErrorMsg(ret))); } else { Debug.Print((string.Format("Sub:连接{0}成功", config.GetString("t2sdk", "servers", "")))); } } catch (Exception e) { Debug.Print(e.Message); } }
public EntrustHundsun() { this.name = "恒生UFX委托接口"; this.Vendor = EntrustVendor.Hundsun; MessageManager.GetInstance().Add(MessageType.Warning, "对于x64的机器需要更换引用的ext_t2sdkEx.dll"); try { CT2Configinterface config = new CT2Configinterface(); config.Load(Config.GetInstance().GetParameter(Config.C_PATH_HUNDSUN_CONFIG).ToString()); #region 打开连接 //主连接 connMain = new CT2Connection(config); connMain.Create2BizMsg(new UFXMainCallback()); int ret = connMain.Connect(5000); if (ret != 0) { MessageManager.GetInstance().Add(MessageType.Error, string.Format("连接{0}失败:main-{1}", config.GetString("t2sdk", "servers", ""), connMain.GetErrorMsg(ret))); return; } //子连接 connSub = new CT2Connection(config); connSub.Create(null); ret = connSub.Connect(5000); if (ret != 0) { MessageManager.GetInstance().Add(MessageType.Error, string.Format("连接{0}失败:sub-{1}", config.GetString("t2sdk", "servers", ""), connSub.GetErrorMsg(ret))); } #endregion } catch (Exception ex) { MessageManager.GetInstance().Add(MessageType.Error, ex.Message + "请检查license.dat文件是否存在。"); throw ex; } }