Esempio n. 1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    string            token    = refreshToken();
                    var               urlArral = ConfigExtensions.GetListAppSettings <string>("url");
                    HttpRequestClient http     = new HttpRequestClient();
                    http.ContentType = "application/json";
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    dictionary.Add("Authorization", "Bearer " + token);
                    http.dicion = dictionary;
                    foreach (var url in from url in urlArral let html = http.HttpGet(url) where html.StatusCode == HttpStatusCode.OK select url)
                    {
                        _logger.LogInformation("执行------>>>>>" + url + "-------<<<<成功");
                    }

                    //需要执行的任务
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex.Message);
                }

                await Task.Delay(Convert.ToInt32(ConfigExtensions.Configuration["Interval"]), stoppingToken);
            }
        }