protected async override Task OnTimer()
        {
            try
            {
                //Skip if network not available
                if (_networkStatus?.CanDownload(_downloadNetworkPriority) != true)
                {
                    _logger?.LogInformation($"Skip configuration download due to network not allowed to download.");
                    return;
                }

                _logger?.LogDebug($"Running config updater. Downloading {this.Source}.");
                var    configDownloader = UpdateUtility.CreateDownloaderFromUrl(this.Source, _context);
                string newConfig        = await configDownloader.ReadFileAsStringAsync(this.Source);

                string configPath = UpdateUtility.ResolvePath(this.Destination);
                if (!File.Exists(configPath) || !newConfig.Equals(File.ReadAllText(configPath)))
                {
                    _logger?.LogInformation($"Config file changed. Updating configuration file.");
                    File.WriteAllText(configPath, newConfig);
                }
            }
            catch (Exception ex)
            {
                _logger?.LogError($"Error download {this.Source}. Exception: {ex.ToMinimized()}");
            }
        }
Пример #2
0
        protected async override Task OnTimer()
        {
            try
            {
                _logger?.LogDebug($"Running config updater. Downloading {this.Source}.");
                var    configDownloader = UpdateUtility.CreateDownloaderFromUrl(this.Source, _context);
                string newConfig        = await configDownloader.ReadFileAsStringAsync(this.Source);

                string configPath = UpdateUtility.ResolvePath(this.Destination);
                if (!File.Exists(configPath) || !newConfig.Equals(File.ReadAllText(configPath)))
                {
                    _logger?.LogInformation($"Config file changed. Updating configuration file.");
                    File.WriteAllText(configPath, newConfig);
                }
            }
            catch (Exception ex)
            {
                _logger?.LogError($"Error download {this.Source}. Exception: {ex.ToMinimized()}");
            }
        }