From 2f82769938003001b2dec086429375f815d8aa0c Mon Sep 17 00:00:00 2001 From: Martin Othamar Date: Thu, 28 Nov 2024 11:08:21 +0100 Subject: [PATCH 1/3] Register IInstanceAndEventsRepository --- src/Storage/Controllers/ProcessController.cs | 5 +++++ src/Storage/Repository/ServiceCollectionExtensions.cs | 1 + 2 files changed, 6 insertions(+) diff --git a/src/Storage/Controllers/ProcessController.cs b/src/Storage/Controllers/ProcessController.cs index 7a15fafe..e17de480 100644 --- a/src/Storage/Controllers/ProcessController.cs +++ b/src/Storage/Controllers/ProcessController.cs @@ -132,6 +132,11 @@ public async Task> PutInstanceAndEvents( return NotFound(); } + foreach (InstanceEvent instanceEvent in processStateUpdate.Events) + { + instanceEvent.Created = instanceEvent.Created?.ToUniversalTime() ?? DateTime.UtcNow; + } + ProcessState processState = processStateUpdate.State; var (action, taskId) = ActionMapping(processState, existingInstance); diff --git a/src/Storage/Repository/ServiceCollectionExtensions.cs b/src/Storage/Repository/ServiceCollectionExtensions.cs index d759266a..5b2625cf 100644 --- a/src/Storage/Repository/ServiceCollectionExtensions.cs +++ b/src/Storage/Repository/ServiceCollectionExtensions.cs @@ -22,6 +22,7 @@ public static IServiceCollection AddRepositoriesPostgreSQL(this IServiceCollecti .AddSingleton() .AddSingleton() .AddSingleton() + .AddSingleton() .AddSingleton() .AddSingleton() .AddNpgsqlDataSource(connectionString, builder => builder.EnableParameterLogging(logParameters).EnableDynamicJson()); From 9de685377aefb9892f97d685b3ee0db076cbb50a Mon Sep 17 00:00:00 2001 From: Martin Othamar Date: Thu, 28 Nov 2024 11:10:18 +0100 Subject: [PATCH 2/3] Set instance ID if not set --- src/Storage/Controllers/ProcessController.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Storage/Controllers/ProcessController.cs b/src/Storage/Controllers/ProcessController.cs index e17de480..0b5578f7 100644 --- a/src/Storage/Controllers/ProcessController.cs +++ b/src/Storage/Controllers/ProcessController.cs @@ -134,6 +134,10 @@ public async Task> PutInstanceAndEvents( foreach (InstanceEvent instanceEvent in processStateUpdate.Events) { + if (string.IsNullOrWhiteSpace(instanceEvent.InstanceId)) + { + instanceEvent.InstanceId = $"{instanceOwnerPartyId}/{instanceGuid}"; + } instanceEvent.Created = instanceEvent.Created?.ToUniversalTime() ?? DateTime.UtcNow; } From b5f5e7226de3e84b6ac1a260bd001f7d81fe4b95 Mon Sep 17 00:00:00 2001 From: Martin Othamar Date: Thu, 28 Nov 2024 11:15:03 +0100 Subject: [PATCH 3/3] Whitespace, null handling --- src/Storage/Controllers/ProcessController.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Storage/Controllers/ProcessController.cs b/src/Storage/Controllers/ProcessController.cs index 0b5578f7..13abd592 100644 --- a/src/Storage/Controllers/ProcessController.cs +++ b/src/Storage/Controllers/ProcessController.cs @@ -132,12 +132,13 @@ public async Task> PutInstanceAndEvents( return NotFound(); } - foreach (InstanceEvent instanceEvent in processStateUpdate.Events) + foreach (InstanceEvent instanceEvent in processStateUpdate.Events ?? []) { if (string.IsNullOrWhiteSpace(instanceEvent.InstanceId)) { instanceEvent.InstanceId = $"{instanceOwnerPartyId}/{instanceGuid}"; } + instanceEvent.Created = instanceEvent.Created?.ToUniversalTime() ?? DateTime.UtcNow; }