コード例 #1
0
#pragma warning disable IDE0060 // Remove unused parameter
        public static async Task RunAsync([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer, ILogger log)
        {
            log = LogDisabler.GetLogger(log);
            await SchedulingLogic.DoSchedulingAsync(log).ConfigureAwait(true);

            await SchedulingLogic.ClearAllRepeatedMessagesAsync(log, default).ConfigureAwait(true);
        }
コード例 #2
0
        public static async Task <IActionResult> RunAsync
        (
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "callback")]
            HttpRequest req,
            ILogger log
        )
        {
            log = LogDisabler.GetLogger(log);

            log.LogInformation(req.Method);

            if (req.Method == HttpMethods.Get)
            {
                return(new OkObjectResult("works"));
            }

            string requestBody;

            using (var streamReader = new StreamReader(req.Body))
                requestBody = await streamReader.ReadToEndAsync().ConfigureAwait(false);
            log.LogInformation(requestBody);

            var cancellation = req.HttpContext.RequestAborted;

            var query = JsonConvert.DeserializeObject <Req>(requestBody);

            if (query.callback_query == null && query.message == null)
            {
                return(new OkObjectResult("wtf telegram"));
            }

            if (query.callback_query != null)
            {
                log.LogInformation("received callback");

                var taskId = Int32.Parse(query.callback_query.data);

                await SchedulingLogic.DoneTaskAsync(taskId, query.callback_query, log, cancellation).ConfigureAwait(false);
            }
            if (query.message != null)
            {
                log.LogInformation("received message");
                await MessageProcessor.ProcessMessageAsync(query.message, log, cancellation).ConfigureAwait(false);
            }
            return(new OkObjectResult("Ok"));
        }