Exemplo n.º 1
0
        /// <summary>
        /// Детализация по метрике - Значения
        /// </summary>
        public ActionResult MetricDetailsValues(Guid id)
        {
            var metricRepository = CurrentAccountDbContext.GetMetricRepository();
            var metric           = metricRepository.GetById(id);

            var metricHistoryRepository = CurrentAccountDbContext.GetMetricHistoryRepository();
            var rows = metricHistoryRepository
                       .QueryAllByMetricType(metric.ComponentId, metric.MetricTypeId)
                       .OrderByDescending(t => t.BeginDate)
                       .Take(10);

            var model = new MetricDetailsValuesModel()
            {
                Id   = metric.Id,
                Data = rows.Select(t => new MetricDetailsValuesModel.History()
                {
                    Date      = t.BeginDate,
                    Value     = t.Value,
                    Color     = t.Color,
                    HasSignal = t.HasSignal
                }).ToArray()
            };

            return(PartialView(model));
        }
        public ActionResult GraphByInterval(Guid id, TimelineInterval interval)
        {
            var toDate   = MvcApplication.GetServerDateTime();
            var fromDate = TimelineHelper.IntervalToStartDate(toDate, interval);

            var metricRepository = CurrentAccountDbContext.GetMetricRepository();
            var metric           = metricRepository.GetById(id);

            var metricHistoryRepository = CurrentAccountDbContext.GetMetricHistoryRepository();
            var rows = metricHistoryRepository
                       .GetByPeriod(metric.ComponentId, fromDate, toDate, new[] { metric.MetricTypeId })
                       .OrderBy(t => t.BeginDate)
                       .ToArray();

            var model = GetCounterGraphDataModel(metric.MetricType, rows);

            return(PartialView("GraphPartial", model));
        }