private void SendAmsHeartbeat()
        {
            var result = _kafkaMessageFlowInfoProvider.TryGetFlowLastMessage(AmsFactsFlow.Instance);

            if (result == null || result.IsPartitionEOF)
            {
                return;
            }

            var utcNow    = DateTime.UtcNow;
            var amsUtcNow = result.Timestamp.UtcDateTime;
            var amsIsDown = (utcNow - amsUtcNow).Duration() > AmsSyncInterval;

            var amsSystemStatus = _query.For <SystemStatus>().Single(x => x.Id == SystemStatus.SystemId.Ams);

            if (amsSystemStatus.SystemIsDown == amsIsDown)
            {
                return;
            }

            amsSystemStatus.SystemIsDown = amsIsDown;
            _repository.Update(amsSystemStatus);
            _repository.Save();
            _eventLogger.Log <IEvent>(new[] { new FlowEvent(KafkaFactsFlow.Instance, new DataObjectUpdatedEvent(typeof(SystemStatus), new[] { SystemStatus.SystemId.Ams })) });
        }
Beispiel #2
0
        private void SendAmsHeartbeat()
        {
            if (!_kafkaMessageFlowInfoProvider.TryGetFlowLastMessage(AmsFactsFlow.Instance, out var amsLastMessage))
            {
                return;
            }

            var utcNow    = DateTime.UtcNow;
            var amsUtcNow = amsLastMessage.Timestamp.UtcDateTime;
            var amsIsDown = (utcNow - amsUtcNow).Duration() > AmsSyncInterval;

            _repository.Update(new SystemStatus {
                Id = SystemStatus.SystemId.Ams, SystemIsDown = amsIsDown
            });
            _repository.Save();

            _eventLogger.Log <IEvent>(new[] { new FlowEvent(AmsFactsFlow.Instance, new DataObjectUpdatedEvent(typeof(SystemStatus), SystemStatus.SystemId.Ams)) });
        }