Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions src/apps/Elsa.Server.Web/Elsa.Server.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
<None Update="Workflows\for-loop.elsa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Workflows\flowchart-test.elsa">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
16 changes: 0 additions & 16 deletions src/apps/Elsa.Server.Web/Workflows/flowchart-test.elsa

This file was deleted.

29 changes: 0 additions & 29 deletions src/apps/Elsa.Server.Web/Workflows/multi-workflow-example.elsa

This file was deleted.

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
@@ -0,0 +1,8 @@
using FluentStorage.Blobs;

namespace Elsa.Extensions;

public static class BlobExtensions
{
public static string GetExtension(this Blob blob) => Path.GetExtension(blob.Name).TrimStart('.');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Elsa.WorkflowProviders.BlobStorage.Contracts;

namespace Elsa.Extensions;

public static class BlobWorkflowFormatHandlerExtensions
{
public static bool SupportsExtension(this IBlobWorkflowFormatHandler handler, string extension) => handler.SupportedExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Elsa.WorkflowProviders.BlobStorage.Contracts;
using Elsa.Extensions;
using Elsa.WorkflowProviders.BlobStorage.Contracts;
using Elsa.Workflows.Runtime;
using FluentStorage.Blobs;
using JetBrains.Annotations;
Expand Down Expand Up @@ -71,11 +72,13 @@ public async ValueTask<IEnumerable<MaterializedWorkflow>> GetWorkflowsAsync(Canc
{
var blobStorage = _blobStorageProvider.GetBlobStorage();
var content = await blobStorage.ReadTextAsync(blob.FullPath, cancellationToken: cancellationToken);

var contentType = blob.Properties.TryGetValue("ContentType", out var ct) ? ct?.ToString() : null;

foreach (var handler in _handlers)
{
if (!handler.SupportsExtension(blob.GetExtension()))
continue;

if (!handler.CanHandle(blob, contentType))
continue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,32 +81,53 @@ 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 null)
return activityTypeName;

activityDescriptor = activityDescriptorOverride;
activityTypeVersion = activityDescriptor.Version;
}
// 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.
if (valueElement.ValueKind != JsonValueKind.String)
return null;

var searchValue = valueElement.GetString();
return activityRegistry.Find(x => x.CustomProperties.TryGetValue(customPropertyName, out var value) && (string?)value == searchValue);
}

private JsonSerializerOptions GetClonedOptions(JsonSerializerOptions options)
{
var clonedOptions = new JsonSerializerOptions(options);
Expand All @@ -115,7 +136,7 @@ private JsonSerializerOptions GetClonedOptions(JsonSerializerOptions options)
clonedOptions.Converters.Add(new ExpressionJsonConverterFactory(expressionDescriptorRegistry));
return clonedOptions;
}

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