private List<HealthItemViewModel> CreateOfflineApplicationHealthModels(IList<Models.PathModel> paths) { var healthItemViewModels = new List<HealthItemViewModel>(); foreach (var path in paths) { logger.LogInformation($"{nameof(Action)}: Skipping health check for: {path.Path}, because it is offline"); var healthItemViewModel = new HealthItemViewModel() { Service = path.Path, Message = $"Skipped health check for: {path.Path}, because it is offline", }; healthItemViewModels.Add(healthItemViewModel); } return healthItemViewModels; }
private void AppendApplicationsHealths(List<HealthItemViewModel> healthItemModels, IEnumerable<ApplicationHealthModel> applicationHealthModels) { // get the task results as individual health and merge into one foreach (var applicationHealthModel in applicationHealthModels) { if (applicationHealthModel.RetrievalTask.IsCompletedSuccessfully) { logger.LogInformation($"{nameof(Action)}: Received child Health for: {applicationHealthModel.Path}"); var healthItems = applicationHealthModel.RetrievalTask.Result; if (healthItems?.Count() > 0) { var healthItemViewModels = (from a in healthItems select new HealthItemViewModel { Service = a.Service, Message = a.Message, }).ToList(); healthItemModels.AddRange(healthItemViewModels); } else { var healthItemViewModel = new HealthItemViewModel { Service = applicationHealthModel.Path, Message = $"No health response from {applicationHealthModel.Path} app", }; healthItemModels.Add(healthItemViewModel); } } else { logger.LogError($"{nameof(Action)}: Error getting child Health for: {applicationHealthModel.Path}"); } } }