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.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</PropertyGroup>

<PropertyGroup Label="PackageVersions">
<ElsaVersion>3.6.0-preview.2950</ElsaVersion>
<ElsaStudioVersion>3.6.0-preview.1018</ElsaStudioVersion>
<ElsaVersion>3.6.0-preview.3000</ElsaVersion>
<ElsaStudioVersion>3.6.0-preview.1029</ElsaStudioVersion>
</PropertyGroup>
</Project>
18 changes: 9 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup Label="Elsa">
<PackageVersion Include="DistributedLock.FileSystem" Version="1.0.3" />
<PackageVersion Include="Elsa" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Api.Common" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Common" Version="$(ElsaVersion)" />
Expand All @@ -17,17 +16,17 @@
<PackageVersion Include="Elsa.Labels" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Resilience" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Tenants" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Testing.Shared.Component" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Testing.Shared.Integration" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Workflows.Api" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Testing.Shared.Component" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Testing.Shared.Integration" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Workflows.Api" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Workflows.Core" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Workflows.Management" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Workflows.Runtime" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Workflows.Runtime.ProtoActor" Version="$(ElsaVersion)" />
<PackageVersion Include="Elsa.Studio.Core" Version="$(ElsaStudioVersion)" />
<PackageVersion Include="Elsa.Studio.Shared" Version="$(ElsaStudioVersion)" />
<PackageVersion Include="Elsa.Studio.Workflows" Version="$(ElsaStudioVersion)" />
<PackageVersion Include="Elsa.Scripting.JavaScript" Version="3.6.0-preview.28" /> <!-- Remove after core packages are built -->
<PackageVersion Include="Elsa.Studio.Workflows" Version="$(ElsaStudioVersion)" />
<PackageVersion Include="Elsa.Scripting.JavaScript" Version="3.6.0-preview.28" /> <!-- Remove after core packages are built -->
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Antlr4.Runtime.Standard" Version="4.13.1" />
Expand All @@ -51,6 +50,7 @@
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="Cronos" Version="0.11.0" />
<PackageVersion Include="Dapper" Version="2.1.66" />
<PackageVersion Include="DistributedLock.FileSystem" Version="1.0.3" />
<PackageVersion Include="Elastic.Clients.Elasticsearch" Version="9.0.3" />
<PackageVersion Include="FastEndpoints" Version="5.34.0" />
<PackageVersion Include="FastEndpoints.Security" Version="5.34.0" />
Expand Down Expand Up @@ -97,9 +97,9 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.5" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.5" />
<PackageVersion Include="Microsoft.Extensions.Resilience" Version="9.5.0" />
<PackageVersion Include="Microsoft.Identity.Client" Version="4.72.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.52.0" />
<PackageVersion Include="Microsoft.Identity.Client" Version="4.72.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
<PackageVersion Include="Microsoft.SemanticKernel" Version="1.53.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="MongoDB.Driver" Version="3.4.0" />
<PackageVersion Include="MongoDB.Driver.Core.Extensions.DiagnosticSources" Version="2.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ namespace Elsa.Alterations.Activities;
public class AlterationPlanCompleted : Trigger
{
/// <inheritdoc />
public AlterationPlanCompleted(Variable<string> planId, [CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
public AlterationPlanCompleted(Variable<string> planId, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
{
PlanId = new Input<string>(planId);
}

/// <inheritdoc />
public AlterationPlanCompleted([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
public AlterationPlanCompleted([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
{
}

/// <summary>
/// The ID of the alteration plan.
/// </summary>
public Input<string> PlanId { get; set; } = default!;
public Input<string> PlanId { get; set; } = null!;

/// <inheritdoc />
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ namespace Elsa.Alterations.Activities;
public class CompleteAlterationPlan : CodeActivity
{
/// <inheritdoc />
public CompleteAlterationPlan(Variable<string> planId, [CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
public CompleteAlterationPlan(Variable<string> planId, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
{
PlanId = new Input<string>(planId);
}

/// <inheritdoc />
public CompleteAlterationPlan([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
public CompleteAlterationPlan([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
{
}

/// <summary>
/// The ID of the alteration plan.
/// </summary>
public Input<string> PlanId { get; set; } = default!;
public Input<string> PlanId { get; set; } = null!;

/// <inheritdoc />
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ namespace Elsa.Alterations.Activities;
public class DispatchAlterationJobs : CodeActivity
{
/// <inheritdoc />
public DispatchAlterationJobs(Variable<string> planId, [CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
public DispatchAlterationJobs(Variable<string> planId, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
{
PlanId = new Input<string>(planId);
}

/// <inheritdoc />
public DispatchAlterationJobs([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
public DispatchAlterationJobs([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
{
}

/// <summary>
/// The ID of the alteration plan.
/// </summary>
public Input<string> PlanId { get; set; } = default!;
public Input<string> PlanId { get; set; } = null!;

/// <inheritdoc />
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ namespace Elsa.Alterations.Activities;
public class GenerateAlterationJobs : CodeActivity<int>
{
/// <inheritdoc />
public GenerateAlterationJobs([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
public GenerateAlterationJobs([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
{
}

/// <inheritdoc />
public GenerateAlterationJobs(Variable<string> planId, [CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
public GenerateAlterationJobs(Variable<string> planId, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
{
PlanId = new Input<string>(planId);
}

/// <summary>
/// The ID of the submitted alteration plan.
/// </summary>
public Input<string> PlanId { get; set; } = default!;
public Input<string> PlanId { get; set; } = null!;

/// <inheritdoc />
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class SubmitAlterationPlan : CodeActivity<string>
/// <summary>
/// The parameters for the alteration plan to be submitted.
/// </summary>
public Input<AlterationPlanParams> Params { get; set; } = default!;
public Input<AlterationPlanParams> Params { get; set; } = null!;

/// <inheritdoc />
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,24 @@ private Task UnloadDropInAssemblyAsync(string fullPath)
}
return Task.CompletedTask;
}

/// <inheritdoc />
public override async Task StopAsync(CancellationToken cancellationToken)
{
_watcher.EnableRaisingEvents = false;
_watcher.Changed -= OnChanged;
_watcher.Deleted -= OnDeleted;

await base.StopAsync(cancellationToken);
}

/// <inheritdoc />
public override void Dispose()
{
_watcher.Changed -= OnChanged;
_watcher.Deleted -= OnDeleted;
_watcher.Dispose();

base.Dispose();
}
}
16 changes: 8 additions & 8 deletions src/email/Elsa.Email/Activities/SendEmail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ namespace Elsa.Email.Activities;
public class SendEmail : Activity
{
/// <inheritdoc />
public SendEmail([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
public SendEmail([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
{
}

/// <summary>
/// The sender's email address.
/// </summary>
[Input(Description = "The sender's email address.")]
public Input<string?> From { get; set; } = default!;
public Input<string?> From { get; set; } = null!;

/// <summary>
/// The recipients email addresses.
/// </summary>
[Input(Description = "The recipients email addresses.", UIHint = InputUIHints.MultiText)]
public Input<ICollection<string>> To { get; set; } = default!;
public Input<ICollection<string>> To { get; set; } = null!;

/// <summary>
/// The CC recipient email addresses.
Expand All @@ -47,7 +47,7 @@ public SendEmail([CallerFilePath] string? source = default, [CallerLineNumber] i
Description = "The CC recipient email addresses.",
UIHint = InputUIHints.MultiText,
Category = "More")]
public Input<ICollection<string>> Cc { get; set; } = default!;
public Input<ICollection<string>> Cc { get; set; } = null!;

/// <summary>
/// The BCC recipients email addresses.
Expand All @@ -56,13 +56,13 @@ public SendEmail([CallerFilePath] string? source = default, [CallerLineNumber] i
Description = "The BCC recipients email addresses.",
UIHint = InputUIHints.MultiText,
Category = "More")]
public Input<ICollection<string>> Bcc { get; set; } = default!;
public Input<ICollection<string>> Bcc { get; set; } = null!;

/// <summary>
/// The subject of the email message.
/// </summary>
[Input(Description = "The subject of the email message.")]
public Input<string?> Subject { get; set; } = default!;
public Input<string?> Subject { get; set; } = null!;

/// <summary>
/// The attachments to send with the email message.
Expand All @@ -71,7 +71,7 @@ public SendEmail([CallerFilePath] string? source = default, [CallerLineNumber] i
Description = "The attachments to send with the email message. Can be (an array of) a fully-qualified file path, URL, stream, byte array or instances of EmailAttachment.",
UIHint = InputUIHints.MultiLine
)]
public Input<object?> Attachments { get; set; } = default!;
public Input<object?> Attachments { get; set; } = null!;

/// <summary>
/// The body of the email message.
Expand All @@ -80,7 +80,7 @@ public SendEmail([CallerFilePath] string? source = default, [CallerLineNumber] i
Description = "The body of the email message.",
UIHint = InputUIHints.MultiLine
)]
public Input<string> Body { get; set; } = default!;
public Input<string> Body { get; set; } = null!;

/// <summary>
/// The activity to execute when an error occurs while trying to send the email.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
};

protected IServiceProvider ServiceProvider { get; }
private readonly ElsaDbContextOptions? _elsaDbContextOptions;
private readonly ElsaDbContextOptions? elsaDbContextOptions;
public string? TenantId { get; set; }

/// <summary>
Expand All @@ -41,10 +41,10 @@ public abstract class ElsaDbContextBase : DbContext, IElsaDbContextSchema
protected ElsaDbContextBase(DbContextOptions options, IServiceProvider serviceProvider) : base(options)
{
ServiceProvider = serviceProvider;
_elsaDbContextOptions = options.FindExtension<ElsaDbContextOptionsExtension>()?.Options;
elsaDbContextOptions = options.FindExtension<ElsaDbContextOptionsExtension>()?.Options;

// ReSharper disable once VirtualMemberCallInConstructor
Schema = !string.IsNullOrWhiteSpace(_elsaDbContextOptions?.SchemaName) ? _elsaDbContextOptions.SchemaName : ElsaSchema;
Schema = !string.IsNullOrWhiteSpace(elsaDbContextOptions?.SchemaName) ? elsaDbContextOptions.SchemaName : ElsaSchema;

var tenantAccessor = serviceProvider.GetService<ITenantAccessor>();
var tenantId = tenantAccessor?.Tenant?.Id;
Expand All @@ -63,19 +63,19 @@ public override async Task<int> SaveChangesAsync(CancellationToken cancellationT
/// <inheritdoc />
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
if (!string.IsNullOrWhiteSpace(Schema))
if (!string.IsNullOrWhiteSpace(Schema))
modelBuilder.HasDefaultSchema(Schema);

var additionalConfigurations = _elsaDbContextOptions?.GetModelConfigurations(this);
var additionalConfigurations = elsaDbContextOptions?.GetModelConfigurations(this);

additionalConfigurations?.Invoke(modelBuilder);

using var scope = ServiceProvider.CreateScope();
var entityTypeHandlers = scope.ServiceProvider.GetServices<IEntityModelCreatingHandler>().ToList();

foreach (var entityType in modelBuilder.Model.GetEntityTypes().ToList())
{
foreach (var handler in entityTypeHandlers)
foreach (var handler in entityTypeHandlers)
handler.Handle(this, modelBuilder, entityType);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Linq.Expressions;
using Elsa.Common.Entities;
using Elsa.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query;

namespace Elsa.Persistence.EFCore.EntityHandlers;

Expand All @@ -15,15 +13,32 @@ public class SetTenantIdFilter : IEntityModelCreatingHandler
/// <inheritdoc />
public void Handle(ElsaDbContextBase dbContext, ModelBuilder modelBuilder, IMutableEntityType entityType)
{
if (!entityType.ClrType.IsAssignableTo(typeof(Entity)))
if (!typeof(Entity).IsAssignableFrom(entityType.ClrType))
return;

var tenantId = dbContext.TenantId.NullIfEmpty();
var parameter = Expression.Parameter(entityType.ClrType);
Expression<Func<Entity, bool>> filterExpr = entity => entity.TenantId == tenantId;
var body = ReplacingExpressionVisitor.Replace(filterExpr.Parameters[0], parameter, filterExpr.Body);
var lambdaExpression = Expression.Lambda(body, parameter);
modelBuilder
.Entity(entityType.ClrType)
.HasQueryFilter(CreateTenantFilterExpression(dbContext, entityType.ClrType));
}

private LambdaExpression CreateTenantFilterExpression(ElsaDbContextBase dbContext, Type clrType)
{
var parameter = Expression.Parameter(clrType, "e");

// e => EF.Property<string>(e, "TenantId") == this.TenantId
var tenantIdProperty = Expression.Call(
typeof(EF),
nameof(EF.Property),
[typeof(string)],
parameter,
Expression.Constant("TenantId"));

var tenantIdOnContext = Expression.Property(
Expression.Constant(dbContext),
nameof(ElsaDbContextBase.TenantId));

var body = Expression.Equal(tenantIdProperty, tenantIdOnContext);

entityType.SetQueryFilter(lambdaExpression);
return Expression.Lambda(body, parameter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public async Task<RunWorkflowInstanceResponse> CreateAndRunInstanceAsync(CreateA
Variables = request.Variables,
Properties = request.Properties,
TriggerActivityId = request.TriggerActivityId,
ActivityHandle = request.ActivityHandle
ActivityHandle = request.ActivityHandle,
IncludeWorkflowOutput = request.IncludeWorkflowOutput
}, cancellationToken));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ public override Task Create(CreateWorkflowInstanceRequest request, Action<Create
public override Task Run(RunWorkflowInstanceRequest request, Action<RunWorkflowInstanceResponse> respond, Action<string> onError)
{
var mappedRequest = mappers.RunWorkflowParamsMapper.Map(request);
var includeOutput = request.IncludeWorkflowOutput;
Context.ReenterAfter(RunAsync(mappedRequest), async completedTask =>
{
if (completedTask.IsFaulted)
onError(completedTask.Exception.Message);
else
{
var result = await completedTask;
respond(mappers.RunWorkflowInstanceResponseMapper.Map(result));
respond(mappers.RunWorkflowInstanceResponseMapper.Map(result, includeOutput));
}
});

Expand Down Expand Up @@ -144,7 +145,7 @@ private async Task<RunWorkflowInstanceResponse> CreateAndRunAsync(CreateAndRunWo

var result = await RunAsync(runWorkflowOptions);

return mappers.RunWorkflowInstanceResponseMapper.Map(result);
return mappers.RunWorkflowInstanceResponseMapper.Map(result, request.IncludeWorkflowOutput);
}

public override Task Stop()
Expand Down
Loading
Loading