Remove redundant activity metadata properties from ActivityExecutionRecordSnapshot and streamline mapping logic

Deleted unused metadata properties to simplify `ActivityExecutionRecordSnapshot`. Updated `GetOrMapCapturedActivityExecutionRecordAsync` to maintain serialized snapshots when mapping, ensuring consistency in activity execution records.
This commit is contained in:
Sipke Schoorstra 2025-07-24 19:47:26 +02:00
parent 18ee694d23
commit 61179bcb53
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F
3 changed files with 6 additions and 30 deletions

View file

@ -18,10 +18,12 @@ public static class ActivityExecutionContextRecordExtensions
public static async Task<ActivityExecutionRecord> GetOrMapCapturedActivityExecutionRecordAsync(this ActivityExecutionContext context)
{
if(context.TransientProperties.TryGetValue(ActivityExecutionRecordKey, out var record))
return (ActivityExecutionRecord)record;
var mapper = context.GetRequiredService<IActivityExecutionMapper>();
return await mapper.MapAsync(context);
var record = await mapper.MapAsync(context);
if (context.TransientProperties.TryGetValue(ActivityExecutionRecordKey, out var capturedRecord))
record.SerializedSnapshot = ((ActivityExecutionRecord)capturedRecord).SerializedSnapshot;
return record;
}
}

View file

@ -2,19 +2,6 @@ namespace Elsa.Workflows.Runtime;
public class ActivityExecutionRecordSnapshot
{
public string Id { get; set; } = null!;
public string? TenantId { get; set; }
public string WorkflowInstanceId { get; set; } = null!;
public string ActivityId { get; set; } = null!;
public string ActivityNodeId { get; set; } = null!;
public string ActivityType { get; set; } = null!;
public int ActivityTypeVersion { get; set; }
public string? ActivityName { get; set; }
public DateTimeOffset StartedAt { get; set; }
public bool HasBookmarks { get; set; }
public ActivityStatus Status { get; set; }
public int AggregateFaultCount { get; set; }
public DateTimeOffset? CompletedAt { get; set; }
public string? SerializedActivityState { get; set; }
public string? SerializedOutputs { get; set; }
public string? SerializedProperties { get; set; }

View file

@ -58,19 +58,6 @@ public class DefaultActivityExecutionMapper(
var serializedMetadata = record.Metadata != null ? payloadSerializer.Serialize(record.Metadata) : null;
record.SerializedSnapshot = new()
{
Id = record.Id,
TenantId = record.TenantId,
WorkflowInstanceId = record.WorkflowInstanceId,
ActivityId = record.ActivityId,
ActivityNodeId = record.ActivityNodeId,
ActivityType = record.ActivityType,
ActivityTypeVersion = record.ActivityTypeVersion,
ActivityName = record.ActivityName,
StartedAt = record.StartedAt,
HasBookmarks = record.HasBookmarks,
Status = record.Status,
AggregateFaultCount = record.AggregateFaultCount,
CompletedAt = record.CompletedAt,
SerializedActivityState = compressedSerializedActivityState,
SerializedActivityStateCompressionAlgorithm = compressionAlgorithm,
SerializedOutputs = record.Outputs?.Any() == true ? safeSerializer.Serialize(record.Outputs) : null,