Interface IAutomationEventService
Represents a service for managing event automation.
Namespace: DataWeb.Automation
Assembly: DataWeb.Core.dll
Syntax
public interface IAutomationEventService
Properties
AutomationAppSettings
Gets the automation application settings loaded from configuration.
Declaration
AutomationAppSettings AutomationAppSettings { get; }
Property Value
| Type | Description |
|---|---|
| AutomationAppSettings |
Methods
AddTriggeredTaskToEventAsync(string, string, TriggeredTask, CancellationToken)
Asynchronously adds a triggered event to the automation event.
Declaration
Task AddTriggeredTaskToEventAsync(string automationEventId, string automationEventEmail, AutomationEvent.TriggeredTask triggeredTask, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | automationEventId | The id of the automation event. |
| string | automationEventEmail | The email of the automation event. |
| AutomationEvent.TriggeredTask | triggeredTask | The triggered task to add. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
EventExistsAsync(AutomationEventFilter, CancellationToken)
Determines whether an automation event exists based on the specified filter.
Declaration
Task<bool> EventExistsAsync(AutomationEventFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AutomationEventFilter | filter | The filter to apply when checking for the event. |
| CancellationToken | cancellationToken | A token to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<bool> | True if the event exists; otherwise, false. |
GetEmailFromContext(IUser, HttpContext)
Retrieves the email of the authenticated user, or attempts to get and decrypt the email from a browser cookie if the user is not authenticated.
Declaration
string GetEmailFromContext(IUser user, HttpContext httpContext)
Parameters
| Type | Name | Description |
|---|---|---|
| IUser | user | The user object containing authentication and email information. |
| HttpContext | httpContext | The current HTTP context, used to access request cookies. |
Returns
| Type | Description |
|---|---|
| string | The user's email if authenticated, the decrypted email from the cookie if available, or |
GetEventAsync(AutomationEventFilter, CancellationToken)
Retrieves a single automation event that matches the specified filter.
Declaration
Task<AutomationEvent> GetEventAsync(AutomationEventFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AutomationEventFilter | filter | The filter to apply when searching for the event. |
| CancellationToken | cancellationToken | A token to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<AutomationEvent> | The matching automation event, if found. |
GetEventCountAsync(AutomationEventFilter, CancellationToken)
Asynchronously retrieves the count of automation events that match the specified filter.
Declaration
Task<long> GetEventCountAsync(AutomationEventFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AutomationEventFilter | filter | The filter criteria used to query the automation events. |
| CancellationToken | cancellationToken | A token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<long> | The total number of matching automation events as a long. |
GetEventsAsync(AutomationEventFilter, CancellationToken)
Retrieves a list of automation events based on the specified filter.
Declaration
Task<IEnumerable<AutomationEvent>> GetEventsAsync(AutomationEventFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AutomationEventFilter | filter | The filter to apply when searching for events. |
| CancellationToken | cancellationToken | A token to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<AutomationEvent>> | A list of matching automation events. |
SetEventAsync(AutomationEvent, CancellationToken)
Asynchronously adds an automation event to the store.
Declaration
Task SetEventAsync(AutomationEvent automationEvent, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AutomationEvent | automationEvent | The AutomationEvent to add to the store. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
SetEventAsync(string, string, List<Parameter>, List<AdditionalValue>, int, int, bool, CancellationToken)
Creates and stores an automation event for a given user, validating input data, event type requirements, throttling constraints, and profile existence if specified.
Declaration
Task<AutomationEventService.EventEditResult> SetEventAsync(string email, string type, List<AutomationEvent.Parameter> parameters = null, List<AutomationEvent.AdditionalValue> additionalValues = null, int throttlingHours = 24, int expirationDays = 365, bool checkProfileExists = true, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | The email address of the user for whom the event is being created. |
|
| string | type | The type of automation event to create. Must correspond to a valid value in the AutomationEvent_Types list. |
| List<AutomationEvent.Parameter> | parameters | Optional list of parameters required by the event type. |
| List<AutomationEvent.AdditionalValue> | additionalValues | Optional list of additional values associated with the event. |
| int | throttlingHours | The number of hours used to prevent duplicate events within the specified window. Must be greater than 0. Default is 24. |
| int | expirationDays | The number of days after which the event expires. Default is 365. |
| bool | checkProfileExists | Whether to check if the user has an active automation profile before creating the event. Default is true. |
| CancellationToken | cancellationToken | A token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task<AutomationEventService.EventEditResult> | An EventEditResult object containing the result of the operation and the created event, if any. |
Exceptions
| Type | Condition |
|---|---|
| Exception | Thrown when the event type is not specified or when |
SetProfileCookie(string, HttpContext, bool)
Sets a secure, HTTP-only cookie containing the encrypted email address for user profile automation purposes.
Declaration
void SetProfileCookie(string email, HttpContext httpContext, bool isProfilingConsentRequired = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | The email address to be encrypted and stored in the cookie. |
|
| HttpContext | httpContext | The current HTTP context, used to append response cookies. |
| bool | isProfilingConsentRequired | Indicates whether to enforce profiling cookie consent checks before setting the automation email cookie. |