* Refactor workflow context extension structure Removed unused WorkflowContextWorkflowDefinitionExtensions and renamed several extension and middleware classes for clarity and consistency. Simplified context provider type handling using JsonArray in custom properties. * Refactor context provider and update email workflow Refactored `CustomerWorkflowContextProvider` to use constructor parameter directly, removing redundant fields and constructors. Updated comments and list syntax in `CustomerCommunicationsWorkflow`. Improved README.md documentation for workflow contexts and context providers. * Adjust logging levels and improve workflow logic Modified `appsettings.json` to reduce the verbosity of logging by adjusting log levels. Updated `CustomerCommunicationsWorkflow` to include a timer activity and simplified the workflow context parameter setting. * Remove PropertyBag and related functionalities. Deleted the PropertyBag class and extension methods, and removed all instances where PropertyBag was utilized across various modules. This simplifies the workflow configuration and management by relying solely on CustomProperties for storing metadata. * Add workflow context management extensions and optimizations Introduces `WorkflowExecutionContextExtensions` for loading and saving workflow contexts more efficiently. Replaces `JsonArray` usage with `List<object>` for context provider types, simplifying the type management in the workflow execution context. Streamlines `WorkflowContextActivityExecutionMiddleware` by removing redundant service scope creation and enhancing readability. * Remove redundant timer in CustomerCommunicationsWorkflow The timer activity that was set to not start the workflow has been removed to streamline the workflow process. Updated the README to include instructions on how to start the CustomerCommunicationsWorkflow using the REST API or Elsa Studio. * Refactor middleware to streamline context management Removed dependency on `IServiceScopeFactory` and refactored middleware to directly load and save workflow contexts. Simplified workflow context provider invocation, enhancing code readability and maintainability. * Remove redundant PropertyBag property The PropertyBag property was commented out and is no longer needed in the WorkflowDefinition class. This change removes the commented-out code to clean up the class definition. * Add JsonSerializerOptions for deserialization Introduce JsonSerializerOptions with camelCase policy and case insensitivity for property names. This ensures consistent deserialization of custom properties in activity workflow context settings. |
||
|---|---|---|
| .. | ||
| Contracts | ||
| Entities | ||
| Extensions | ||
| Properties | ||
| Providers | ||
| Services | ||
| Workflows | ||
| appsettings.json | ||
| Dockerfile | ||
| Elsa.Samples.AspNet.WorkflowContexts.csproj | ||
| Program.cs | ||
| README.md | ||
Server
This project demonstrates how to use Workflow Contexts.
A Workflow Context represents a custom, application-specific object provided to the workflow at runtime. For example, if your workflow handles a Customer, a custom workflow context provider could provide this customer automatically to the workflow without the need for custom activities that load & persist updates to this customer. Instead, the custom context provider would load the customer into memory once before the workflow starts and persists changes made to the customer (if any) when the workflow execution ends.
In this sample project, we handle two custom objects: Customer and Order.
To start the CustomerCommunicationsWorkflow, start it using the REST API or from Elsa Studio.
Secrets
The following are the secrets stored in hashed form in appsettings.json:
API key: 4E753976726458745954355043687772-e54d5a2c-33a3-4c05-a216-b09569062aed
Admin user: admin
Admin password: password