Example #1
0
        public void ConnectivityTestCase()
        {
            bool             logonArrived         = false;
            bool             logoutArrived        = false;
            bool             connected            = false;
            ManualResetEvent manualLogonEvent     = new ManualResetEvent(false);
            ManualResetEvent manualLogoutEvent    = new ManualResetEvent(false);
            ManualResetEvent manualConnectedEvent = new ManualResetEvent(false);

            _executionEngineClient.ServerConnected += delegate()
            {
                connected = true;
                _executionEngineClient.SendLoginRequest(new Login()
                {
                    OrderExecutionProvider = TradeHubConstants.OrderExecutionProvider.Simulated
                });
                manualConnectedEvent.Set();
            };

            _executionEngineClient.LogonArrived +=
                delegate(string obj)
            {
                logonArrived = true;

                _executionEngineClient.SendLogoutRequest(new Logout
                {
                    OrderExecutionProvider = TradeHubConstants.OrderExecutionProvider.Simulated
                });
                manualLogonEvent.Set();
            };
            _executionEngineClient.LogoutArrived +=
                delegate(string obj)
            {
                logoutArrived = true;
                manualLogoutEvent.Set();
            };

            _executionEngineClient.Start();

            manualConnectedEvent.WaitOne(30000, false);
            manualLogonEvent.WaitOne(30000, false);
            manualLogoutEvent.WaitOne(30000, false);

            //Thread.Sleep(70000);

            Assert.AreEqual(true, logonArrived, "Logon Arrived");
            Assert.AreEqual(true, logoutArrived, "Logout Arrived");
        }
        /// <summary>
        /// Sends Logout request to OEE
        /// </summary>
        /// <param name="logout">TradeHub Logout object</param>
        public bool Logout(Logout logout)
        {
            try
            {
                if (_asyncClassLogger.IsInfoEnabled)
                {
                    _asyncClassLogger.Info("Sending logout request for: " + logout.OrderExecutionProvider, _type.FullName, "Logout");
                }

                // Check if OEE-Client is connected to OEE
                if (_isConnected)
                {
                    // Send logout request to OEE
                    _executionEngineClient.SendLogoutRequest(logout);
                    return(true);
                }

                if (_asyncClassLogger.IsDebugEnabled)
                {
                    _asyncClassLogger.Debug("Request not sent to OEE as OEE-Client is not connected.", _type.FullName, "Logout");
                }
                return(false);
            }
            catch (Exception exception)
            {
                _asyncClassLogger.Error(exception, _type.FullName, "Logout");
                return(false);
            }
        }