FlowSendHttpRequest improvements

This commit is contained in:
Sipke Schoorstra 2023-09-22 11:13:23 +02:00
parent e7ca310eac
commit a201672584
6 changed files with 29 additions and 9 deletions

View file

@ -19,7 +19,7 @@ using Proto.Persistence.SqlServer;
const bool useMongoDb = false;
const bool useSqlServer = false;
const bool useDapper = false;
const bool useProtoActor = true;
const bool useProtoActor = false;
const bool useHangfire = false;
var builder = WebApplication.CreateBuilder(args);

View file

@ -1,7 +1,9 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using Elsa.Extensions;
using Elsa.Workflows.Core;
using Elsa.Workflows.Core.Attributes;
using Elsa.Workflows.Core.Contracts;
using Elsa.Workflows.Core.Models;
namespace Elsa.Http;
@ -10,17 +12,21 @@ namespace Elsa.Http;
/// Send an HTTP request.
/// </summary>
[Activity("Elsa", "HTTP", "Send an HTTP request.", DisplayName = "HTTP Request (flow)", Kind = ActivityKind.Task)]
public class FlowSendHttpRequest : SendHttpRequestBase
public class FlowSendHttpRequest : SendHttpRequestBase, IActivityPropertyDefaultValueProvider
{
/// <inheritdoc />
public FlowSendHttpRequest([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
{
}
/// <summary>
/// A list of expected status codes to handle.
/// </summary>
[Input(Description = "A list of expected status codes to handle.", UIHint = InputUIHints.MultiText)]
[Input(
Description = "A list of expected status codes to handle.",
UIHint = InputUIHints.MultiText,
DefaultValueProvider = typeof(FlowSendHttpRequest)
)]
public Input<ICollection<int>> ExpectedStatusCodes { get; set; } = default!;
/// <inheritdoc />
@ -45,4 +51,14 @@ public class FlowSendHttpRequest : SendHttpRequestBase
{
await context.CompleteActivityWithOutcomesAsync("Timeout");
}
object IActivityPropertyDefaultValueProvider.GetDefaultValue(PropertyInfo property)
{
if (property.Name == nameof(ExpectedStatusCodes))
{
return new List<int> { 200 };
}
return default!;
}
}

View file

@ -11,6 +11,7 @@ namespace Elsa.Http;
/// <summary>
/// Base class for activities that send HTTP requests.
/// </summary>
[Output(IsSerializable = false)]
public abstract class SendHttpRequestBase : Activity<HttpResponseMessage>
{
/// <inheritdoc />

View file

@ -78,10 +78,8 @@ public abstract class Activity : IActivity, ISignalHandler
/// <inheritdoc />
[JsonIgnore]
public IDictionary<string, object> SyntheticProperties { get; set; } = new Dictionary<string, object>();
/// <summary>
/// Stores metadata such as x and y coordinates when created via the designer.
/// </summary>
/// <inheritdoc />
public IDictionary<string, object> Metadata { get; set; } = new Dictionary<string, object>();
/// <summary>

View file

@ -38,6 +38,11 @@ public interface IActivity
[JsonIgnore]
IDictionary<string, object> SyntheticProperties { get; set; }
/// <summary>
/// Metadata associated with the activity. This is typically used by the workflow designer to store information about the activity.
/// </summary>
IDictionary<string, object> Metadata { get; set; }
/// <summary>
/// Invoked when the activity executes.
/// </summary>

View file

@ -56,7 +56,7 @@ public class PersistActivityExecutionLogMiddleware : WorkflowExecutionMiddleware
var outputs = outputDescriptors.ToDictionary(x => x.Name, x =>
{
if(x.IsSerializable == false)
return default;
return "(not serializable)";
var cachedValue = activity.GetOutput(expressionExecutionContext, x.Name);