public Task Execute(IJobExecutionContext context) { try { var agents = _agentsRepository.GetAgentsList(); for (int i = 0; i < agents.Count(); i++) { if (agents[i].Enabled) { long lastTime = _repository.GetLastTime(i); DateTimeOffset fromTime = DateTimeOffset.FromUnixTimeSeconds(lastTime); var metrics = _client.GetRamMetrics(new GetAllRamMetricsApiRequest() { AgentAddress = agents[i].AgentAddress, FromTime = fromTime, ToTime = DateTimeOffset.Now }); if (metrics != null) { foreach (var metric in metrics.Metrics) { _repository.Create(new RamMetric() { AgentId = metric.AgentId, Time = metric.Time.ToUnixTimeSeconds(), Value = metric.Value }); } } } } } catch (Exception ex) { _logger.LogError(ex.Message); } return(Task.CompletedTask); }