예제 #1
0
        public IActionResult GetMetricsByTimePeriod([FromRoute] RamMetricGetByTimePeriodRequest request)
        {
            logger.LogInformation($"From={request.From}|To={request.To}");
            var requestDAL = mapper.Map <DAL.Requests.RamMetricGetByTimePeriodRequest>(request);
            var metrics    = repository.GetByTimePeriod(requestDAL);
            var response   = new RamMetricsResponse();

            response.Metrics = metrics.Select(metric => mapper.Map <RamMetricDto>(metric)).ToList();
            return(Ok(response));
        }
예제 #2
0
        public IActionResult GetMetrics(
            [FromRoute] DateTimeOffset fromTime,
            [FromRoute] DateTimeOffset toTime)
        {
            _logger.LogInformation($"GetMetrics from:{fromTime} to:{toTime}");

            var metrics  = _repository.GetByTimePeriod(fromTime, toTime);
            var response = new RamMetricsResponse()
            {
                Metrics = new List <RamMetricDto>()
            };

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

            return(Ok(response));
        }
예제 #3
0
        public IActionResult GetMetricsFromAgent(
            [FromRoute] int agentId,
            [FromRoute] DateTimeOffset fromTime,
            [FromRoute] DateTimeOffset toTime)
        {
            var metrics  = _repository.GetByTimePeriod(agentId, fromTime, toTime);
            var response = new RamMetricsResponse()
            {
                Metrics = new List <RamMetricDto>()
            };

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

            return(Ok(metrics));
        }
        public IActionResult GetMetricsRamByTimePeriod([FromBody] TimePeriod timePeriod)
        {
            var metrics = _repository.GetByTimePeriod(timePeriod);

            var response = new AllRamMetricsResponse()
            {
                Metrics = new List <RamMetricDto>()
            };

            foreach (var metric in metrics)
            {
                response.Metrics.Add(new RamMetricDto {
                    Time = metric.Time, Value = metric.Value, Id = metric.Id
                });
            }

            _logger.LogInformation($"All records of the period: {timePeriod.From} - {timePeriod.To} displayed successfully");

            return(Ok(response));
        }