Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.11"/>
<PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.11"/>
<PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="9.0.11"/>
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.0.11"/>
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.10.0"/>
<PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.11"/>
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.11"/>
<PackageVersion Include="Microsoft.Extensions.Resilience" Version="9.0.11"/>
<PackageVersion Include="Microsoft.Extensions.Resilience" Version="9.10.0"/>
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.11"/>
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.11"/>
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.11"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- Pomelo targets EF Core up to 9.x, so exclude MySQL provider for net10.0. -->
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Description>
Provides MySQL EF Core migrations for various modules.
</Description>
<PackageTags>elsa extension module persistence efcore mysql</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" PrivateAssets="all" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" PrivateAssets="all"/>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Elsa.Persistence.EFCore\Elsa.Persistence.EFCore.csproj" />
<ProjectReference Include="..\Elsa.Persistence.EFCore\Elsa.Persistence.EFCore.csproj"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -81,32 +81,54 @@ private string GetActivityDetails(JsonElement activityRoot, out int activityType
activityDescriptor = null;
activityTypeVersion = 0;

// First try and find the activity by its workflow definition version id. This is a special case when working with the WorkflowDefinitionActivity.
if (activityRoot.TryGetProperty("workflowDefinitionVersionId", out var workflowDefinitionVersionIdElement))
{
var workflowDefinitionVersionId = workflowDefinitionVersionIdElement.GetString();
activityDescriptor = activityRegistry.Find(x =>
x.CustomProperties.TryGetValue("WorkflowDefinitionVersionId", out var value) && (string?)value == workflowDefinitionVersionId);
activityTypeVersion = activityDescriptor?.Version ?? 0;
}
// First we check whether the activity type name is a 'well-known' activity; not a workflow-as-activity

// If the activity type version is specified, use that to find the activity descriptor.
if (activityDescriptor == null && activityRoot.TryGetProperty("version", out var activityVersionElement))
if (activityRoot.TryGetProperty("version", out var activityVersionElement))
{
activityTypeVersion = activityVersionElement.GetInt32();
activityDescriptor = activityRegistry.Find(activityTypeName, activityTypeVersion);
}

// If the activity type version is not specified, use the latest version of the activity descriptor.
// If a version is not specified, or activity with specified version is not found: use the latest version of the activity descriptor.
if (activityDescriptor == null)
{
activityDescriptor = activityRegistry.Find(activityTypeName);
activityTypeVersion = activityDescriptor?.Version ?? 0;
}

// This is a special case when working with the WorkflowDefinitionActivity: workflowDefinitionVersionId should be used to find the workflow-as-activity.
if (activityRoot.TryGetProperty("workflowDefinitionVersionId", out var workflowDefinitionVersionIdElement))
{
var activityDescriptorOverride = FindActivityDescriptorByCustomProperty("WorkflowDefinitionVersionId", workflowDefinitionVersionIdElement);
if (activityDescriptorOverride is not null)
{
activityDescriptor = FindActivityDescriptorByCustomProperty("WorkflowDefinitionVersionId", workflowDefinitionVersionIdElement);
Comment thread
sfmskywalker marked this conversation as resolved.
Outdated
Comment thread
sfmskywalker marked this conversation as resolved.
Outdated
Comment thread
sfmskywalker marked this conversation as resolved.
Outdated
activityTypeVersion = activityDescriptor?.Version ?? 0;
}
}
// This is also a special case when working with the WorkflowDefinitionActivity: if no 'well-known' activity could be found, it might be a workflow-as-activity with a workflowDefinitionId
else if (activityDescriptor is null
&& activityRoot.TryGetProperty("workflowDefinitionId", out var workflowDefinitionIdElement)
&& workflowDefinitionIdElement.ValueKind == JsonValueKind.String)
{
activityDescriptor = FindActivityDescriptorByCustomProperty("WorkflowDefinitionId", workflowDefinitionIdElement);
activityTypeVersion = activityDescriptor?.Version ?? 0;
}

return activityTypeName;
}

private ActivityDescriptor? FindActivityDescriptorByCustomProperty(string customPropertyName, JsonElement valueElement)
{
Comment thread
sfmskywalker marked this conversation as resolved.
var searchValue = valueElement.GetString();
return activityRegistry.Find(x =>
{
return x.CustomProperties.TryGetValue(customPropertyName, out var value)
&& (string?)value == searchValue;
});
}

private JsonSerializerOptions GetClonedOptions(JsonSerializerOptions options)
{
var clonedOptions = new JsonSerializerOptions(options);
Expand Down
Loading
Loading