public Task Execute(IJobExecutionContext context) { DateTimeOffset toTime = DateTimeOffset.UtcNow; DateTimeOffset fromTime = _repositoryNetwork.LastTime(); IList <AgentModel> agents = _repositoryAgent.GetAll(); foreach (var agent in agents) { if (agent.Status == true) { AllNetworkMetricsApiResponse allNetworkMetrics = _client.GetAllNetworkMetrics(new GetAllNetworkMetricsApiRequest { FromTime = fromTime, ToTime = toTime, Addres = agent.Ipaddress }); if (allNetworkMetrics != null) { foreach (var metric in allNetworkMetrics.Metrics) { _repositoryNetwork.Create(new NetworkMetricModel { IdAgent = agent.Id, Time = metric.Time, Value = metric.Value }); } } } } return(Task.CompletedTask); }
public IActionResult GetList() { _logger.LogInformation("Запрос списка агентов"); var agents = _repository.GetAll(); var response = new ListAgentInfoResponse() { Agents = new List <AgentInfoResponse>() }; foreach (var agent in agents) { response.Agents.Add(_mapper.Map <AgentInfoResponse>(agent)); } return(Ok(response)); }
public IActionResult GetAll() { var metrics = _repository.GetAll(); var response = new AllAgentsResponse() { Metrics = new List <AgentManagerDto>() }; foreach (var metric in metrics) { response.Metrics.Add(new AgentManagerDto { Id = metric.Id, Status = metric.Status, IpAddress = metric.IpAddress, Name = metric.Name }); } _logger.LogInformation("Запрос всех агентов"); return(Ok(response)); }
public IEnumerable <IAgentModel> GetAll() { var agents = _repo.GetAll(); return(_mapper.Map <IEnumerable <AgentModel> >(agents)); }