Merge pull request #6493 from elsa-workflows/bug/composite-activity-variables
Refactor variable merging logic in ActivityExecutionContext
This commit is contained in:
commit
d0d3ab1c1c
|
|
@ -12,6 +12,16 @@
|
|||
ports:
|
||||
- "5432:5432"
|
||||
|
||||
sqlserver:
|
||||
image: mcr.microsoft.com/mssql/server:2022-latest
|
||||
environment:
|
||||
- ACCEPT_EULA=Y
|
||||
- MSSQL_SA_PASSWORD=!Elsa2025@
|
||||
ports:
|
||||
- 1433:1433
|
||||
volumes:
|
||||
- sqlserver_data:/var/opt/mssql
|
||||
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: mysql
|
||||
|
|
@ -126,6 +136,7 @@
|
|||
- "14000:8080"
|
||||
|
||||
volumes:
|
||||
sqlserver_data:
|
||||
postgres-data:
|
||||
oracle-data-free1:
|
||||
mysql_data2:
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"Sqlite": "Data Source=App_Data/elsa.sqlite.db;Cache=Shared;",
|
||||
"SqlServer": "Server=localhost,1433;Initial Catalog=Elsa;User=sa;Password=!Elsa2025@;Encrypt=false;PersistSecurityInfo=false",
|
||||
"MySql": "Server=localhost;Database=elsa;Uid=admin;Pwd=password;",
|
||||
"PostgreSql": "Server=localhost;Username=elsa;Database=elsa;Port=5432;Password=elsa;SSLMode=Prefer;MaxPoolSize=2000;Timeout=60",
|
||||
"Citus": "Server=localhost;Username=citus;Database=citus;Port=9700;Password=citus;SSLMode=Prefer;MaxPoolSize=2000;Timeout=60",
|
||||
|
|
|
|||
|
|
@ -124,7 +124,20 @@ public partial class ActivityExecutionContext : IExecutionContext, IDisposable
|
|||
{
|
||||
var containerVariables = (Activity as IVariableContainer)?.Variables ?? Enumerable.Empty<Variable>();
|
||||
var dynamicVariables = DynamicVariables;
|
||||
return containerVariables.Concat(dynamicVariables).DistinctBy(x => x.Name);
|
||||
var mergedVariables = new Dictionary<string, Variable>();
|
||||
|
||||
foreach (var containerVariable in containerVariables)
|
||||
{
|
||||
var name = !string.IsNullOrEmpty(containerVariable.Name) ? containerVariable.Name : containerVariable.Id;
|
||||
mergedVariables[name] = containerVariable;
|
||||
}
|
||||
|
||||
foreach (var dynamicVariable in dynamicVariables)
|
||||
{
|
||||
var name = !string.IsNullOrEmpty(dynamicVariable.Name) ? dynamicVariable.Name : dynamicVariable.Id;
|
||||
mergedVariables[name] = dynamicVariable;
|
||||
}
|
||||
return mergedVariables.Values;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class Variable : MemoryBlockReference
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Variable(string name, object? value = default) : this()
|
||||
public Variable(string name, object? value = null) : this()
|
||||
{
|
||||
Name = name;
|
||||
Value = value;
|
||||
|
|
@ -30,7 +30,7 @@ public class Variable : MemoryBlockReference
|
|||
/// <summary>
|
||||
/// The name of the variable.
|
||||
/// </summary>
|
||||
public string Name { get; set; } = default!;
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// A default value for the variable.
|
||||
|
|
@ -89,6 +89,12 @@ public class Variable<T> : Variable
|
|||
StorageDriverType = typeof(TDriver);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Variable<T> WithId(string id)
|
||||
{
|
||||
Id = id;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in a new issue