public async Task Synchronize(CancellationToken cancellationToken) { var bearerToken = await _authenticator.GetBearerTokenForApplicationAsync(); _bearerTokenSetter.SetBearerToken(bearerToken, false); _currentUserSetter.SetCurrentUserOid(_synchronizationUserOid); var currentUser = _claimsProvider.GetCurrentUser(); var claimsIdentity = new ClaimsIdentity(); claimsIdentity.AddClaim(new Claim(ClaimsExtensions.Oid, _synchronizationUserOid.ToString())); currentUser.AddIdentity(claimsIdentity); foreach (var plant in await _plantCache.GetPlantWithAccessForUserAsync(_synchronizationUserOid)) { _logger.LogInformation($"Synchronizing plant {plant}..."); _plantSetter.SetPlant(plant); await _claimsTransformation.TransformAsync(currentUser); var startTime = TimeService.UtcNow; // todo Synchronize here var endTime = TimeService.UtcNow; _logger.LogInformation($"Plant {plant} synchronized. Duration: {(endTime - startTime).TotalSeconds}s."); _telemetryClient.TrackMetric("Synchronization Time", (endTime - startTime).TotalSeconds, "Plant", plant); } }
public async Task <IList <string> > GetPlants() { var currentUserOid = _currentUserProvider.GetCurrentUserOid(); var plants = await _plantCache.GetPlantWithAccessForUserAsync(currentUserOid); return(plants); }