Ejemplo n.º 1
0
        public IActionResult GetMetricsFromAgent([FromRoute] RamMetricGetByIntervalForAgentRequest request)
        {
            _logger.LogDebug("Вызов метода. Параметры:" +
                             $" {nameof(request.AgentId)} = {request.AgentId}" +
                             $" {nameof(request.FromTime)} = {request.FromTime}" +
                             $" {nameof(request.ToTime)} = {request.ToTime}");

            var metrics = _repository.GetByTimeInterval(request.AgentId, request.FromTime, request.ToTime);

            var response = new AllMetricsResponse <RamMetricDto>();

            foreach (var metric in metrics.Metrics)
            {
                response.Metrics.Add(_mapper.Map <RamMetricDto>(metric));
            }

            return(Ok(response));
        }
Ejemplo n.º 2
0
        public IActionResult GetMetricsFromAgent([FromRoute] DateTimeOffset fromTime, [FromRoute] DateTimeOffset toTime)
        {
            _logger.LogInformation($"Метод GetMetricsFromAgent fromTime {fromTime.DateTime} toTime {toTime.DateTime}");
            var metrics  = _repository.GetByTimeInterval(fromTime, toTime);
            var response = new AllRamMetricsApiResponse()
            {
                Metrics = new List <RamMetricsDto>()
            };

            if (metrics != null)
            {
                foreach (var metric in metrics)
                {
                    response.Metrics.Add(_mapper.Map <RamMetricsDto>(metric));
                }
            }
            return(Ok(response));
        }