Esempio n. 1
0
        public async Task RunAsync([TimerTrigger("0 0,30 * * * *")] TimerInfo myTimer, ILogger log)
        {
            try
            {
                var items = await _notificationProvider.GetItemWhereDue();

                foreach (var item in items)
                {
                    log.LogInformation($"Sending Overdue item ID: {item.Id}");

                    var req = new RestRequest().AddJsonBody(new DiscordWebhook
                    {
                        Content = $"<@{_config["DiscordUserId"]}>, " + item.Content
                    });

                    await _httpClient.PostAsync <dynamic>(req);

                    item.Status = NotificationStatus.Completed;
                    await _notificationProvider.UpdateItem(item);
                }
            }
            catch (Exception e)
            {
                log.LogError($"Error while polling for notifications :: {e}");
                throw;
            }
        }