public ActionResult ShowTable(Guid?logId, Guid?eventId, Guid?componentId) { ExtentionPropertiesModel model = null; if (logId.HasValue) { var log = CurrentAccountDbContext.Logs.Find(logId); model = ExtentionPropertiesModel.Create(log); } else if (eventId.HasValue) { var eventObj = CurrentAccountDbContext.Events.Find(eventId); model = ExtentionPropertiesModel.Create(eventObj); } else if (componentId.HasValue) { var component = CurrentAccountDbContext.Components.Find(componentId); model = ExtentionPropertiesModel.Create(component); } else { throw new Exception("Не удалось найти расширенные свойства"); } return(PartialView("ExtentionPropertiesTable", model)); }
/// <summary> /// Детализация по проверке - общее состояние /// </summary> public ActionResult UnittestDetailsState(Guid id) { var unitTestRepository = CurrentAccountDbContext.GetUnitTestRepository(); var unittest = unitTestRepository.GetById(id); var model = new UnittestDetailsStateModel() { Id = id, Status = unittest.Bulb.Status, StatusEventId = unittest.Bulb.StatusEventId, StatusDuration = unittest.Bulb.GetDuration(MvcApplication.GetServerDateTime()), CanRun = unittest.IsSystemType, CanEdit = CurrentUser.CanEditCommonData(), IsEnabled = unittest.Enable, TypeId = unittest.TypeId, LastExecutionDate = unittest.Bulb.EndDate, LastExecutionResult = unittest.Bulb.GetUnitTestMessage() }; if (model.TypeId == SystemUnitTestTypes.HttpUnitTestType.Id) { model.RuleData = unittest.HttpRequestUnitTest?.Rules.FirstOrDefault()?.Url; } else if (model.TypeId == SystemUnitTestTypes.PingTestType.Id) { model.RuleData = unittest.PingRule?.Host; } else if (model.TypeId == SystemUnitTestTypes.DomainNameTestType.Id) { model.RuleData = unittest.DomainNamePaymentPeriodRule?.Domain; } else if (model.TypeId == SystemUnitTestTypes.SslTestType.Id) { model.RuleData = unittest.SslCertificateExpirationDateRule?.Url; } else if (model.TypeId == SystemUnitTestTypes.SqlTestType.Id) { model.RuleData = unittest.SqlRule?.Query; } var eventRepository = CurrentAccountDbContext.GetEventRepository(); var lastExecutionResultEvent = eventRepository.QueryAll(unittest.Id).Where(t => t.Category == EventCategory.UnitTestResult).OrderByDescending(t => t.StartDate).FirstOrDefault(); if (lastExecutionResultEvent != null && lastExecutionResultEvent.Properties.Count > 0) { model.LastExecutionResultProperties = ExtentionPropertiesModel.Create(lastExecutionResultEvent); } return(PartialView(model)); }
public PartialViewResult LastEventInfo(Guid id) { var eventRepository = CurrentAccountDbContext.GetEventRepository(); var lastEvent = eventRepository.GetLastEventByEndDate(id); if (lastEvent == null) { return(PartialView("NoLastEventInfo")); } var model = new EventTypeLastEventModel() { Id = lastEvent.Id, EndDate = lastEvent.EndDate, Message = lastEvent.Message }; model.Properties = ExtentionPropertiesModel.Create(lastEvent); // событие метрики if (lastEvent.Category.IsMetricCategory()) { var metricRepository = CurrentAccountDbContext.GetMetricRepository(); var metric = metricRepository.GetById(lastEvent.OwnerId); model.Metric = metric; model.Component = metric.Component; } // событие проверки else if (lastEvent.Category.IsUnitTestCategory()) { var unitTestRepository = CurrentAccountDbContext.GetUnitTestRepository(); var unitTest = unitTestRepository.GetById(lastEvent.OwnerId); model.Unittest = unitTest; model.Component = unitTest.Component; } else // событие компонента { var componentRepository = CurrentAccountDbContext.GetComponentRepository(); model.Component = componentRepository.GetById(lastEvent.OwnerId); } return(PartialView(model)); }