Beispiel #1
0
        static async Task Poll(string tenant)
        {
            var config = LogTool.GetConfig().GetSection(tenant);
            var conn   = new ManagementConnector(config);
            await conn.Connect();

            var allUrls = new List <string>();
            var checker = new StreamChecker(LogTool.CreateLogger <StreamChecker>(), config, config["TenantId"]);
            await checker.Connect();

            while (true)
            {
                var urls = await conn.GetContentUrls(DateTime.Now.AddMinutes(-150));

                urls = urls.Except(allUrls).ToArray();
                allUrls.AddRange(urls);
                File.WriteAllLines("urls.log", allUrls);

                foreach (var url in urls)
                {
                    await checker.Check(url);
                }

                await Task.Delay(TimeSpan.FromMinutes(5));
            }
        }
Beispiel #2
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            var    payload     = JToken.Parse(requestBody);

            if (payload is JArray data)
            {
                var conf = new ConfigurationBuilder()
                           .AddEnvironmentVariables()
                           .Build();
                var tenants  = new[] { conf.GetSection("UvA"), conf.GetSection("HvA") };
                var tenantId = (string)data[0]["tenantId"];
                log.LogInformation($"Received {data.Count} blocks (tenant {tenantId})");
                var tenant  = tenants.First(t => t["tenantId"] == tenantId);
                var checker = new StreamChecker(log, tenant, tenantId);
                await checker.Connect();

                foreach (var el in payload)
                {
                    await checker.Check(el["contentUri"].ToString());
                }
            }
            else
            {
                log.LogInformation("Received message without array");
            }

            return(new OkResult());
        }