using System; using System.Threading.Tasks; using Elsa.Models; using Elsa.Persistence; using Elsa.Persistence.Specifications; using Elsa.Persistence.YesSql.Extensions; using Elsa.Services; using Microsoft.Extensions.DependencyInjection; namespace Elsa.Samples.HelloWorldConsole { class Program { private static async Task Main() { // Create a service container with Elsa services. var services = new ServiceCollection() .AddElsa(options => options.UseYesSqlPersistence()) .AddConsoleActivities() .AddWorkflow() .AddAutoMapperProfiles() .BuildServiceProvider(); // Run startup actions (not needed when registering Elsa with a Host). var startupRunner = services.GetRequiredService(); await startupRunner.StartupAsync(); // Get a workflow runner. var workflowRunner = services.GetRequiredService(); // Run the workflow. await workflowRunner.RunWorkflowAsync(); var store = services.GetRequiredService(); var results = await store.FindManyAsync( new WorkflowInstanceDefinitionIdSpecification(nameof(HelloWorld)), OrderBySpecification.OrderByDescending(x => x.CreatedAt), Paging.Page(1, 2)); var count = await store.CountAsync( new WorkflowInstanceDefinitionIdSpecification(nameof(HelloWorld)), OrderBySpecification.OrderByDescending(x => x.CreatedAt)); Console.WriteLine(count); foreach (var result in results) { Console.WriteLine(result.CreatedAt); } } } }