* Introduce `MigrationOptions` for configurable EF Core migration execution
Added `MigrationOptions` to control migration execution on a per-DbContext basis. Updated `RunMigrationsStartupTask` to respect these options, and refactored configurations in `PersistenceFeatureBase`.
This fixes an issue where the `RunMigrations` setting is not properly propagated to dependency features.
Fixes#6912
* Propagate `DbContextOptionsBuilder`, `UseContextPooling`, and `RunMigrations` settings to dependency features in `WorkflowManagementPersistenceFeature`.
* Update src/modules/Elsa.EntityFrameworkCore.Common/RunMigrationsStartupTask.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Frans van Ek <frans@fransvanek.nl>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Document architecture decision to capture `ActivityExecutionContext` snapshots at execution time. Updated TOC and dependency graph to reference the new ADR.
Replaced `CaptureActivityExecutionRecordMiddleware` with a notification-based approach using `ActivityCompleted` and `CaptureActivityExecutionState`. Removed obsolete middleware setup and extensions for better maintainability.
Refactor the extension method to merge existing serialized snapshots with updated activity execution properties, ensuring the latest context state is retained without overwriting prior data.
* Add cancellation handling for executing scheduled tasks
Enhanced `ScheduledRecurringTask`, `ScheduledCronTask`, and `ScheduledSpecificInstantTask` to properly handle cancellation scenarios when tasks are executing. Introduced `_executing` and `_cancellationRequested` flags to ensure clean cancellation processes.
* Refactor `ScheduledRecurringTask` to improve readability and fix formatting issues.
* Add `SemaphoreSlim` for concurrent task execution control in scheduled tasks
Introduce `SemaphoreSlim` to manage and safeguard concurrent executions in `ScheduledRecurringTask`, `ScheduledCronTask`, and `ScheduledSpecificInstantTask`. Enhances thread safety and prevents overlapping executions. Added exception handling and proper semaphore release to ensure robustness.
* Add ILogger to scheduled tasks and improve error logging
Integrated `ILogger` into `ScheduledRecurringTask` to enhance logging capabilities and replaced the generic comment-based error handling with proper logging for better traceability. Cleaned up and formatted `ScheduledCronTask` for improved code readability.
* Dispose of semaphore fields in scheduled task classes to ensure proper resource cleanup.
* Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledRecurringTask.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Set `_executing` to `false` in task `finally` blocks to ensure state reset after execution.
* Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledSpecificInstantTask.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Remove redundant `_executing` assignment after `SendAsync` in scheduled task classes.
* Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledRecurringTask.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledRecurringTask.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledCronTask.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledSpecificInstantTask.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update semaphore logic to prevent blocked tasks when cancellation is requested
Refactored `_executionSemaphore.WaitAsync` usage in `ScheduledRecurringTask`, `ScheduledCronTask`, and `ScheduledSpecificInstantTask` to use non-blocking semaphore acquisition with cancellation token support. This ensures graceful handling of pending tasks during cancellation scenarios.
* Refactor delay condition checks to use `TimeSpan.Zero` for improved readability and precision.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Deleted unused metadata properties to simplify `ActivityExecutionRecordSnapshot`. Updated `GetOrMapCapturedActivityExecutionRecordAsync` to maintain serialized snapshots when mapping, ensuring consistency in activity execution records.
Revised method parameters, simplified object initializations in `DefaultWorkflowInstanceVariableReader`, and enhanced hierarchy reconstruction in `WorkflowStateExtractor` with logging for missing parent contexts.
* Ongoing MongoDB work
* Refactor MongoDB serializer configuration and improve type handling
- Added `BsonSerializerHelpers` for streamlined serializer registration with error handling.
- Introduced `ConfigureMongoDbSerializers` hosted service to centralize serializer setup.
- Enhanced `FlowScopeSerializer` to handle additional BSON types.
- Cleaned up and reorganized MongoDB feature implementations, removing redundant code and improving consistency.
* Remove `BsonSerializerHelpers` and update MongoDB serializer registration
- Deleted `BsonSerializerHelpers` as it was redundant.
- Updated `ConfigureMongoDbSerializers` to directly register serializers using `BsonSerializer`.
- Simplified `FlowScopeSerializer` null handling for improved readability.
* Switch persistence provider to Entity Framework Core in `Program.cs`.
* Update src/modules/Elsa.MongoDb/Serializers/FlowScopeSerializer.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Configures MongoDB services and options.
Configures MongoDB services, including client and database creation.
Registers default naming strategy and collection naming strategy.
Adds BsonClassMap configuration for KeyValuePair.
* Simplify null check in `FlowScopeSerializer`.
* Allow `FlowScopeSerializer` to handle nullable `FlowScope`.
* Registers FlowScope BSON class map
Registers the `FlowScope` class with BSON to enable proper serialization and deserialization of workflow scopes within MongoDB.
This ensures that workflow scopes, which are used to manage variables within a workflow, are correctly stored and retrieved from the database.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Converted `CheckList` and `CheckListItem` to records,
adding XML documentation for clarity. Updated properties
in `CheckListProps`, `RadioList`, and `RadioListItem`
with similar changes. Enhanced documentation in
`DropDownOptionsProviderBase` and modified
`RadioListOptionsProviderBase` to reflect new
functionality. Overall improvements for readability
and maintainability.
- Renamed `CheckList` to `RadioList` in `RadioListProps`.
- Updated `WorkflowsFeature` to include `RadioListUIHintHandler` and `StaticRadioListOptionsProvider`.
- Introduced `TestRadioList` class for executing radio list functionality.
- Created `RadioList` and `RadioListItem` classes for managing radio list items.
- Added `RadioListOptionsProviderBase` for custom radio list data logic.
- Implemented `StaticRadioListOptionsProvider` for static radio list options.
Refactors the background alteration job dispatcher to use a service scope
to resolve the alteration job runner. This ensures that the runner
is resolved within a scope, allowing it to utilize scoped services.
- Introduced `HealActivity` alteration type for resolving faulted activity states.
- Added `HealActivityHandler` to manage execution of `HealActivity`.
- Enhanced `WorkflowExecutionContextExtensions` with `FindActivityExecutionContexts` method for locating activity execution contexts based on provided handles.
- Updated `AlterationHandlerContext` to enable custom commit actions during `Succeed` calls.
- Registered `HealActivity` and its handler in alteration services.
- Upgraded `ElsaStudioVersion` to `3.5.0-preview.1092`.
Reordered query operations to ensure consistent execution of `OrderBy` before `Paginate`, improving clarity and maintaining the expected query behavior.