public ActionResult ForEventTypeAnyComponentsByInterval(Guid eventTypeId, TimelineInterval interval) { var toDate = MvcApplication.GetServerDateTime(); var fromDate = TimelineHelper.IntervalToStartDate(toDate, interval); return(ForEventTypeAnyComponents(eventTypeId, fromDate, toDate)); }
public ActionResult ForMetricByInterval(Guid id, EventCategory category, TimelineInterval interval) { var toDate = MvcApplication.GetServerDateTime(); var fromDate = TimelineHelper.IntervalToStartDate(toDate, interval); return(ForMetric(id, category, fromDate, toDate)); }
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)); }
public ActionResult Index(TimelineInterval?interval) { var userSettingService = CurrentAccountDbContext.GetUserSettingService(); var savedInterval = (TimelineInterval?)userSettingService.ComponentHistoryInterval(CurrentUser.Id) ?? TimelineInterval.Hour; if (interval != null) { userSettingService.ComponentHistoryInterval(CurrentUser.Id, (int)interval.Value); DbContext.SaveChanges(); } var model = new IndexModel() { Interval = interval ?? savedInterval }; model.ToDate = MvcApplication.GetServerDateTime(); model.FromDate = TimelineHelper.IntervalToStartDate(model.ToDate, model.Interval); return(View(model)); }
public PartialViewResult ShowTimelinesEventsPartial(Guid id, TimelineInterval interval, bool all = false) { var toDate = MvcApplication.GetServerDateTime(); var fromDate = TimelineHelper.IntervalToStartDate(toDate, interval); var eventTypeRepository = CurrentAccountDbContext.GetEventTypeRepository(); var eventTypes = eventTypeRepository.QueryAll().Select(t => new { t.Id, t.DisplayName }).ToDictionary(t => t.Id, t => t); var eventRepository = CurrentAccountDbContext.GetEventRepository(); var query = eventRepository.QueryAllByAccount() .Where(t => t.OwnerId == id && t.StartDate <= toDate && t.ActualDate >= fromDate); if (all) { query = query.Where(t => t.Category == EventCategory.ApplicationError || t.Category == EventCategory.ComponentEvent); } else { query = query.Where(t => t.Category == EventCategory.ApplicationError); } var events = query .GroupBy(t => t.EventTypeId) .Select(t => new { Id = t.Key, Importance = t.Max(z => z.Importance), Count = t.Sum(z => z.Count), LastMessage = t.OrderByDescending(z => z.StartDate).FirstOrDefault().Message }) .ToArray(); var model = new ComponentShowTimelinesGroupModel() { FromDate = fromDate, ToDate = toDate, HideUptime = true, Items = events .Select(t => new { Id = t.Id, Importance = t.Importance, Count = t.Count, Name = eventTypes[t.Id].DisplayName, LastMessage = t.LastMessage }) .OrderByDescending(t => t.Importance) .ThenByDescending(t => t.Count) .ThenBy(t => t.Name) .Take(MaxEventTimelineCount) .Select(t => new ComponentShowTimelinesGroupItemModel() { Action = "ForEventType", Category = null, OwnerId = id, EventTypeId = t.Id, Importance = t.Importance, Name = t.Name, Count = t.Count, Comment = t.LastMessage, Url = Url.Action("Show", "EventTypes", new { Id = t.Id }) }) .ToArray() }; return(PartialView("~/Views/Components/ShowTimelinesPartialGroup.cshtml", model)); }