DataWeb
Search Results for

    Show / Hide Table of Contents

    Class NewsletterEventStore

    SQL Server newsletter event store implementation. Manages persistence and retrieval of newsletter events from the database.

    Inheritance
    object
    NewsletterEventStore
    Implements
    INewsletterEventStore
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: DataWeb.Newsletter.SqlServer
    Assembly: DataWeb.Data.SqlServer.dll
    Syntax
    public class NewsletterEventStore : INewsletterEventStore

    Constructors

    NewsletterEventStore(ISqlHelper, TimeProvider)

    SQL Server newsletter event store implementation. Manages persistence and retrieval of newsletter events from the database.

    Declaration
    public NewsletterEventStore(ISqlHelper sqlHelper, TimeProvider timeProvider)
    Parameters
    Type Name Description
    ISqlHelper sqlHelper
    TimeProvider timeProvider

    Properties

    Name

    Gets the name of the newsletter event store.

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    string

    Methods

    BatchInsertAsync(string, List<NewsletterEventBatchInsert>, CancellationToken)

    Inserts a batch of newsletter events for the specified master row. Event types not matching a valid NewsletterEventType are defaulted to Reject. Descriptions longer than 500 characters are automatically truncated.

    Declaration
    public Task BatchInsertAsync(string rowIdMaster, List<NewsletterEventBatchInsert> events, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string rowIdMaster

    Identifier of the master row. Cannot be null or empty.

    List<NewsletterEventBatchInsert> events

    List of events to insert. Cannot be null.

    CancellationToken cancellationToken

    Token to cancel the asynchronous operation.

    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    ArgumentException

    If rowIdMaster is null or empty.

    ArgumentNullException

    If events is null.

    ConvertEventTypeToString(NewsletterEventType)

    Converts a newsletter event type to its string representation.

    Declaration
    public string ConvertEventTypeToString(NewsletterEventType eventType)
    Parameters
    Type Name Description
    NewsletterEventType eventType

    The event type to convert.

    Returns
    Type Description
    string

    String representation of the event type.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If eventType is not a valid value.

    ConvertStringToEventType(string)

    Converts a string to the corresponding newsletter event type.

    Declaration
    public NewsletterEventType ConvertStringToEventType(string value)
    Parameters
    Type Name Description
    string value

    String representing the event type. Cannot be null.

    Returns
    Type Description
    NewsletterEventType

    Corresponding NewsletterEventType.

    Exceptions
    Type Condition
    ArgumentNullException

    If value is null.

    ArgumentOutOfRangeException

    If value does not correspond to any valid event type.

    GetEventAsync(NewsletterEventFilter, CancellationToken)

    Retrieves a single newsletter event based on the specified filter criteria.

    Declaration
    public Task<NewsletterEvent> GetEventAsync(NewsletterEventFilter filter, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    NewsletterEventFilter filter

    Search criteria. Cannot be null.

    CancellationToken cancellationToken

    Token to cancel the asynchronous operation.

    Returns
    Type Description
    Task<NewsletterEvent>

    The newsletter event found, or null if not found.

    Exceptions
    Type Condition
    ArgumentNullException

    If filter is null.

    GetEventsAsync(NewsletterEventFilter, CancellationToken)

    Retrieves a collection of newsletter events based on the specified filters.

    Declaration
    public Task<IEnumerable<NewsletterEvent>> GetEventsAsync(NewsletterEventFilter filter, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    NewsletterEventFilter filter

    Search criteria. Cannot be null.

    CancellationToken cancellationToken

    Token to cancel the asynchronous operation.

    Returns
    Type Description
    Task<IEnumerable<NewsletterEvent>>

    Collection of newsletter events matching the filter criteria.

    Exceptions
    Type Condition
    ArgumentNullException

    If filter is null.

    GetEventsCountAsync(NewsletterEventFilter, CancellationToken)

    Retrieves the total count of newsletter events based on the specified filters.

    Declaration
    public Task<long> GetEventsCountAsync(NewsletterEventFilter filter, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    NewsletterEventFilter filter

    Search criteria. Cannot be null.

    CancellationToken cancellationToken

    Token to cancel the asynchronous operation.

    Returns
    Type Description
    Task<long>

    Number of newsletter events matching the filter criteria.

    Exceptions
    Type Condition
    ArgumentNullException

    If filter is null.

    GetRowLinksAsync(string, CancellationToken)

    Retrieves all unique link URLs clicked for a given master row.

    Declaration
    public Task<IEnumerable<string>> GetRowLinksAsync(string rowIdMaster, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string rowIdMaster

    Identifier of the master row. Cannot be null or empty.

    CancellationToken cancellationToken

    Token to cancel the asynchronous operation.

    Returns
    Type Description
    Task<IEnumerable<string>>

    Collection of distinct link URLs associated with click events.

    Exceptions
    Type Condition
    ArgumentException

    If rowIdMaster is null or empty.

    GetWorkedCountAsync(string, CancellationToken)

    Retrieves the count of processed events (sent or rejected) for a given master row.

    Declaration
    public Task<long> GetWorkedCountAsync(string rowIdMaster, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string rowIdMaster

    Identifier of the master row. Cannot be null or empty.

    CancellationToken cancellationToken

    Token to cancel the asynchronous operation.

    Returns
    Type Description
    Task<long>

    Number of processed events.

    Exceptions
    Type Condition
    ArgumentException

    If rowIdMaster is null or empty.

    IsMailInSendListAsync(string, string, CancellationToken)

    Checks whether an email address is present in the send list for a given master row.

    Declaration
    public Task<bool> IsMailInSendListAsync(string email, string rowIdMaster = null, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string email

    Email address to check. Cannot be null or empty.

    string rowIdMaster

    Optional master row identifier to scope the check.

    CancellationToken cancellationToken

    Token to cancel the asynchronous operation.

    Returns
    Type Description
    Task<bool>

    true if the email is in the send list; otherwise false.

    Exceptions
    Type Condition
    ArgumentException

    If email is null or empty.

    RemoveOldEventsAsync(CancellationToken)

    Removes newsletter events older than 6 months from the database. Deletion is performed in batches of 1000 rows to reduce database impact.

    Declaration
    public Task RemoveOldEventsAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    Token to cancel the asynchronous operation.

    Returns
    Type Description
    Task

    SetAsync(string, NewsletterEventType, string, string, CancellationToken)

    Inserts a new newsletter event for the specified email address. Descriptions longer than 500 characters are automatically truncated.

    Declaration
    public Task<string> SetAsync(string email, NewsletterEventType eventType, string description = null, string rowIdMaster = null, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string email

    Email address associated with the event. Cannot be null or empty.

    NewsletterEventType eventType

    Type of the newsletter event.

    string description

    Optional event description. Truncated to 500 characters if longer.

    string rowIdMaster

    Optional identifier of the associated master row.

    CancellationToken cancellationToken

    Token to cancel the asynchronous operation.

    Returns
    Type Description
    Task<string>

    The identifier of the newly created event.

    Exceptions
    Type Condition
    ArgumentException

    If email is null or empty.

    Implements

    INewsletterEventStore
    In this article
    Back to top Generated by DocFX