/// <summary> /// Processes a command. /// </summary> public async Task Process(GenerateBeerReportCommand command) { // Get the map image and forecast, then write the forecast on the image ImageFile imageFile = await CreateMap(command.Location, command.BlobName); // Upload the forged beer report map image CloudBlockBlob blob = await _cloudBlobService.UploadAsync(imageFile); }
public static async Task Run( [QueueTrigger(Routes.QueueStorageReports, Connection = "AzureWebJobsStorage")] string message, ILogger log) { try { log.LogInformation($"C# Queue trigger function processed: {message}"); // Services IMessageSerializer serializer = DIContainer.Instance.GetService <IMessageSerializer>(); IGenerateBeerReportCommandHandler commandHandler = DIContainer.Instance.GetService <IGenerateBeerReportCommandHandler>(); // Deserialize the message, then process the command GenerateBeerReportCommand command = serializer.Deserialize <GenerateBeerReportCommand>(message); await commandHandler.Process(command); } catch (Exception ex) { log.LogError(ex, $"Something went wrong with the GenerateReportQueueTrigger: {message}"); throw; } }
public async Task <IActionResult> GenerateReport(ReportViewModel model) { model.RemoveNulls(); // No location passed if (string.IsNullOrEmpty(model.Location)) { model.GenerateMessage = $"Empty location input... please input valid location."; return(View("Index", model)); } // Location not found if (mapServices.SearchAddress(model.Location) == null) { model.GenerateMessage = $"Couldn't find address for location: {model.Location}. Please try again with a different location."; return(View("Index", model)); } // Prepare the queue command var queueCommand = new GenerateBeerReportCommand() { BlobName = model.Location + _cloudBlobService.GetRandomBlobName(model.Location + ".png"), Location = model.Location }; // Get and save the sas uri so we can access the blob once it's done string sasUri = await _cloudBlobService.GetBlobSasUri(queueCommand.BlobName); HttpContext.Session.SetString("sas_uri", sasUri); HttpContext.Session.SetString("blob_name", queueCommand.BlobName); // Send to the queue await _queueCommunicator.SendAsync(queueCommand); model.GenerateMessage = $"Thank you. Request for beer report in {model.Location} will be added to queue."; return(View("Index", model)); }