public async Task <IMaintenanceDetails> GetActiveMaintenanceDetailsAsync() { if (_isInited.HasValue && _isInited.Value) { return(_currentMaintenance); } try { var currentMaintenanceStatus = await _maintenanceEventRepository.GetMaintenanceStatusAsync(); _currentMaintenance = currentMaintenanceStatus; _isInited = true; return(currentMaintenanceStatus); } catch (Exception e) { _log.Error(e); return(null); } }
public async Task <StartMaintenanceError> StartMaintenanceAsync( string who, string reason, TimeSpan plannedDuration) { var activeMaintenance = await GetActiveMaintenanceDetailsAsync(); if (activeMaintenance != null) { return(StartMaintenanceError.AlreadyStarted); } _currentMaintenance = await _maintenanceEventRepository.StartMaintenanceAsync( who, reason, plannedDuration); if (_isInited == null) { _isInited = true; } return(StartMaintenanceError.None); }
public Task StopMaintenanceAsync() { _currentMaintenance = null; return(_maintenanceEventRepository.StopMaintenanceAsync()); }