private async Task SetCurrentLinesAsNoLongerCurrent() { // Get current lines var currentLines = await _lineRepository.GetAll(LineExpression.CurrentLine()); // Set as no longer current LineBuilder.SetLinesAsNoLongerCurrent(currentLines); // Update _lineRepository.UpdateRange(currentLines); }
public async Task Run() { try { // Start watch var stopwatch = new Stopwatch(); stopwatch.Start(); // Get current lines var currentLines = await _lineRepository.GetAll(LineExpression.CurrentLine()); // Build default watchers var newDefaultWatchers = WatcherBuilder.BuildDefaultWatchers(currentLines); // Get all default watchers var defaultWatchers = await _watcherRepository.GetAll(WatcherExpression.DefaultWatcher()); // Update _watcherRepository.UpdateCollection(defaultWatchers, newDefaultWatchers); // Save await _mainDbContext.SaveChangesAsync(); // Stop watch stopwatch.Stop(); // Log into Splunk _logger.LogSplunkJob(new { newDefaultWatchers.Count, ExecutionTime = stopwatch.Elapsed.TotalSeconds }); // Return await Task.CompletedTask; } catch (Exception ex) { // Log into Splunk _logger.LogSplunkJob(new { JobFailed = ex.Message }); // Log error into Splunk _logger.LogSplunkError(ex); } }
public async Task <List <Watcher> > UpdateDefaultWatchers(List <Line> lines) { // Return if there are no lines if (lines.Count == 0) { return(new List <Watcher>()); } // Start watch var stopwatch = new Stopwatch(); stopwatch.Start(); // Get newest time var newestTime = lines.Max(x => x.Time); // Get current lines var currentLines = await _lineRepository.GetAll(LineExpression.CurrentLine(newestTime)); // Build default watchers var newDefaultWatchers = WatcherBuilder.BuildDefaultWatchers(currentLines); // Get all default watchers var defaultWatchers = await _watcherRepository.GetAll(WatcherExpression.DefaultWatcher()); // Update _watcherRepository.UpdateCollection(defaultWatchers, newDefaultWatchers); // Save await _dbContext.SaveChangesAsync(); // Stop watch stopwatch.Stop(); // Log into Splunk _logger.LogSplunkInformation("UpdateDefaultWatchers", new { newDefaultWatchers.Count, ExecutionTime = stopwatch.Elapsed.TotalSeconds }); // Return return(defaultWatchers); }