Ejemplo n.º 1
0
        public IActionResult GetMetricsFromAgent([FromRoute] HddMetricGetByIntervalForAgentRequest 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 <HddMetricDto>();

            foreach (var metric in metrics.Metrics)
            {
                response.Metrics.Add(_mapper.Map <HddMetricDto>(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 AllHddMetricsResponse()
            {
                Metrics = new List <HddMetricsDto>()
            };

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