Exemple #1
0
        private async Task <IEnumerable <ScenarioData> > FilterNewSignalsAsync(
            IEnumerable <TraceRecord> traceRecords,
            NotifyFilter filter,
            CancellationToken token)
        {
            var newSignalsMatchingFilter = new List <ScenarioData>();

            foreach (var oneTraceRecord in traceRecords.OrderBy(record => record.TimeStamp))
            {
                // Encapsulate the new information into a shareable abstraction. We mark the event seen time as current time
                // which may not be completely accurate but it's close enough for all purposes.
                var scenarioData = new ScenarioData(filter.TargetScenario, oneTraceRecord, DateTime.UtcNow);

                if (DateTime.UtcNow - oneTraceRecord.TimeStamp > filter.SignalAvailableForAtLeastDuration)
                {
                    if (!await this.IsSignalAlreadyReportedAsync(scenarioData, token).ConfigureAwait(false))
                    {
                        newSignalsMatchingFilter.Add(scenarioData);
                    }
                }
            }

            return(newSignalsMatchingFilter);
        }
Exemple #2
0
 private Task <bool> IsSignalAlreadyReportedAsync(ScenarioData signal, CancellationToken token)
 {
     return(this.reportedSignalsUniqueIdsStore.IsKeyPresentAsync(signal.TraceRecord.GetUniqueId(), token));
 }