Example #1
0
        private async Task AllCheck(StatusDbContext dbContext, HTTPService http)
        {
            var items = await dbContext.MonitorRules.ToListAsync();

            foreach (var item in items)
            {
                _logger.LogInformation($"Checking status for: {item.ProjectName}");
                try
                {
                    var content = await http.Get(new AiurUrl(item.CheckAddress));

                    var success = content.Contains(item.ExpectedContent);
                    if (!success)
                    {
                        var errorMessage = $"Status check for {item.ProjectName} did not pass. Expected: {item.ExpectedContent}. Got content: {content}";
                        _logger.LogError(errorMessage);
                    }
                    item.LastHealthStatus = success;
                    item.LastCheckTime    = DateTime.UtcNow;
                    dbContext.Update(item);
                }
                catch (Exception e)
                {
                    var errorMessage = $"Status check for {item.ProjectName} did not pass. Expected: {item.ExpectedContent}. Got error: {e.Message}";
                    _logger.LogError(errorMessage);
                    item.LastHealthStatus = false;
                    item.LastCheckTime    = DateTime.UtcNow;
                }
                finally
                {
                    await dbContext.SaveChangesAsync();
                }
            }
        }
Example #2
0
 public EventController(
     ACTokenManager tokenManager,
     StatusDbContext dbContext)
 {
     _tokenManager = tokenManager;
     _dbContext    = dbContext;
 }
Example #3
0
        private async Task AllClean(StatusDbContext dbContext)
        {
            var oldestRecordTime = DateTime.UtcNow - TimeSpan.FromDays(7);
            var items            = await dbContext.ErrorLogs.Where(t => t.LogTime < oldestRecordTime).ToListAsync();

            dbContext.ErrorLogs.RemoveRange(items);
            await dbContext.SaveChangesAsync();
        }
Example #4
0
 public HomeController(StatusDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Example #5
0
 public PickingPersonRepository(StatusDbContext context)
 {
     _context = context;
 }
 public StatusMessageReceivedHandler(StatusDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Example #7
0
 public ProjectRepository(StatusDbContext context)
 {
     _context = context;
 }
 public AccountRepository(StatusDbContext context)
 {
     _context = context;
 }
Example #9
0
 public WellRepository(StatusDbContext context)
 {
     _context = context;
 }