Enhanced Delete of variable persistence manager to allow drivers filtering with tags (#6558) (#6559)
This commit is contained in:
parent
bd2fcb4d21
commit
be455ee11b
|
|
@ -21,10 +21,16 @@ public interface IVariablePersistenceManager
|
|||
/// <summary>
|
||||
/// Deletes the specified variables from the <see cref="ActivityExecutionContext"/>.
|
||||
/// </summary>
|
||||
Task DeleteVariablesAsync(ActivityExecutionContext context);
|
||||
/// <param name="context"></param>
|
||||
/// <param name="includeTags"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteVariablesAsync(ActivityExecutionContext context, IEnumerable<string>? includeTags = default);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified variables from the <see cref="WorkflowExecutionContext"/>.
|
||||
/// </summary>
|
||||
Task DeleteVariablesAsync(WorkflowExecutionContext context);
|
||||
/// <param name="context"></param>
|
||||
/// <param name="includeTags"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteVariablesAsync(WorkflowExecutionContext context, IEnumerable<string>? includeTags = default);
|
||||
}
|
||||
|
|
@ -100,11 +100,12 @@ public class VariablePersistenceManager(IStorageDriverManager storageDriverManag
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task DeleteVariablesAsync(ActivityExecutionContext context)
|
||||
public async Task DeleteVariablesAsync(ActivityExecutionContext context, IEnumerable<string>? includeTags = default)
|
||||
{
|
||||
var register = context.ExpressionExecutionContext.Memory;
|
||||
var variableList = GetLocalVariables(context).ToList();
|
||||
var cancellationToken = context.CancellationToken;
|
||||
var includeTagsList = includeTags?.ToList();
|
||||
|
||||
foreach (var variable in variableList)
|
||||
{
|
||||
|
|
@ -116,6 +117,9 @@ public class VariablePersistenceManager(IStorageDriverManager storageDriverManag
|
|||
|
||||
if (driver == null)
|
||||
continue;
|
||||
|
||||
if (includeTagsList != null && !driver.Tags.Any(includeTagsList.Contains))
|
||||
continue;
|
||||
|
||||
var id = GetStateId(variable);
|
||||
var storageDriverContext = new StorageDriverContext(context, variable, cancellationToken);
|
||||
|
|
@ -125,13 +129,14 @@ public class VariablePersistenceManager(IStorageDriverManager storageDriverManag
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task DeleteVariablesAsync(WorkflowExecutionContext context)
|
||||
public async Task DeleteVariablesAsync(WorkflowExecutionContext context, IEnumerable<string>? includeTags = default)
|
||||
{
|
||||
var activityContexts = context.ActivityExecutionContexts.ToList();
|
||||
|
||||
var includeTagsList = includeTags?.ToList();
|
||||
|
||||
foreach (var activityContext in activityContexts)
|
||||
{
|
||||
await DeleteVariablesAsync(activityContext);
|
||||
await DeleteVariablesAsync(activityContext, includeTagsList);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue