public async Task <bool> TryLogSentMessageAsync( EmailQueueToken token, SentEmailInfo info, CancellationToken cancellationToken) { var success = false; try { if (!_initialized) { await InitializeAsync(cancellationToken); } var batch = new TableBatchOperation(); foreach (var entry in BuildEntries(token, info)) { batch.Insert(entry); } await _sentMessagesTable.Value.ExecuteBatchAsync(batch); success = true; } catch (Exception ex) { _logger.LogError("Error logging email recipients for email {0}:\n{1}", token, ex); } return(success); }
public Task <bool> TryLogSentMessageAsync(EmailQueueToken token, SentEmailInfo info, CancellationToken cancellationToken) { SentLog.AddRange(info.Recipients.Select(r => new BasicSentEmailInfo { ApplicationId = token.ApplicationId, RequestId = token.RequestId, ReceivedTime = token.TimeStamp, ApplicationName = info.ApplicationName, DequeueCount = info.DequeueCount, TemplateId = info.TemplateId, TemplateName = info.TemplateName, TransportId = info.Transport.Id, TransportType = info.Transport.Type.ToString(), TransportName = info.Transport.Name, LogLevel = info.LogLevel, ProcessedTime = info.ProcessedUtc, Subject = info.Subject, RecipientAddress = r.Address, RecipientType = r.Type.ToString() })); return(Task.FromResult(true)); }
private IEnumerable <TableEmailAuditLogEntry> BuildEntries(EmailQueueToken token, SentEmailInfo info) { foreach (var recipient in info.Recipients) { yield return(new TableEmailAuditLogEntry(token.ApplicationId, info.ProcessedUtc) { ApplicationName = info.ApplicationName, DequeueCount = info.DequeueCount, LogLevel = info.LogLevel, ReceivedTime = token.TimeStamp, RequestId = token.RequestId, TemplateId = info.TemplateId, TemplateName = info.TemplateName, TransportId = info.Transport.Id, TransportName = info.Transport.Name, TransportType = info.Transport.Type.ToString(), Subject = info.Subject, RecipientAddress = recipient.Address, RecipientType = recipient.Type.ToString() }); } }