Exemple #1
0
        static async Task Main(string[] args)
        {
            var services = new ServiceCollection()
                           .AddElsa(configure => configure
                                    .AddConsoleActivities()
                                    .AddFileActivities())
                           .AddAutoMapperProfiles <Program>()
                           .BuildServiceProvider();

            // Run startup actions (not needed when registering Elsa with a Host).
            var startupRunner = services.GetRequiredService <IStartupRunner>();
            await startupRunner.StartupAsync();

            // Get a workflow runner.
            var workflowRunner = services.GetRequiredService <IBuildsAndStartsWorkflow>();

            // Run the workflow.
            await workflowRunner.BuildAndStartWorkflowAsync <ReadLineToFileWorkflow>();

            var store = services.GetRequiredService <IWorkflowInstanceStore>();

            var results = await store.FindManyAsync(
                new WorkflowDefinitionIdSpecification(nameof(ReadLineToFileWorkflow)),
                OrderBySpecification.OrderByDescending <WorkflowInstance>(x => x.CreatedAt),
                Paging.Page(1, 2));

            var count = await store.CountAsync(new WorkflowDefinitionIdSpecification(nameof(ReadLineToFileWorkflow)));

            Console.WriteLine(count);

            foreach (var result in results)
            {
                Console.WriteLine(result.CreatedAt);
            }
        }
        public async Task <IActionResult> Get(CancellationToken cancellationToken)
        {
            var instances = await this.instanceStore.FindManyAsync(
                new WorkflowInstanceAllSpecification(),
                OrderBySpecification.OrderByDescending <WorkflowInstance>(x => x.CreatedAt));


            return(new JsonResult(instances));
        }
        public async Task <IActionResult> Get(string correlationId, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(correlationId))
            {
                this.Response.StatusCode = StatusCodes.Status400BadRequest;
                return(new EmptyResult());
            }

            var instances = await this.instanceStore.FindManyAsync(
                new WorkflowInstanceCorrelationIdSpecification(correlationId),
                OrderBySpecification.OrderByDescending <WorkflowInstance>(x => x.CreatedAt));


            return(new JsonResult(instances));
        }