private async Task RunStartupJobsAsync() { var taskList = new List <Task>(); var settings = _applicationSettingsService.Settings; if (settings.AutomaticUpdateCheck) { if (settings.LastUpdateCheck.AddDays(1) < DateTime.Now) { bool isLatestVersion = await _updateService.IsLatestVersion(); settings.LastUpdateCheck = DateTime.Now; _applicationSettingsService.SaveSettings(); if (!isLatestVersion) { taskList.Add(new Task(EnqueueUpdateRequest)); } } } //taskList.Add(TestJob()); foreach (var task in taskList) { task.Start(); } await Task.WhenAll(taskList).ConfigureAwait(false); }
private string GetDefaultPassword() { try { string defaultKey = _applicationSettingsService.Settings.DefaultKey; if (defaultKey != null && defaultKey.Length == 256) { return(defaultKey); } string previousKey = defaultKey; defaultKey = new SecureRandomGenerator().GetAlphaNumericString(256); _applicationSettingsService.Settings.DefaultKey = defaultKey; _applicationSettingsService.SetSettingsStateModified(); _applicationSettingsService.SaveSettings(); Log.Information("New default bookmark key was created and saved. Previous key was: {previousKey}", previousKey); return(defaultKey); } catch (Exception e) { Log.Error(e, "GetDefaultPassword"); return("CodeRed"); } }
public ImageCacheService(ApplicationSettingsService applicationSettingsService, ImageCacheRepository imageCacheRepository) { _imageCacheRepository = imageCacheRepository; if (_imageCacheRepository.CacheSize < MinCacheSize) { _imageCacheRepository.SetCacheSize(MinCacheSize, CacheTruncatePriority.RemoveLargest); applicationSettingsService.SaveSettings(); } applicationSettingsService.OnSettingsSaved += _applicationSettingsService_OnSettingsChanged; applicationSettingsService.OnSettingsLoaded += ApplicationSettingsService_OnSettingsLoaded; }