Ejemplo n.º 1
0
 public MarketDataLibrary()
 {
     _wrapper = new KCBPLibraryWrapper();
     if (_wrapper.GetConnectionOption().Address == "")
     {
         //_connectionOptions = SZKingdomPool.GetAvailableSZKingdom();
         _collections = SZKingdomPool.GetAvailableSZKingdom();
         foreach (KeyValuePair <KCBPConnectionOptions, SZKingdomConfiguration> kv in _collections)
         {
             _connectionOptions = kv.Key;
             Configuration      = kv.Value;
         }
         _wrapper.SetConnectionOption(_connectionOptions);
         _wrapper.SetCliTimeOut(Configuration.Timeout);
         Logging.Logger.Debug("connect to SZKingdom server:ipAddress=" + Configuration.IpAddress + "port=" + Configuration.Port + "ServerName=" + Configuration.ServerName + "UserName="******"Password=" + Configuration.Password);
         IsConnected = false;
     }
 }
Ejemplo n.º 2
0
        public EntityResponse <DataTable> ExecuteCommand(SZKingdomRequest request, List <SZKingdomArgument> arguments)
        {
            try
            {
                EntityResponse <DataTable> result = Retry.Do(() => ExecuteInternal(request, arguments), TimeSpan.FromMilliseconds(10), 1, exception =>
                {
                    _wrapper.Disconnect();
                    //_connectionOptions = SZKingdomPool.GetAvailableSZKingdom();
                    //_wrapper.SetConnectionOption(_connectionOptions);
                    _collections = SZKingdomPool.GetAvailableSZKingdom();
                    foreach (KeyValuePair <KCBPConnectionOptions, SZKingdomConfiguration> kv in _collections)
                    {
                        _connectionOptions = kv.Key;
                        Configuration      = kv.Value;
                    }
                    _wrapper.SetConnectionOption(_connectionOptions);
                    _wrapper.SetCliTimeOut(Configuration.Timeout);
                    Logging.Logger.Debug("failover to SZKingdom Server:ipAddress=" + Configuration.IpAddress + "port=" + Configuration.Port + "ServerName=" + Configuration.ServerName + "UserName="******"Password="******"thread ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId + ", ExecuteCommand innerException:" + exception.InnerException.ToString() + "ExecuteCommand stackTraceException:" + exception.StackTrace.ToString() + ", class is MarketDataLibrary");
                throw new Exception("金正服务暂时不可用");
                //return EntityResponse<DataTable>.Error(ErrorCode.SZKingdomLibraryError,
                //    string.Format("KCBP error code: {0}. Message: {1}.", inner.ErrorCode, inner.Message));
            }
            catch (Exception ex)
            {
                Logging.Logger.Error("thread ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId + ", ExecuteCommand Exception:" + ex.StackTrace.ToString() + ", class is MarketDataLibrary");
                throw;
            }
        }