2022-11-19 21:30:43 +00:00
|
|
|
|
using Elsa.Extensions;
|
2023-10-07 10:47:36 +00:00
|
|
|
|
using Elsa.Samples.ConsoleApp.Composition.Activities;
|
|
|
|
|
|
using Elsa.Samples.ConsoleApp.Composition.Models;
|
Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688)
* add a more generic UIHandler to customize how inputAttributes can be handle by the ui
* Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver
Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization.
* Refactor variable name and description in InputDescriptor
The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI.
* "Refactor codebase for improved organization and cleaner architecture"
The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised.
* Add CheckList UIHint with associated handler and provider
This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint.
---------
Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2023-12-26 17:56:29 +00:00
|
|
|
|
using Elsa.Workflows.Activities;
|
|
|
|
|
|
using Elsa.Workflows.Contracts;
|
|
|
|
|
|
using Elsa.Workflows.Memory;
|
2022-11-19 21:30:43 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
|
|
// Setup service container.
|
|
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
|
|
|
|
|
|
|
// Add Elsa services.
|
|
|
|
|
|
services.AddElsa();
|
|
|
|
|
|
|
|
|
|
|
|
// Build service container.
|
|
|
|
|
|
var serviceProvider = services.BuildServiceProvider();
|
|
|
|
|
|
|
|
|
|
|
|
// Declare a workflow variable for use in the workflow.
|
2022-11-20 19:37:56 +00:00
|
|
|
|
var personVariable = new Variable<Person>();
|
2022-11-19 21:30:43 +00:00
|
|
|
|
|
|
|
|
|
|
// Declare a workflow.
|
|
|
|
|
|
var workflow = new Sequence
|
|
|
|
|
|
{
|
2022-11-20 19:37:56 +00:00
|
|
|
|
Variables = { personVariable },
|
2022-11-19 21:30:43 +00:00
|
|
|
|
Activities =
|
|
|
|
|
|
{
|
2022-11-24 20:12:07 +00:00
|
|
|
|
new AskDetails
|
2022-11-19 21:30:43 +00:00
|
|
|
|
{
|
2022-11-27 12:28:53 +00:00
|
|
|
|
NamePrompt = new ("What's your name?"),
|
|
|
|
|
|
AgePrompt = new ("What's your age?"),
|
|
|
|
|
|
Result = new(personVariable)
|
2022-11-19 21:30:43 +00:00
|
|
|
|
},
|
2022-11-20 19:37:56 +00:00
|
|
|
|
new WriteLine(context =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var person = personVariable.Get(context)!;
|
|
|
|
|
|
return $"Your name is {person.Name} and you are {person.Age} years old.";
|
|
|
|
|
|
})
|
2022-11-19 21:30:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Resolve a workflow runner to run the workflow.
|
|
|
|
|
|
var workflowRunner = serviceProvider.GetRequiredService<IWorkflowRunner>();
|
|
|
|
|
|
|
|
|
|
|
|
// Run the workflow.
|
|
|
|
|
|
await workflowRunner.RunAsync(workflow);
|