elsa-core/src/common/Elsa.Features
Sipke Schoorstra c3686bf165
Fix flowchart completion after faulted child activity cancellation (#5145)
* Refactor alteration runner logic and simplify CancelActivityHandler

The DefaultAlterationRunner.cs file was refactored to include a workflow middleware pipeline, replacing the previous method of updating workflow state. Comments were added to discuss potential solutions for reusing the same pipeline in the workflow runtime. The CancelActivityHandler was simplified by removing multiple functions and replacing them with a single CancelAsync method.

* Add RunAlterationsMiddleware to handle workflow alterations

The commit introduces a new middleware, RunAlterationsMiddleware, that is designed to process workflow alterations. The middleware is in charge of executing alteration handlers and taking care of any required commit actions. The original code for handling alterations in DefaultAlterationRunner has been significantly reduced as it now delegates most of its responsibility to this new middleware.

* Add comments to IAlterationPlanManager interface methods

In the IAlterationPlanManager interface, explanatory comments were added to each method. These include methods for getting a plan by ID, checking if all jobs in the plan have been completed, and completing an alteration plan. The changes made will greatly aid in understanding the purpose and functionality of each method.

* Refactor pipeline execution methods and replace middleware

The workflow execution pipeline has been refactored to allow for dynamic configuration. The middleware components are now retrievable properties and can be replaced individually. This change provides more extensibility with modifying the pipeline execution and replacing the DefaultActivitySchedulerMiddleware with desired middleware.

* Refactor pipeline alteration and addition methods

Simplified the pipeline alteration process in Elsa.Alterations. Instead of manually handling middleware delegates, added a new extension method, ReplaceTerminal, in WorkflowExecutionMiddlewareExtensions.cs to replace the terminal middleware component. This approach improves code readability and maintenance.

* Refactor RunAlterationsMiddleware class

Removed an unnecessary extension class and updated the RunAlterationsMiddleware class to streamline its structure. The handlers are now initialized directly in the constructor, eliminating the need for an additional field. Renamed local variable for better code clarity.

* Refactor variable name in RunAlterationsMiddleware

The variable name 'handlers1' has been renamed to 'supportedHandlers' in the RunAlterationsMiddleware.cs file. This change improves code readability and makes it clear that the list contains only the handlers that can handle the given alteration.

* Change RunAsync method to return void

The RunAsync function in the RunAlterationsMiddleware class no longer returns a boolean value. The returned 'false' has been replaced with a 'return' statement, and the 'return true' statement has been completely removed. This refactor simplifies the control flow when executing alterations.

* Refactor variable handling and improve flowchart completion

Refactored variable value conversion and update logic in ModifyVariableHandler classes. Removal of some service dependencies simplifies the implementation and reduces coupling. Also streamlined completion process in Flowchart classes, making it more efficient and improving readability.

* Add running status filter to workflow instance finder

A new method was introduced to filter only running workflow instances before applying alterations in the "WorkflowInstanceFinder" service. The change ensures that alterations affect only workflows that are currently running, increasing the effectiveness and accuracy of the system.

* Rename ActivityId to ActivityNodeId in related classes

Modified the name of the 'ActivityId' property to 'ActivityNodeId' across multiple classes including 'ActivityWorkItemState' and 'WorkflowStateExtractor'. This change reflects the usage of NodeId more accurately in the workflow process. The methods 'FindActivityById' across classes were updated accordingly. Also, an attribute '[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]' was added to two methods in 'WorkflowRunner'.

* Refactor code in Flowchart class

Removed unnecessary variable 'flowchartContext' in the 'CompleteIfNoPendingWorkAsync' method of the Flowchart class. The 'context' variable has been used directly for the 'HasPendingWork' check and 'CompleteActivityAsync' call, simplifying the code without altering functionality.

* Update workflow methods with parameterless constructor constraints

This change introduces parameterless constructor constraints on workflow-related methods in Elsa.Workflows.Core. Specifically, both RunAsync and BuildWorkflowAsync methods had their generics constraint updated to require a parameterless constructor. This ensures only workflows with a parameterless constructor can be run or built. Additionally, unused usages of `RequiresUnreferencedCode` attribute were removed from Elsa.Features.
2024-03-29 20:38:09 +01:00
..
Abstractions Fix flowchart completion after faulted child activity cancellation (#5145) 2024-03-29 20:38:09 +01:00
Attributes Decouple Expression Types (#4622) 2023-11-14 20:44:42 +01:00
Contracts Implement real time workflow update broadcasting using SignalR 2023-07-25 15:12:27 +02:00
Extensions Finish Azure Service Bus activities (#3617) 2023-01-12 11:59:31 +01:00
Implementations Decouple Expression Types (#4622) 2023-11-14 20:44:42 +01:00
Models Extend FeatureDescriptor with namespace and full name props 2023-06-10 15:31:45 +02:00
Services Fix flowchart completion after faulted child activity cancellation (#5145) 2024-03-29 20:38:09 +01:00
Elsa.Features.csproj Convert to use Central Package Management 2024-02-04 13:49:54 +02:00
FodyWeavers.xml Add FodyWeavers.xml files 2022-08-27 20:42:34 +02:00