/// <summary> /// Fetches the feed statistic of a specific feed. /// </summary> /// <param name="feed">The feed.</param> /// <param name="useTableBuilder">If set to <c>true</c> use the feed tableBuilder to build an human readable output.</param> private void FetchFeedStatisticNoLock(ScheduledStatisticFeed feed, bool useTableBuilder) { StatisticFeedDefinition feedDefinition = feed.StatisticFeedDefinition; try { var newValues = new List <string?[]>(); List <object?[]>?statisticValues = feed.Source.GetStatisticFeedValues(feedDefinition.FeedId); if (statisticValues != null) { foreach (object?[] values in statisticValues) { newValues.Add(feedDefinition.FieldsDefinition .Select((field, index) => field.ValueFormatter?.Invoke((value: values[index], widthHint: field.WidthHint)) ?? values[index]?.ToString()) .ToArray() ); } } if (useTableBuilder) { _logStringBuilder.AppendLine(feed.GetTabularFeed()); } feed.SetLastResults(newValues); } catch (Exception ex) { _logger.LogDebug(ex, "Error generating statistics for {IStatisticFeedsProvider}", feed.Source.GetType().Name); throw; } }
public ScheduledStatisticFeed(IStatisticFeedsProvider source, StatisticFeedDefinition statisticFeedDefinition) { Source = source ?? throw new ArgumentNullException(nameof(source)); StatisticFeedDefinition = statisticFeedDefinition ?? throw new ArgumentNullException(nameof(statisticFeedDefinition)); NextPlannedExecution = DateTime.Now + statisticFeedDefinition.FrequencyTarget; _tableBuilder = CreateTableBuilder(); }