public Task Execute(IJobExecutionContext context) { IList <Agents> _agents = _agentsRepository.GetAgents(); foreach (var agent in _agents) { var fromTime = _repository.GetLastDate(agent.AgentId); var toTime = DateTimeOffset.Now; var metrics = _metricsAgentClient.GetRamMetrics(new GetAllRamMetricsApiRequest { FromTime = fromTime, ToTime = toTime, ClientBaseAddress = agent.AgentUrl }); if (metrics != null) { foreach (var metric in metrics) { _repository.Create(new RamMetric { Time = metric.time.ToUnixTimeSeconds(), Value = metric.value, AgentId = agent.AgentId }); } } } return(Task.CompletedTask); }