Пример #1
0
        public BackgroundWorkerContinuation Work(BackgroundWorkerContext context, CancellationToken token)
        {
            var logEntry = new HeartbeatLogEntry(Time.UtcNow);

            foreach (IHeartbeatProvider provider in _providers)
            {
                logEntry.CollectFrom(provider, token);
            }

            _repository.Insert(logEntry);

            return(context.Wait(_interval));
        }
Пример #2
0
        public void Insert(HeartbeatLogEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }

            var configuration = _service.Get <HeartbeatLog>();

            configuration.Cleanup(
                (int)ReadMaximumEntries().GetValueOrDefault(500u),
                ReadMaximumAge().GetValueOrDefault(TimeSpan.FromDays(14)));

            configuration.Add(_machineName, entry);

            _service.Save(configuration, GetType().Name);
        }