@@ -15,15 +15,9 @@
}
-
diff --git a/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ApplicationBuilderExtensions.cs b/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ApplicationBuilderExtensions.cs
index a5cc1dc6e..9ec6e53ad 100644
--- a/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ApplicationBuilderExtensions.cs
+++ b/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ApplicationBuilderExtensions.cs
@@ -5,9 +5,10 @@ namespace ElsaDashboard.Backend.Extensions
{
public static class ApplicationBuilderExtensions
{
- public static IApplicationBuilder UserElsaGrpcServices(this IApplicationBuilder app)
+ public static IApplicationBuilder UseElsaGrpcServices(this IApplicationBuilder app)
{
return app
+ .UseCors()
.UseGrpcWeb()
.UseEndpoints(endpoints => endpoints
.MapGrpcEndpoint
()
diff --git a/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ServiceCollectionExtensions.cs b/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ServiceCollectionExtensions.cs
index 7ec85f37e..0f8833a1f 100644
--- a/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ServiceCollectionExtensions.cs
+++ b/src/dashboards/blazor/ElsaDashboard.Backend/Extensions/ServiceCollectionExtensions.cs
@@ -4,8 +4,10 @@ using Elsa.Client.Extensions;
using Elsa.Client.Options;
using ElsaDashboard.Backend.Rpc;
using ElsaDashboard.Shared.Rpc;
+using ElsaDashboard.Shared.Surrogates;
using Microsoft.Extensions.DependencyInjection;
using ProtoBuf.Grpc.Server;
+using ProtoBuf.Meta;
namespace ElsaDashboard.Backend.Extensions
{
@@ -13,6 +15,8 @@ namespace ElsaDashboard.Backend.Extensions
{
public static IServiceCollection AddElsaDashboardBackend(this IServiceCollection services, Action? configure = default)
{
+ RuntimeTypeModel.Default.AddElsaGrpcSurrogates();
+ services.AddCors();
services.AddElsaClient(configure);
services.AddCodeFirstGrpc(options => options.ResponseCompressionLevel = CompressionLevel.Optimal);
services.AddScoped();
diff --git a/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/ActivityService.cs b/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/ActivityService.cs
index d89c45564..016c0191c 100644
--- a/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/ActivityService.cs
+++ b/src/dashboards/blazor/ElsaDashboard.Backend/Rpc/ActivityService.cs
@@ -1,8 +1,5 @@
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
+using System.Threading.Tasks;
using Elsa.Client;
-using Elsa.Client.Models;
using ElsaDashboard.Shared.Rpc;
using ProtoBuf.Grpc;
@@ -17,10 +14,10 @@ namespace ElsaDashboard.Backend.Rpc
_elsaClient = elsaClient;
}
- public async Task> GetActivitiesAsync(CallContext callContext)
+ public async Task GetActivitiesAsync(CallContext callContext)
{
var result = await _elsaClient.Activities.ListAsync(callContext.CancellationToken);
- return result.Items;
+ return new GetActivitiesResponse(result.Items);
}
}
}
\ No newline at end of file
diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/ElsaDashboard.Shared.csproj b/src/dashboards/blazor/ElsaDashboard.Shared/ElsaDashboard.Shared.csproj
index e437d8668..fc78967e5 100644
--- a/src/dashboards/blazor/ElsaDashboard.Shared/ElsaDashboard.Shared.csproj
+++ b/src/dashboards/blazor/ElsaDashboard.Shared/ElsaDashboard.Shared.csproj
@@ -5,6 +5,7 @@
+
diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IActivityService.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IActivityService.cs
index 9c55dc9db..0faf8c4f1 100644
--- a/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IActivityService.cs
+++ b/src/dashboards/blazor/ElsaDashboard.Shared/Rpc/IActivityService.cs
@@ -1,5 +1,5 @@
using System.Collections.Generic;
-using System.Threading;
+using System.ServiceModel;
using System.Threading.Tasks;
using Elsa.Client.Models;
using ProtoBuf;
@@ -8,9 +8,25 @@ using ProtoBuf.ServiceModel;
namespace ElsaDashboard.Shared.Rpc
{
- [ProtoContract]
+ [ServiceContract]
public interface IActivityService
{
- [ProtoBehavior]Task> GetActivitiesAsync(CallContext context = default);
+ [ProtoBehavior]
+ Task GetActivitiesAsync(CallContext context = default);
+ }
+
+ [ProtoContract]
+ public sealed class GetActivitiesResponse
+ {
+ public GetActivitiesResponse()
+ {
+ }
+
+ public GetActivitiesResponse(IEnumerable activities)
+ {
+ Activities = activities;
+ }
+
+ [ProtoMember(1)] public IEnumerable Activities { get; set; } = new System.Collections.Generic.List();
}
}
\ No newline at end of file
diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/JTokenSurrogate.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/JTokenSurrogate.cs
new file mode 100644
index 000000000..003ffa866
--- /dev/null
+++ b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/JTokenSurrogate.cs
@@ -0,0 +1,45 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using NodaTime;
+using NodaTime.Serialization.JsonNet;
+using ProtoBuf;
+
+namespace ElsaDashboard.Shared.Surrogates
+{
+ ///
+ /// Surrogate for .
+ ///
+ [ProtoContract(IgnoreListHandling = true)]
+ public class JTokenSurrogate
+ {
+ private static readonly JsonSerializerSettings SerializerSettings;
+
+ ///
+ /// Default constructor.
+ ///
+ static JTokenSurrogate()
+ {
+ SerializerSettings = new JsonSerializerSettings().ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
+ }
+
+ ///
+ /// Constructor overload.
+ ///
+ public JTokenSurrogate(JToken value) => Value = JsonConvert.SerializeObject(value, SerializerSettings);
+
+ ///
+ /// Stores the Google Protobuf Any value for serialization.
+ ///
+ public string Value { get; set; } = default!;
+
+ ///
+ /// Converts the surrogate to a .
+ ///
+ public static implicit operator JToken(JTokenSurrogate surrogate) => JsonConvert.DeserializeObject(surrogate.Value, SerializerSettings);
+
+ ///
+ /// Converts the to a surrogate.
+ ///
+ public static implicit operator JTokenSurrogate(JToken source) => new(source);
+ }
+}
\ No newline at end of file
diff --git a/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/RuntimeTypeModelExtensions.cs b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/RuntimeTypeModelExtensions.cs
new file mode 100644
index 000000000..b3ebf5afc
--- /dev/null
+++ b/src/dashboards/blazor/ElsaDashboard.Shared/Surrogates/RuntimeTypeModelExtensions.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using Newtonsoft.Json.Linq;
+using ProtoBuf.Meta;
+
+namespace ElsaDashboard.Shared.Surrogates
+{
+ ///
+ /// Provides an extension method to conveniently register surrogate types with the default .
+ ///
+ public static class RuntimeTypeModelExtensions
+ {
+ private static readonly IDictionary SurrogateMapping = new Dictionary
+ {
+ [typeof(JToken)] = typeof(JTokenSurrogate)
+ };
+
+ ///
+ /// Register all NodaTime surrogate types with the protobuf runtime model.
+ ///
+ public static RuntimeTypeModel AddElsaGrpcSurrogates(this RuntimeTypeModel runtimeTypeModel)
+ {
+ foreach (var map in SurrogateMapping)
+ runtimeTypeModel.Add(map.Key, false).SetSurrogate(map.Value);
+
+ return runtimeTypeModel;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/ServiceCollectionExtensions.cs b/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/ServiceCollectionExtensions.cs
index 657fcd7d5..b995c1b7c 100644
--- a/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/ServiceCollectionExtensions.cs
+++ b/src/dashboards/blazor/ElsaDashboard.WebAssembly/Extensions/ServiceCollectionExtensions.cs
@@ -1,5 +1,7 @@
using ElsaDashboard.Shared.Rpc;
+using ElsaDashboard.Shared.Surrogates;
using Microsoft.Extensions.DependencyInjection;
+using ProtoBuf.Meta;
namespace ElsaDashboard.WebAssembly.Extensions
{
@@ -7,6 +9,7 @@ namespace ElsaDashboard.WebAssembly.Extensions
{
public static IServiceCollection AddElsaDashboardBackend(this IServiceCollection services)
{
+ RuntimeTypeModel.Default.AddElsaGrpcSurrogates();
return services
.AddGrpcClient()
.AddGrpcClient();
diff --git a/src/server/Elsa.Server.Api/Endpoints/Activities/List.cs b/src/server/Elsa.Server.Api/Endpoints/Activities/List.cs
index adf7b4860..bd2a050c2 100644
--- a/src/server/Elsa.Server.Api/Endpoints/Activities/List.cs
+++ b/src/server/Elsa.Server.Api/Endpoints/Activities/List.cs
@@ -1,14 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using Elsa.Metadata;
-using Elsa.Models;
-using Elsa.Server.Api.Models;
-using Elsa.Server.Api.Swagger;
using Elsa.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
-using Swashbuckle.AspNetCore.Filters;
namespace Elsa.Server.Api.Endpoints.Activities
{
diff --git a/src/server/Elsa.Server.Api/Endpoints/WorkflowDefinitions/Post.cs b/src/server/Elsa.Server.Api/Endpoints/WorkflowDefinitions/Post.cs
index 0565b4f11..7e023cbd8 100644
--- a/src/server/Elsa.Server.Api/Endpoints/WorkflowDefinitions/Post.cs
+++ b/src/server/Elsa.Server.Api/Endpoints/WorkflowDefinitions/Post.cs
@@ -1,7 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using Elsa.Models;
-using Elsa.Server.Api.Models;
using Elsa.Server.Api.Swagger;
using Elsa.Services;
using Microsoft.AspNetCore.Http;
diff --git a/src/server/Elsa.Server.Api/Models/PagedList.cs b/src/server/Elsa.Server.Api/Models/PagedList.cs
index e36699d26..352fe2b33 100644
--- a/src/server/Elsa.Server.Api/Models/PagedList.cs
+++ b/src/server/Elsa.Server.Api/Models/PagedList.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using System.Linq;
namespace Elsa.Server.Api.Models
{
diff --git a/test/integration/Elsa.Core.IntegrationTests/StorageProvider/StorageWorkflowProviderTests.cs b/test/integration/Elsa.Core.IntegrationTests/StorageProvider/StorageWorkflowProviderTests.cs
index ee98ee857..63568b7a4 100644
--- a/test/integration/Elsa.Core.IntegrationTests/StorageProvider/StorageWorkflowProviderTests.cs
+++ b/test/integration/Elsa.Core.IntegrationTests/StorageProvider/StorageWorkflowProviderTests.cs
@@ -2,7 +2,6 @@
using System.Threading.Tasks;
using Elsa.Core.IntegrationTests.Helpers;
using Elsa.Models;
-using Elsa.Testing.Shared.Helpers;
using Elsa.Testing.Shared.Unit;
using Microsoft.Extensions.DependencyInjection;
using Storage.Net.Blobs;
diff --git a/test/integration/Elsa.Core.IntegrationTests/Workflows/BasicWorkflowTests.cs b/test/integration/Elsa.Core.IntegrationTests/Workflows/BasicWorkflowTests.cs
index b4712a964..8e3a9d810 100644
--- a/test/integration/Elsa.Core.IntegrationTests/Workflows/BasicWorkflowTests.cs
+++ b/test/integration/Elsa.Core.IntegrationTests/Workflows/BasicWorkflowTests.cs
@@ -1,6 +1,5 @@
using System.Threading.Tasks;
using Elsa.Models;
-using Elsa.Testing.Shared.Helpers;
using Elsa.Testing.Shared.Unit;
using Xunit;
using Xunit.Abstractions;
diff --git a/test/integration/Elsa.Core.IntegrationTests/Workflows/FinishWorkflowTests.cs b/test/integration/Elsa.Core.IntegrationTests/Workflows/FinishWorkflowTests.cs
index 82d6fd93d..b75aef291 100644
--- a/test/integration/Elsa.Core.IntegrationTests/Workflows/FinishWorkflowTests.cs
+++ b/test/integration/Elsa.Core.IntegrationTests/Workflows/FinishWorkflowTests.cs
@@ -1,7 +1,6 @@
using System.Threading.Tasks;
using AutoFixture;
using Elsa.Models;
-using Elsa.Testing.Shared.Helpers;
using Elsa.Testing.Shared.Unit;
using Xunit;
using Xunit.Abstractions;
diff --git a/test/integration/Elsa.Core.IntegrationTests/Workflows/ForEachWorkflowTests.cs b/test/integration/Elsa.Core.IntegrationTests/Workflows/ForEachWorkflowTests.cs
index dd1b3f45c..f4e75eb23 100644
--- a/test/integration/Elsa.Core.IntegrationTests/Workflows/ForEachWorkflowTests.cs
+++ b/test/integration/Elsa.Core.IntegrationTests/Workflows/ForEachWorkflowTests.cs
@@ -1,7 +1,6 @@
using System.Linq;
using System.Threading.Tasks;
using Elsa.Models;
-using Elsa.Testing.Shared.Helpers;
using Elsa.Testing.Shared.Unit;
using Xunit;
using Xunit.Abstractions;
diff --git a/test/integration/Elsa.Core.IntegrationTests/Workflows/ForLoopWorkflowTests.cs b/test/integration/Elsa.Core.IntegrationTests/Workflows/ForLoopWorkflowTests.cs
index 9f4daad18..48e322a74 100644
--- a/test/integration/Elsa.Core.IntegrationTests/Workflows/ForLoopWorkflowTests.cs
+++ b/test/integration/Elsa.Core.IntegrationTests/Workflows/ForLoopWorkflowTests.cs
@@ -1,6 +1,5 @@
using System.Linq;
using System.Threading.Tasks;
-using Elsa.Testing.Shared.Helpers;
using Elsa.Testing.Shared.Unit;
using Xunit;
using Xunit.Abstractions;
diff --git a/test/integration/Elsa.Core.IntegrationTests/Workflows/ForkJoinWorkflowTests.cs b/test/integration/Elsa.Core.IntegrationTests/Workflows/ForkJoinWorkflowTests.cs
index 8735e84a3..bff37a2dd 100644
--- a/test/integration/Elsa.Core.IntegrationTests/Workflows/ForkJoinWorkflowTests.cs
+++ b/test/integration/Elsa.Core.IntegrationTests/Workflows/ForkJoinWorkflowTests.cs
@@ -5,7 +5,6 @@ using Elsa.Activities.Signaling;
using Elsa.Activities.Signaling.Models;
using Elsa.Models;
using Elsa.Services.Models;
-using Elsa.Testing.Shared.Helpers;
using Elsa.Testing.Shared.Unit;
using Xunit;
using Xunit.Abstractions;
diff --git a/test/integration/Elsa.Core.IntegrationTests/Workflows/IfElseWorkflowTests.cs b/test/integration/Elsa.Core.IntegrationTests/Workflows/IfElseWorkflowTests.cs
index c82354260..72d06270a 100644
--- a/test/integration/Elsa.Core.IntegrationTests/Workflows/IfElseWorkflowTests.cs
+++ b/test/integration/Elsa.Core.IntegrationTests/Workflows/IfElseWorkflowTests.cs
@@ -1,6 +1,5 @@
using System.Linq;
using System.Threading.Tasks;
-using Elsa.Testing.Shared.Helpers;
using Elsa.Testing.Shared.Unit;
using Xunit;
using Xunit.Abstractions;
diff --git a/test/integration/Elsa.Core.IntegrationTests/Workflows/ParallelForEachWorkflowTests.cs b/test/integration/Elsa.Core.IntegrationTests/Workflows/ParallelForEachWorkflowTests.cs
index 0e06afca5..725a68a36 100644
--- a/test/integration/Elsa.Core.IntegrationTests/Workflows/ParallelForEachWorkflowTests.cs
+++ b/test/integration/Elsa.Core.IntegrationTests/Workflows/ParallelForEachWorkflowTests.cs
@@ -1,7 +1,6 @@
using System.Linq;
using System.Threading.Tasks;
using Elsa.Models;
-using Elsa.Testing.Shared.Helpers;
using Elsa.Testing.Shared.Unit;
using Xunit;
using Xunit.Abstractions;
diff --git a/test/integration/Elsa.Core.IntegrationTests/Workflows/SwitchWorkflowTests.cs b/test/integration/Elsa.Core.IntegrationTests/Workflows/SwitchWorkflowTests.cs
index 9f965057a..2795cf650 100644
--- a/test/integration/Elsa.Core.IntegrationTests/Workflows/SwitchWorkflowTests.cs
+++ b/test/integration/Elsa.Core.IntegrationTests/Workflows/SwitchWorkflowTests.cs
@@ -1,6 +1,5 @@
using System.Linq;
using System.Threading.Tasks;
-using Elsa.Testing.Shared.Helpers;
using Elsa.Testing.Shared.Unit;
using Xunit;
using Xunit.Abstractions;
diff --git a/test/integration/Elsa.Core.IntegrationTests/Workflows/WhileWorkflowTests.cs b/test/integration/Elsa.Core.IntegrationTests/Workflows/WhileWorkflowTests.cs
index b33af513a..7e52d202b 100644
--- a/test/integration/Elsa.Core.IntegrationTests/Workflows/WhileWorkflowTests.cs
+++ b/test/integration/Elsa.Core.IntegrationTests/Workflows/WhileWorkflowTests.cs
@@ -1,6 +1,5 @@
using System.Linq;
using System.Threading.Tasks;
-using Elsa.Testing.Shared.Helpers;
using Elsa.Testing.Shared.Unit;
using Xunit;
using Xunit.Abstractions;