Exemplo n.º 1
0
        public Task Execute(IJobExecutionContext context)
        {
            var agentsList = _repositoryAgents.GetAll();

            foreach (var agent in agentsList)
            {
                var metricsList = _metricsAgentClient.GetAllRamMetrics(new GetAllRamMetricsApiRequest
                {
                    FromTime          = _repository.GetMaxDate(agent.AgentId),
                    ToTime            = DateTimeOffset.UtcNow,
                    ClientBaseAddress = agent.AgentURL
                });

                if (!object.ReferenceEquals(metricsList, null))
                {
                    foreach (var metric in metricsList.Metrics)
                    {
                        _repository.Create(metric, agent.AgentId);
                    }
                }
            }

            return(Task.CompletedTask);
        }