internal static void PrepareFeedConnectionTesters(string address, string username, string password, IEnumerable <int> ports, ICollection <ConnectionTester> testers)
        {
            if (address == null)
            {
                throw new ArgumentNullException(nameof(address));
            }

            if (ports == null)
            {
                ports = Ports;
            }

            foreach (var element in ports)
            {
                var builder = new LrpConnectionStringBuilder
                {
                    Address  = address,
                    Port     = element,
                    Username = username,
                    Password = password
                };

                var tester = new ConnectionTester(builder);
                testers.Add(tester);
            }
        }
        /// <summary>
        /// The method tries to connect to remote server and returns list of valid connection strings.
        /// </summary>
        /// <param name="address">host name or IP address; can not benull</param>
        /// <param name="ports">list of ports, which should be checked; can be null in this case list of predefined ports will be checked</param>
        /// <param name="timeoutInMs">timeout in ms of connection establishing; can be zero or negative in this case default timeout will be used</param>
        /// <returns>list of valid connection strings</returns>
        public static ConnectionStringBuilder[] TestConnections(string address, IEnumerable <int> ports = null, int timeoutInMs = 0)
        {
            CheckConnectionParameters(address, string.Empty, string.Empty);
            var testers = new List <ConnectionTester>();

            FixConnectionStringBuilder.PrepareConnectionTesters(address, string.Empty, string.Empty, ports, testers);
            LrpConnectionStringBuilder.PrepareConnectionTesters(address, string.Empty, string.Empty, ports, testers);
            var result = TestConnections <ConnectionStringBuilder>(testers, timeoutInMs);

            return(result);
        }
        /// <summary>
        /// The method tries to connect to remote server and returns list of valid connection strings.
        /// </summary>
        /// <param name="username">a valid username</param>
        /// <param name="password">a valid password</param>
        /// <param name="address">host name or IP address; can not benull</param>
        /// <param name="ports">list of ports, which should be checked; can be null in this case list of predefined ports will be checked</param>
        /// <param name="timeoutInMs">timeout in ms of connection establishing; can be zero or negative in this case default timeout will be used</param>
        /// <returns>list of valid connection strings</returns>
        public static ConnectionStringBuilder[] TestTradeConnections(string address, string username, string password, IEnumerable <int> ports = null, int timeoutInMs = 0)
        {
            CheckConnectionParameters(address, username, password);
            var testers = new List <ConnectionTester>();

            FixConnectionStringBuilder.PrepareTradeConnectionTesters(address, username, password, ports, testers);
            LrpConnectionStringBuilder.PrepareTradeConnectionTesters(address, username, password, ports, testers);
            var result = TestTradeConnections <ConnectionStringBuilder>(testers, timeoutInMs);

            return(result);
        }
Beispiel #4
0
        static ConnectionStringBuilder CreateLrpConnectionStringBuilder(string address, string username, string password, string logDirectory)
        {
            var result = new LrpConnectionStringBuilder
            {
                Address = address,
                EnableQuotesLogging = true,
                EventsLogFileName = Path.Combine(logDirectory, string.Format("LRP_{0}.feed.events.log", username)),
                MessagesLogFileName = Path.Combine(logDirectory, string.Format("LRP_{0}.feed.messages.log", username)),

                Username = username,
                Password = password
            };

            return result;
        }
Beispiel #5
0
        internal static void PrepareFeedConnectionTesters(string address, string username, string password, IEnumerable<int> ports, ICollection<ConnectionTester> testers)
        {
            if (address == null)
                throw new ArgumentNullException(nameof(address));

            if (ports == null)
                ports = Ports;

            foreach (var element in ports)
            {
                var builder = new LrpConnectionStringBuilder
                {
                    Address = address,
                    Port = element,
                    Username = username,
                    Password = password
                };

                var tester = new ConnectionTester(builder);
                testers.Add(tester);
            }
        }