Example #1
0
        public async Task MessageHandler(ProcessMessageEventArgs args)
        {
            string body = args.Message.Body.ToString();

            var wantedList = _repo.RetrieveWantedList();

            var lp = JsonSerializer.Deserialize <LicensePlatePayload>(body);

            //await _licenseService.SendPlate(lp);
            if (wantedList.Contains(lp.LicensePlate))
            {
                var filePath = _fileRepo.ReadImage(lp.ContextImageJpg, lp.LicensePlate);
                var uri      = await _blob.Upload(filePath);

                _fileRepo.CleanFiles(filePath);
                lp.ContextImageReference = uri;

                Console.WriteLine($"Sending:\n{lp.LicensePlateCaptureTime}\n{lp.LicensePlate}\n{lp.Longitude}\n{lp.Latitude}\n{uri}");
                var code = await _licenseService.SendPlate(lp);
            }
            // complete the message. messages is deleted from the queue.
            await args.CompleteMessageAsync(args.Message);
        }