Пример #1
0
        public Task Execute(IJobExecutionContext context)
        {
            var agentList = _repositoryAgent.GetAllAgents();

            foreach (var agent in agentList)
            {
                string agentAddress = _repositoryAgent.GetAddressForId(agent.AgentId);

                var fromTime = _repositoryNetwork.GetDateTimeOfLastRecord(agent.AgentId);
                var toTime   = DateTimeOffset.UtcNow;

                var metrics = _metricsAgentClient.GetNetworkMetrics(new GetAllNetworkMetricsApiRequest()
                {
                    FromTime          = fromTime,
                    ToTime            = toTime,
                    ClientBaseAddress = agentAddress
                });

                if (metrics != null)
                {
                    foreach (var metricFromAgent in metrics.Metrics)
                    {
                        _repositoryNetwork.Create(agent.AgentId, metricFromAgent);
                    }
                }
            }
            return(Task.CompletedTask);
        }