Fix datetime conversion when sending datetime to API endpoints
This commit is contained in:
parent
99c0797438
commit
bd3797dea5
|
|
@ -1,3 +1,4 @@
|
|||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Elsa.Workflows.Contracts;
|
||||
|
|
@ -29,6 +30,9 @@ public static class WebApplicationExtensions
|
|||
config.Endpoints.RoutePrefix = routePrefix;
|
||||
config.Serializer.RequestDeserializer = DeserializeRequestAsync;
|
||||
config.Serializer.ResponseSerializer = SerializeRequestAsync;
|
||||
|
||||
config.Binding.ValueParserFor<DateTime>(s =>
|
||||
new(DateTime.TryParse(s.ToString(),CultureInfo.InvariantCulture,DateTimeStyles.RoundtripKind, out var result), result));
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -10,16 +10,8 @@ namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.Journal.HasUpdates;
|
|||
|
||||
/// Endpoint that checks if there are updates for a workflow instance.
|
||||
[PublicAPI]
|
||||
internal class HasUpdates : ElsaEndpoint<Request, bool>
|
||||
internal class HasUpdates(IWorkflowExecutionLogStore store) : ElsaEndpoint<Request, bool>
|
||||
{
|
||||
private readonly IWorkflowExecutionLogStore _store;
|
||||
|
||||
/// <inheritdoc />
|
||||
public HasUpdates(IWorkflowExecutionLogStore store)
|
||||
{
|
||||
_store = store;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Configure()
|
||||
{
|
||||
|
|
@ -33,7 +25,7 @@ internal class HasUpdates : ElsaEndpoint<Request, bool>
|
|||
var pageArgs = PageArgs.From(1, 1, 0, 1);
|
||||
var filter = new WorkflowExecutionLogRecordFilter { WorkflowInstanceId = request.WorkflowInstanceId };
|
||||
var order = new WorkflowExecutionLogRecordOrder<long>(x => x.Sequence, OrderDirection.Descending);
|
||||
var pageOfRecords = await _store.FindManyAsync(filter, pageArgs, order, cancellationToken);
|
||||
var pageOfRecords = await store.FindManyAsync(filter, pageArgs, order, cancellationToken);
|
||||
|
||||
return pageOfRecords.Items.Any(item => item.Timestamp >= request.UpdatesSince);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue