Esempio n. 1
0
        private async Task ScanForNewAlertsAsync(Miner miner, IEnumerable <Snapshot> snapshots, IScan scan, DateTime scanTime, CancellationToken token)
        {
            var activeAlerts = (await _alertService.GetActiveByDefinitionAsync(scan.Definition.Id, since: scan.Definition.LastEnabled, token: token)).ToList();

            var result = await scan.PerformScanAsync(activeAlerts, snapshots, token);

            if (result.Skipped)
            {
                _logger.LogInformation($"Skipped scan for miner {miner.Id} definition {scan.Definition.Id}");
            }
            if (result.Failed)
            {
                _logger.LogInformation($"Creating {result.Alerts.Count()} alert(s) for miner {miner.Id} definition {scan.Definition.Id}");

                foreach (var alert in result.Alerts)
                {
                    await _alertService.AddAsync(alert, token);
                }
            }
            await _alertDefinitionService.MarkScannedAsync(scan.Definition.Id, scanTime, token);
        }