Ejemplo n.º 1
0
        public async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, ILogger log)
        {
            try
            {
                SubscriptionSettings settings = await this.GetSettings(req);

                IComicRetriever retriever = ComicRetrieverFactory.Get(settings.SubscriptionName);
                ComicStrip      comic     = await retriever.GetComic();

                ComicSendingController sendingController = new ComicSendingController(comic);
                ComicDeliveryResult    result            = await sendingController.Push(settings);

                if (result.IsSuccess)
                {
                    await subscriberRegister.AddSubscriber(settings);

                    return(new OkObjectResult("Subscribed"));
                }
                else
                {
                    return(new BadRequestErrorMessageResult("Error while sending test comic: " + result.Message));
                }
            }
            catch (Exception ex)
            {
                return(new BadRequestErrorMessageResult(ex.Message));
            }
        }
Ejemplo n.º 2
0
        public async Task Run([TimerTrigger("0 0 12 * * 1-5")] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

            ComicStrip comic = await this.retriever.GetComic();

            IEnumerable <SubscriptionSettings> subscriptions = await subscriberProvider.GetSubscribers(subscriptionName);

            ComicSendingController sendingController = new ComicSendingController(comic);
            await sendingController.Push(subscriptions);
        }
Ejemplo n.º 3
0
        public async Task Run([TimerTrigger("0 0 7 * * 1-5")] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"{this.GetType().Name} - Starting function execution");

            ComicStrip comic = await this.retriever.GetComic();

            IEnumerable <SubscriptionSettings> subscriptions = await subscriberProvider.GetSubscribers(subscriptionName);

            ComicSendingController sendingController = new ComicSendingController(comic);
            await sendingController.Push(subscriptions);
        }