Class NewsletterEventService
Provides methods for interacting with newsletter events.
Implements
Inherited Members
Namespace: DataWeb.Newsletter
Assembly: DataWeb.Core.dll
Syntax
public class NewsletterEventService : INewsletterEventService
Remarks
Initializes a new instance of the NewsletterEventService class.
Constructors
NewsletterEventService(INewsletterEventStore, INewsletterEventHandler)
Provides methods for interacting with newsletter events.
Declaration
public NewsletterEventService(INewsletterEventStore eventStore, INewsletterEventHandler newsletterEventHandler)
Parameters
Type | Name | Description |
---|---|---|
INewsletterEventStore | eventStore | The event store. |
INewsletterEventHandler | newsletterEventHandler |
Remarks
Initializes a new instance of the NewsletterEventService class.
Methods
BatchInsertEventsAsync(string, List<NewsletterEventBatchInsert>, CancellationToken)
Inserts a batch of newsletter events into the event store for the specified row identifier.
Declaration
public Task BatchInsertEventsAsync(string rowIdMaster, List<NewsletterEventBatchInsert> events, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | rowIdMaster | The row identifier to associate the newsletter events with. |
List<NewsletterEventBatchInsert> | events | The list of NewsletterEventBatchInsert to insert. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the number of events to insert is greater than 100. |
ConvertEventType(string)
Converts a string value to a NewsletterEventType enumeration value.
Declaration
public NewsletterEventType ConvertEventType(string value)
Parameters
Type | Name | Description |
---|---|---|
string | value | The string value to convert. |
Returns
Type | Description |
---|---|
NewsletterEventType | The corresponding NewsletterEventType enumeration value. |
GetMailEventSentAsync(string, string, CancellationToken)
Retrieves the most recent newsletter event with a 'Sent' event type associated with the specified email address and row identifier.
Declaration
public Task<NewsletterEvent> GetMailEventSentAsync(string email, string rowIdMaster, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | The email address to retrieve the newsletter event for. |
|
string | rowIdMaster | The row identifier to retrieve the newsletter event for. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<NewsletterEvent> | The most recent newsletter event with a 'Sent' event type. |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the email address is not defined. |
GetMailEventsAsync(string, CancellationToken)
Retrieves a collection of newsletter events associated with the specified email address.
Declaration
public Task<IEnumerable<NewsletterEvent>> GetMailEventsAsync(string email, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | The email address to retrieve newsletter events for. |
|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IEnumerable<NewsletterEvent>> | A collection of newsletter events. |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the email address is not defined. |
GetRowEventsAsync(string, NewsletterEventType, CancellationToken)
Retrieves a collection of newsletter events associated with the specified row identifier and event type.
Declaration
public Task<IEnumerable<NewsletterEvent>> GetRowEventsAsync(string rowIdMaster, NewsletterEventType eventType, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | rowIdMaster | The row identifier to retrieve newsletter events for. |
NewsletterEventType | eventType | The NewsletterEventType to retrieve. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IEnumerable<NewsletterEvent>> | A collection of newsletter events. |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the row identifier is not defined. |
GetWorkedCountAsync(string, CancellationToken)
Retrieves the count of newsletter events with a 'Worked' event type associated with the specified row identifier.
Declaration
public Task<long> GetWorkedCountAsync(string rowIdMaster, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | rowIdMaster | The row identifier to retrieve newsletter events for. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<long> | The count of newsletter events with a 'Worked' event type. |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the row identifier is not defined. |
IsMailInMailingListAsync(string, string, CancellationToken)
Determines whether the specified email address is in the mailing list.
Declaration
public Task<bool> IsMailInMailingListAsync(string email, string rowIdMaster = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | The email address to check. |
|
string | rowIdMaster | The optional row identifier to check against. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> | True if the email address is in the mailing list, otherwise false. |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the email address is not defined. |
IsMultipleDeliveryFailAsync(string, CancellationToken)
Determines whether the specified email address has had three or more delivery failures.
Declaration
public Task<bool> IsMultipleDeliveryFailAsync(string email, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | The email address to check. |
|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> | True if the email address has had three or more delivery failures, otherwise false. |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the email address is not defined. |
RemoveOldNewsletterEventsAsync(CancellationToken)
Removes old newsletter events from the event store.
Declaration
public Task RemoveOldNewsletterEventsAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
SetNewsletterEventAsync(string, NewsletterEventType, string, string, CancellationToken)
Inserts a new newsletter event into the event store if a newsletter event with the same email address, row identifier, description, and event type does not already exist.
Declaration
public Task SetNewsletterEventAsync(string email, NewsletterEventType eventType, string description = null, string rowIdMaster = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | The email address associated with the newsletter event. |
|
NewsletterEventType | eventType | The NewsletterEventType of the newsletter event. |
string | description | The optional description of the newsletter event. |
string | rowIdMaster | The optional row identifier associated with the newsletter event. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the email address is not defined. |