public async Task CreateCommand(string address, string email) { var msg = new AddressTransactionReportQueueCommand { Address = address, Email = email }; await _queue.PutRawMessageAsync(msg.ToJson()); }
public async Task CreateReport(AddressTransactionReportQueueCommand command) { try { await _log.WriteInfoAsync(nameof(AddressTransactionsQueueFunctions), nameof(CreateReport), command.ToJson(), "Started"); await _addressTransactionsReportMetadataRepository.SetProcessing(command.Address); var reportDate = DateTime.UtcNow; var reportData = await _addressTransactionReportService.GetTransactionsReport(command.Address); var saveResult = await _addressTransactionsReportStorage.SaveXlsxReport(command.Address, reportData); var emailMes = new EmailMessage { Subject = $"Report for {command.Address} at {reportDate:f}", TextBody = $"Report for {command.Address} at {reportDate:f} - {saveResult.Url}" }; if (!string.IsNullOrEmpty(command.Email)) { await _emailSenderProducer.SendAsync(emailMes, new EmailAddressee() { DisplayName = command.Email, EmailAddress = command.Email }); } await _addressTransactionsReportMetadataRepository.SetDone(command.Address, saveResult.Url); await _log.WriteInfoAsync(nameof(AddressTransactionsQueueFunctions), nameof(CreateReport), command.ToJson(), "Done"); } catch (Exception e) { await _log.WriteFatalErrorAsync(nameof(AddressTransactionsQueueFunctions), nameof(CreateReport), command.ToJson(), e); await _addressTransactionsReportMetadataRepository.SetError(command.Address, e.ToString()); throw; } }