2020-02-18 21:29:44 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Net;
|
|
|
|
|
|
using Elsa.Activities.Http;
|
|
|
|
|
|
using Elsa.Builders;
|
|
|
|
|
|
using Elsa.Services.Models;
|
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Elsa.Samples.CustomActivities
|
|
|
|
|
|
{
|
|
|
|
|
|
public class EchoQueryStringWorkflow : IWorkflow
|
|
|
|
|
|
{
|
2021-01-30 11:47:50 +00:00
|
|
|
|
public void Build(IWorkflowBuilder builder)
|
2020-02-18 21:29:44 +00:00
|
|
|
|
{
|
2021-01-30 11:47:50 +00:00
|
|
|
|
builder
|
2021-03-01 20:10:40 +00:00
|
|
|
|
.HttpEndpoint("/test")
|
2020-02-18 21:29:44 +00:00
|
|
|
|
.Then<ReadQueryString>()
|
2020-10-03 10:48:25 +00:00
|
|
|
|
.WriteHttpResponse(_ => HttpStatusCode.OK, GenerateSomeHtml, _ => "text/html");
|
2020-02-18 21:29:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string GenerateSomeHtml(ActivityExecutionContext context)
|
|
|
|
|
|
{
|
2020-10-17 13:45:16 +00:00
|
|
|
|
var query = (IQueryCollection)context.Input; // the output of the ReadQueryString activity will be available as input to this one.
|
|
|
|
|
|
var items = query!.Select(x => $"<li>{x.Key}: {x.Value}</li>");
|
2020-10-03 10:48:25 +00:00
|
|
|
|
|
2020-02-18 21:29:44 +00:00
|
|
|
|
return $"<ul>{string.Join("\n", items)}</ul>";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|