public async Task ExecuteAsync() { if (_notify.ClientsConnected() == false) { _logger.LogDebug("No Clients connected, abort job."); return; } var hosts = (await _hostService.ReadAll().ConfigureAwait(false)).ToList(); //_repository.ReadAll().ToList(); var cachedKeys = _cache.GetKeys().ToList(); var removeKeys = cachedKeys.Except(hosts.Select(x => x.IpAddress)); foreach (var key in removeKeys) { _cache.Delete(key); _logger.LogDebug($"Removed {key} from cache."); } foreach (var host in hosts) { var res = await _ping.CheckHost(host.IpAddress).ConfigureAwait(false); if (_cache.Get(host.IpAddress) != res) { _cache.AddOrUpdate(host.IpAddress, res); host.Status = res; NotifyChanged(host); } } }
public async Task <IActionResult> Get() { return(Ok(await _service.ReadAll().ConfigureAwait(false))); }