Cleanup
This commit is contained in:
parent
d28d8fa3c8
commit
b4180d8e6f
|
|
@ -1,8 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Elsa.Models;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.ActivityResults
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
using System;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Builders
|
||||
{
|
||||
public interface IConnectionBuilder
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Elsa.Models;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Elsa.Models;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
using Elsa.Models;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using Elsa.Services.Models;
|
||||
using MediatR;
|
||||
|
||||
namespace Elsa.Messaging.Domain
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ using System.Reflection;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Models;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Services
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Elsa.Services.Models
|
||||
{
|
||||
|
|
@ -30,8 +29,7 @@ namespace Elsa.Services.Models
|
|||
public string Type { get; set; } = default!;
|
||||
|
||||
public bool PersistWorkflow { get; set; }
|
||||
|
||||
//public JObject Data { get; set; } = new JObject();
|
||||
|
||||
public Func<ActivityExecutionContext, CancellationToken, ValueTask<IActivity>> CreateActivityAsync { get; set; } = default!;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Models;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Services.Models
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Elsa.Services.Models
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using Elsa.Models;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Elsa.Services.Models
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using Elsa.Expressions;
|
|||
using Elsa.Models;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NodaTime;
|
||||
|
||||
namespace Elsa.Services.Models
|
||||
{
|
||||
|
|
@ -17,54 +16,26 @@ namespace Elsa.Services.Models
|
|||
IServiceProvider serviceProvider,
|
||||
IWorkflowBlueprint workflowBlueprint,
|
||||
WorkflowInstance workflowInstance
|
||||
//IWorkflow workflow,
|
||||
//WorkflowStatus status,
|
||||
//Variables variables,
|
||||
//string correlationId,
|
||||
//IWorkflowFault? workflowFault,
|
||||
//ICollection<IScheduledActivity> scheduledActivities,
|
||||
//ICollection<IActivity> blockingActivities,
|
||||
//IEnumerable<IExecutionLogEntry>? executionLog = default
|
||||
)
|
||||
{
|
||||
ServiceProvider = serviceProvider;
|
||||
WorkflowBlueprint = workflowBlueprint;
|
||||
//WorkflowDefinition = workflowDefinition;
|
||||
WorkflowInstance = workflowInstance;
|
||||
//Workflow = workflow;
|
||||
//CorrelationId = correlationId;
|
||||
ExpressionEvaluator = expressionEvaluator;
|
||||
ScheduledActivities = new Stack<ScheduledActivity>(workflowInstance.ScheduledActivities.Reverse());
|
||||
//BlockingActivities = new HashSet<IActivity>(blockingActivities);
|
||||
//Variables = variables;
|
||||
//Status = status;
|
||||
//PersistenceBehavior = workflow.PersistenceBehavior;
|
||||
//ActivityPropertyProviders = workflow.ActivityPropertyProviders;
|
||||
//WorkflowFault = workflowFault;
|
||||
ExecutionLog = new List<ExecutionLogEntry>(workflowInstance.ExecutionLog);
|
||||
IsFirstPass = true;
|
||||
}
|
||||
|
||||
private ScheduledActivity CreateScheduledActivity(ScheduledActivity scheduledActivityModel) =>
|
||||
new ScheduledActivity(scheduledActivityModel.ActivityId, scheduledActivityModel.Input);
|
||||
|
||||
public IWorkflowBlueprint WorkflowBlueprint { get; }
|
||||
|
||||
public IServiceProvider ServiceProvider { get; }
|
||||
|
||||
// public WorkflowDefinition WorkflowDefinition { get; }
|
||||
public WorkflowInstance WorkflowInstance { get; }
|
||||
public WorkflowStatus Status { get; set; }
|
||||
public Stack<ScheduledActivity> ScheduledActivities { get; }
|
||||
|
||||
public HashSet<BlockingActivity> BlockingActivities { get; } =
|
||||
new HashSet<BlockingActivity>(new BlockingActivityEqualityComparer());
|
||||
|
||||
public Variables Variables { get; }
|
||||
public bool HasScheduledActivities => ScheduledActivities.Any();
|
||||
public ScheduledActivity? ScheduledActivity { get; private set; }
|
||||
|
||||
public bool HasScheduledActivities => WorkflowInstance.ScheduledActivities.Any();
|
||||
public IWorkflowFault? WorkflowFault { get; private set; }
|
||||
public object? Output { get; set; }
|
||||
public bool IsFirstPass { get; private set; }
|
||||
|
||||
public void ScheduleActivities(IEnumerable<string> activityIds, object? input = default)
|
||||
{
|
||||
|
|
@ -78,72 +49,35 @@ namespace Elsa.Services.Models
|
|||
ScheduleActivity(activity);
|
||||
}
|
||||
|
||||
public void ScheduleActivity(string activityId, object? input = default) =>
|
||||
ScheduleActivity(new ScheduledActivity(activityId, input));
|
||||
|
||||
public void ScheduleActivity(ScheduledActivity activity) => ScheduledActivities.Push(activity);
|
||||
public ScheduledActivity PopScheduledActivity() => ScheduledActivity = ScheduledActivities.Pop();
|
||||
public ScheduledActivity PeekScheduledActivity() => ScheduledActivities.Peek();
|
||||
public void ScheduleActivity(string activityId, object? input = default) => ScheduleActivity(new ScheduledActivity(activityId, input));
|
||||
public void ScheduleActivity(ScheduledActivity activity) => WorkflowInstance.ScheduledActivities.Push(activity);
|
||||
public ScheduledActivity PopScheduledActivity() => WorkflowInstance.ScheduledActivities.Pop();
|
||||
public ScheduledActivity PeekScheduledActivity() => WorkflowInstance.ScheduledActivities.Peek();
|
||||
public IExpressionEvaluator ExpressionEvaluator { get; }
|
||||
public string? CorrelationId { get; set; }
|
||||
public bool DeleteCompletedInstances { get; set; }
|
||||
public ICollection<ExecutionLogEntry> ExecutionLog { get; }
|
||||
public bool IsFirstPass { get; private set; }
|
||||
public WorkflowStatus Status => WorkflowInstance.Status;
|
||||
|
||||
public bool AddBlockingActivity(IActivity activity) =>
|
||||
BlockingActivities.Add(new BlockingActivity(activity.Id, activity.Type));
|
||||
|
||||
public void SetVariable(string name, object? value) => Variables.Set(name, JToken.FromObject(value!));
|
||||
public void SetVariable(string name, object? value) => WorkflowInstance.Variables.Set(name, JToken.FromObject(value!));
|
||||
public T GetVariable<T>(string name) => (T)GetVariable(name)!;
|
||||
public object? GetVariable(string name) => Variables.Get(name);
|
||||
public object? GetVariable(string name) => WorkflowInstance.Variables.Get(name);
|
||||
public void CompletePass() => IsFirstPass = false;
|
||||
|
||||
public void Suspend() => Status = WorkflowStatus.Suspended;
|
||||
public void Begin() => WorkflowInstance.Status = WorkflowStatus.Running;
|
||||
public void Resume() => WorkflowInstance.Status = WorkflowStatus.Running;
|
||||
public void Suspend() => WorkflowInstance.Status = WorkflowStatus.Suspended;
|
||||
|
||||
public void Fault(string? activityId, LocalizedString? message)
|
||||
{
|
||||
Status = WorkflowStatus.Faulted;
|
||||
WorkflowInstance.Status = WorkflowStatus.Faulted;
|
||||
WorkflowFault = new WorkflowFault(activityId, message);
|
||||
}
|
||||
|
||||
public void Complete() => Status = WorkflowStatus.Completed;
|
||||
public void Complete() => WorkflowInstance.Status = WorkflowStatus.Completed;
|
||||
|
||||
public IActivityBlueprint? GetActivity(string id) =>
|
||||
public IActivityBlueprint? GetActivityBlueprint(string id) =>
|
||||
WorkflowBlueprint.Activities.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
public WorkflowInstance UpdateWorkflowInstance()
|
||||
{
|
||||
var workflowInstance = WorkflowInstance;
|
||||
workflowInstance.Variables = Variables;
|
||||
|
||||
workflowInstance.ScheduledActivities = new Stack<Elsa.Models.ScheduledActivity>(
|
||||
ScheduledActivities.Select(x => new Elsa.Models.ScheduledActivity(x.ActivityId, x.Input)));
|
||||
|
||||
//workflowInstance.Activities =
|
||||
// WorkflowBlueprint.Activities.Select(x => new ActivityInstance(x.Id, x.Type, x.Output, Serialize(x))).ToList();
|
||||
|
||||
workflowInstance.BlockingActivities = BlockingActivities;
|
||||
workflowInstance.Status = Status;
|
||||
workflowInstance.CorrelationId = CorrelationId;
|
||||
workflowInstance.Output = Output;
|
||||
|
||||
var executionLog = workflowInstance.ExecutionLog.Concat(
|
||||
ExecutionLog.Select(x => new Elsa.Models.ExecutionLogEntry(x.ActivityId, x.Timestamp)));
|
||||
|
||||
workflowInstance.ExecutionLog = executionLog.ToList();
|
||||
|
||||
if (WorkflowFault != null)
|
||||
{
|
||||
workflowInstance.Fault = new Elsa.Models.WorkflowFault
|
||||
{
|
||||
FaultedActivityId = WorkflowFault.FaultedActivityId,
|
||||
Message = WorkflowFault.Message
|
||||
};
|
||||
}
|
||||
|
||||
return workflowInstance;
|
||||
}
|
||||
|
||||
private JObject Serialize(IActivity activity) => JObject.FromObject(activity);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using Elsa.Models;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace Elsa.Services.Models
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.ActivityResults;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Services;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.ActivityResults;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Services;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.ActivityResults;
|
||||
using Elsa.Attributes;
|
||||
using Elsa.Services;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
using System;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Builders
|
||||
{
|
||||
public class ConnectionBuilder : IConnectionBuilder
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using System.Threading.Tasks;
|
|||
using Elsa.Models;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Elsa.Data.Services
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace Elsa.Messaging.Domain.Handlers
|
|||
WorkflowExecutionContext workflowExecutionContext,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var workflowInstance = workflowExecutionContext.UpdateWorkflowInstance();
|
||||
var workflowInstance = workflowExecutionContext.WorkflowInstance;
|
||||
await _workflowInstanceManager.SaveAsync(workflowInstance, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Models;
|
||||
using Elsa.Services.Models;
|
||||
using MediatR;
|
||||
using NodaTime;
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ namespace Elsa.Services
|
|||
if (statusEvent != null)
|
||||
await _mediator.Publish(statusEvent, cancellationToken);
|
||||
|
||||
return workflowExecutionContext.UpdateWorkflowInstance();
|
||||
return workflowExecutionContext.WorkflowInstance;
|
||||
}
|
||||
|
||||
private async Task BeginWorkflow(
|
||||
|
|
@ -156,7 +156,7 @@ namespace Elsa.Services
|
|||
if (!await CanExecuteAsync(workflowExecutionContext, activity, input, cancellationToken))
|
||||
return;
|
||||
|
||||
workflowExecutionContext.Status = WorkflowStatus.Running;
|
||||
workflowExecutionContext.Begin();
|
||||
workflowExecutionContext.ScheduleActivity(activity.Id, input);
|
||||
await RunAsync(workflowExecutionContext, Execute, cancellationToken);
|
||||
}
|
||||
|
|
@ -178,7 +178,7 @@ namespace Elsa.Services
|
|||
return;
|
||||
|
||||
workflowExecutionContext.BlockingActivities.RemoveWhere(x => x.ActivityId == activityBlueprint.Id);
|
||||
workflowExecutionContext.Status = WorkflowStatus.Running;
|
||||
workflowExecutionContext.Resume();
|
||||
workflowExecutionContext.ScheduleActivity(activityBlueprint.Id, input);
|
||||
await RunAsync(workflowExecutionContext, Resume, cancellationToken);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ namespace Elsa.Scripting.Liquid.Handlers
|
|||
|
||||
context.MemberAccessStrategy.Register<ActivityExecutionContext, LiquidPropertyAccessor>(
|
||||
"Variables",
|
||||
x => new LiquidPropertyAccessor(name => ToFluidValue(x.WorkflowExecutionContext.Variables, name)));
|
||||
x => new LiquidPropertyAccessor(name => ToFluidValue(x.WorkflowExecutionContext.WorkflowInstance.Variables, name)));
|
||||
|
||||
context.MemberAccessStrategy.Register<ActivityExecutionContext, LiquidObjectAccessor<IActivityBlueprint>>(
|
||||
"Activities",
|
||||
x => new LiquidObjectAccessor<IActivityBlueprint>(name => GetActivityAsync(x, name)));
|
||||
|
||||
context.MemberAccessStrategy.Register<LiquidObjectAccessor<IActivity>, object>(GetActivityOutput);
|
||||
context.MemberAccessStrategy.Register<LiquidObjectAccessor<IActivity>, object?>(GetActivityOutput);
|
||||
|
||||
context.MemberAccessStrategy.Register<LiquidObjectAccessor<object>, object>(
|
||||
(x, name) => x.GetValueAsync(name));
|
||||
|
|
@ -52,7 +52,7 @@ namespace Elsa.Scripting.Liquid.Handlers
|
|||
context.MemberAccessStrategy.Register<ExpandoObject, object>(
|
||||
(x, name) => ((IDictionary<string, object>)x)[name]);
|
||||
|
||||
context.MemberAccessStrategy.Register<JObject, object>((source, name) => source[name]);
|
||||
context.MemberAccessStrategy.Register<JObject, object?>((source, name) => source[name]);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Elsa.Scripting.Liquid.Helpers
|
|||
/// </summary>
|
||||
public class LiquidPropertyAccessor : LiquidObjectAccessor<FluidValue>
|
||||
{
|
||||
public LiquidPropertyAccessor(Func<string, Task<FluidValue>> getter) : base(getter)
|
||||
public LiquidPropertyAccessor(Func<string, Task<FluidValue?>> getter) : base(getter!)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using AutoMapper;
|
||||
using Elsa.Models;
|
||||
using Elsa.Server.GraphQL.Models;
|
||||
using Elsa.Server.GraphQL.Types;
|
||||
|
||||
namespace Elsa.Server.GraphQL.Mapping
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue