using Elsa.Activities.Console; using Elsa.Expressions; using Elsa.Models; using Elsa.Persistence; using Elsa.Services; using Elsa.Builders; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.Extensions.Logging; namespace Elsa.Samples.WorkflowDefinition { internal class Program { private static async Task Main(string[] args) { var services = new ServiceCollection() .AddElsa() .AddLogging(log => log.AddConsole()) .AddConsoleActivities() .AddSingleton(Console.In) .BuildServiceProvider(); var activityResolver = services.GetRequiredService(); var activity1 = activityResolver.ResolveActivity() .WithId("activity-1") .WithText(new LiteralExpression("Hello world!")); var activity2 = activityResolver.ResolveActivity() .WithId("activity-2") .WithText(new LiteralExpression("Goodbye cruel world...!")); //Create Workflow Definition var workflowDefinition = new WorkflowDefinitionVersion { DefinitionId = "definition-001", IsPublished = true, Activities = new List { ActivityDefinition.FromActivity(activity1), ActivityDefinition.FromActivity(activity2) }, Connections = new[] { new ConnectionDefinition("activity-1", "activity-2", OutcomeNames.Done), } }; //Register it var workflowDefination = services.GetService(); await workflowDefination.AddAsync(workflowDefinition); //Run it var invoker = services.GetService(); await invoker.RunWorkflowDefinitionAsync("definition-001"); Console.ReadLine(); } } }