예제 #1
0
        public void StartWiftSession(WiftService wService)
        {
            wiftService = wService;
            _ds         = new DataStore();
            try
            {
                if (!_wiftConn.StartSession())
                {
                    var errMsg = "ERROR : Wift session start failed...";
                    Console.WriteLine(errMsg);
                    _logger.Information(errMsg);
                    return;
                }

                // we have a valid wift session
                AssignDelegates(_ds);

                while (!stopEvent.WaitOne(0))
                {
                    _logger.Information("SUCCESS : Wift session started ok...");
                    response = null;
                    session  = _wiftConn.GetSession();

                    // block until a new wift payload has been received
                    while ((response = session.GetData(3)) != null)
                    {
                        if (response.IsSuccessStatusCode)
                        {
                            try
                            {
                                // WriteLine(response.ContentAsString);
                                _ds.Update(response.HttpResponseMessage);
                                if (!fullSnapshot && response.SnapshotCount == "0")
                                {
                                    fullSnapshot = true;
                                    Console.WriteLine(">> full snapshot");
                                }
                                else
                                {
                                }
                                Console.WriteLine("wift seq no: " + response.SequenceNumber);
                            }
                            catch (Exception ex)
                            {
                                _logger.Information("ERROR : Wift data exception on sequence no: " + response.SequenceNumber);
                                _logger.Information(ex.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var errMsg = $"ERROR : Wift exception...\r\n{ex.Message}";
                Console.WriteLine(errMsg);
                _logger.Information(errMsg);
            }
        }
예제 #2
0
        public void Service_is_created()
        {
            var sut = new WiftService(
                mockLogger.Object,
                mockConfig.Object,
                mockWiftWrapper.Object,
                mockPoolSvc.Object,
                mockDivSvc.Object,
                mockRunnerSvc.Object,
                mockRaceSvc.Object,
                mockMeetingSvc.Object
                );

            Assert.IsInstanceOf <WiftService>(sut);
        }