Skip to content

Commit

Permalink
Fix solution build
Browse files Browse the repository at this point in the history
  • Loading branch information
sfmskywalker committed Oct 16, 2020
1 parent ab7fd8c commit bbf0cfa
Show file tree
Hide file tree
Showing 27 changed files with 204 additions and 308 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ insert_final_newline=false
indent_style=space
indent_size=4

# ReSharper properties
resharper_csharp_max_line_length=240
resharper_keep_user_linebreaks=true

7 changes: 0 additions & 7 deletions Samples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.CustomActiviti
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.TimesheetApproval", "src\samples\Elsa.Samples.TimesheetApproval\Elsa.Samples.TimesheetApproval.csproj", "{1678743A-9095-4683-8DCD-5763F41924E2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.WorkflowDefinition", "src\samples\Elsa.Samples.WorkflowDefinition\Elsa.Samples.WorkflowDefinition.csproj", "{7AC91435-7D10-4353-9064-598A6F8EAED6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.DistributedLocking.Redis", "src\providers\Elsa.DistributedLocking.Redis\Elsa.DistributedLocking.Redis.csproj", "{EBD49CCA-5400-4C36-B5DF-7B28190AA323}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Samples.DistributedLock", "src\samples\Elsa.Samples.DistributedLock\Elsa.Samples.DistributedLock.csproj", "{4D162E3C-0962-43B9-B193-6E806249F81B}"
Expand Down Expand Up @@ -194,10 +192,6 @@ Global
{1678743A-9095-4683-8DCD-5763F41924E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1678743A-9095-4683-8DCD-5763F41924E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1678743A-9095-4683-8DCD-5763F41924E2}.Release|Any CPU.Build.0 = Release|Any CPU
{7AC91435-7D10-4353-9064-598A6F8EAED6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AC91435-7D10-4353-9064-598A6F8EAED6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AC91435-7D10-4353-9064-598A6F8EAED6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AC91435-7D10-4353-9064-598A6F8EAED6}.Release|Any CPU.Build.0 = Release|Any CPU
{EBD49CCA-5400-4C36-B5DF-7B28190AA323}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EBD49CCA-5400-4C36-B5DF-7B28190AA323}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EBD49CCA-5400-4C36-B5DF-7B28190AA323}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -250,7 +244,6 @@ Global
{A11D79AE-F4C9-4595-9B73-0E0AB221B90D} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
{554C21D7-10BE-48E6-B0EF-9FCA43B32A0F} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
{1678743A-9095-4683-8DCD-5763F41924E2} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
{7AC91435-7D10-4353-9064-598A6F8EAED6} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
{4D162E3C-0962-43B9-B193-6E806249F81B} = {5E5E1E84-DDBC-40D6-B891-0D563A15A44A}
{7CD5C8D5-EC78-4A99-A514-F01CA7197AC8} = {DA71CDAA-8DD3-4D5F-9FBD-8E4B37A2D925}
{E20238CE-5C64-4F87-8753-3B4E1EC9A740} = {7CD5C8D5-EC78-4A99-A514-F01CA7197AC8}
Expand Down
2 changes: 2 additions & 0 deletions Samples.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_USER_LINEBREAKS/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINES/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EF/@EntryIndexedValue">EF</s:String></wpf:ResourceDictionary>
4 changes: 2 additions & 2 deletions src/core/Elsa.Abstractions/Builders/IWorkflowBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ IActivityBuilder New<T>(
where T : class, IActivity;

IActivityBuilder New<T>(
Action<ISetupActivity<T>>? setup = default,
Action<ISetupActivity<T>>? setup,
Action<IActivityBuilder>? branch = default) where T : class, IActivity;

IActivityBuilder StartWith<T>(
Action<ISetupActivity<T>>? setup = default,
Action<ISetupActivity<T>>? setup,
Action<IActivityBuilder>? branch = default) where T : class, IActivity;

IActivityBuilder StartWith<T>(Action<IActivityBuilder>? branch = default)
Expand Down
2 changes: 1 addition & 1 deletion src/core/Elsa.Abstractions/Services/Activity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Elsa.Services
{
public abstract class Activity : IActivity
{
public virtual string Type => GetType().Name;
public string Type => GetType().Name;
public string Id { get; set; } = default!;
public string? Name { get; set; }
public string? DisplayName { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/core/Elsa.Abstractions/Services/IActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface IActivity
/// <summary>
/// The type name of this activity.
/// </summary>
string Type { get; set; }
string Type { get;}

/// <summary>
/// Unique identifier of this activity within the workflow.
Expand Down
2 changes: 1 addition & 1 deletion src/core/Elsa.Abstractions/Services/IWorkflowProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ namespace Elsa.Services
/// </summary>
public interface IWorkflowProvider
{
Task<IEnumerable<WorkflowBlueprint>> GetWorkflowsAsync(CancellationToken cancellationToken);
Task<IEnumerable<IWorkflowBlueprint>> GetWorkflowsAsync(CancellationToken cancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Elsa.Services
{
public interface IWorkflowSchedulerQueue
{
void Enqueue(WorkflowBlueprint workflowBlueprint, IActivity activity, object? input, string? correlationId);
(WorkflowBlueprint Workflow, IActivity Activity, object? Input, string? CorrelationId)? Dequeue(string workflowDefinitionId, string activityId);
void Enqueue(IWorkflowBlueprint workflowBlueprint, IActivityBlueprint activity, object? input, string? correlationId);
(IWorkflowBlueprint Workflow, IActivityBlueprint Activity, object? Input, string? CorrelationId)? Dequeue(string workflowDefinitionId, string activityId);
}
}
14 changes: 5 additions & 9 deletions src/core/Elsa.Abstractions/Services/Models/ActivityBlueprint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,19 @@ public ActivityBlueprint()
{
}

public ActivityBlueprint(
Func<ActivityExecutionContext, CancellationToken, ValueTask<IActivity>> createActivity) =>
CreateActivityAsync = createActivity;
public ActivityBlueprint(Func<ActivityExecutionContext, CancellationToken, ValueTask<IActivity>> createActivity) => CreateActivityAsync = createActivity;

public ActivityBlueprint(
string id,
Func<ActivityExecutionContext, CancellationToken, ValueTask<IActivity>> createActivity)
public ActivityBlueprint(string id, Func<ActivityExecutionContext, CancellationToken, ValueTask<IActivity>> createActivity)
{
Id = id;
CreateActivityAsync = createActivity;
}

public string Id { get; set; } = default!;
public string? Name { get; set; }
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!;
public Func<ActivityExecutionContext, CancellationToken, ValueTask<IActivity>> CreateActivityAsync { get; set; } = default!;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ namespace Elsa.Services.Models
{
public class ExecutionLogEntry : IExecutionLogEntry
{
public ExecutionLogEntry(IActivity activity, Instant timestamp)
public ExecutionLogEntry(string activityId, Instant timestamp)
{
Activity = activity;
ActivityId = activityId;
Timestamp = timestamp;
}

public IActivity Activity { get; }
public string ActivityId { get; }
public Instant Timestamp { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ namespace Elsa.Services.Models
public interface IActivityBlueprint
{
public string Id { get; }
string? Name { get; }
public string Type { get; }
public bool PersistWorkflow { get; }
public JObject Data { get; }
Func<ActivityExecutionContext, CancellationToken, ValueTask<IActivity>> CreateActivityAsync { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Elsa.Services.Models
{
public interface IExecutionLogEntry
{
IActivity Activity { get; }
string ActivityId { get; }
Instant Timestamp { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ WorkflowInstance workflowInstance
//ICollection<IScheduledActivity> scheduledActivities,
//ICollection<IActivity> blockingActivities,
//IEnumerable<IExecutionLogEntry>? executionLog = default
)
)
{
ServiceProvider = serviceProvider;
WorkflowBlueprint = workflowBlueprint;
Expand All @@ -49,12 +49,17 @@ private IScheduledActivity CreateScheduledActivity(Elsa.Models.ScheduledActivity
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<IScheduledActivity> ScheduledActivities { get; }
public HashSet<BlockingActivity> BlockingActivities { get; } = new HashSet<BlockingActivity>(new BlockingActivityEqualityComparer());

public HashSet<BlockingActivity> BlockingActivities { get; } =
new HashSet<BlockingActivity>(new BlockingActivityEqualityComparer());

public Variables Variables { get; }
public bool HasScheduledActivities => ScheduledActivities.Any();
public IScheduledActivity? ScheduledActivity { get; private set; }
Expand Down Expand Up @@ -87,7 +92,9 @@ public void ScheduleActivity(string activityId, object? input = default) =>
public ICollection<IExecutionLogEntry> ExecutionLog { get; }
public bool IsFirstPass { get; private set; }

public bool AddBlockingActivity(IActivity activity) => BlockingActivities.Add(new BlockingActivity(activity.Id, activity.Type));
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 T GetVariable<T>(string name) => (T)GetVariable(name)!;
public object? GetVariable(string name) => Variables.Get(name);
Expand All @@ -103,10 +110,12 @@ public void Fault(string? activityId, LocalizedString? message)

public void Complete() => Status = WorkflowStatus.Completed;

public IActivityBlueprint? GetActivity(string id) => WorkflowBlueprint.Activities.FirstOrDefault(x => x.Id == id);
public IActivityBlueprint? GetActivity(string id) =>
WorkflowBlueprint.Activities.FirstOrDefault(x => x.Id == id);

public void UpdateWorkflowInstance(WorkflowInstance workflowInstance)
public WorkflowInstance UpdateWorkflowInstance()
{
var workflowInstance = WorkflowInstance;
workflowInstance.Variables = Variables;

workflowInstance.ScheduledActivities = new Stack<Elsa.Models.ScheduledActivity>(
Expand All @@ -121,7 +130,7 @@ public void UpdateWorkflowInstance(WorkflowInstance workflowInstance)
workflowInstance.Output = Output;

var executionLog = workflowInstance.ExecutionLog.Concat(
ExecutionLog.Select(x => new Elsa.Models.ExecutionLogEntry(x.Activity.Id, x.Timestamp)));
ExecutionLog.Select(x => new Elsa.Models.ExecutionLogEntry(x.ActivityId, x.Timestamp)));

workflowInstance.ExecutionLog = executionLog.ToList();

Expand All @@ -133,6 +142,8 @@ public void UpdateWorkflowInstance(WorkflowInstance workflowInstance)
Message = WorkflowFault.Message
};
}

return workflowInstance;
}

private JObject Serialize(IActivity activity) => JObject.FromObject(activity);
Expand Down
3 changes: 1 addition & 2 deletions src/core/Elsa.Core/Data/Services/DatabaseWorkflowProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public DatabaseWorkflowProvider(
_activityActivator = activityActivator;
}

public async Task<IEnumerable<WorkflowBlueprint>> GetWorkflowsAsync(CancellationToken cancellationToken)
public async Task<IEnumerable<IWorkflowBlueprint>> GetWorkflowsAsync(CancellationToken cancellationToken)
{
var workflowDefinitions = await _workflowDefinitionManager.ListAsync(cancellationToken);
return workflowDefinitions.Select(CreateWorkflow);
Expand Down Expand Up @@ -87,7 +87,6 @@ private ValueTask<IActivity> CreateActivityAsync(
activity.Description = activityDefinition.Description;
activity.Id = activityDefinition.Id;
activity.Name = activityDefinition.Name;
activity.Type = activityDefinition.Type;
activity.DisplayName = activityDefinition.DisplayName;
activity.PersistWorkflow = activityDefinition.PersistWorkflow;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ public async Task Handle(WorkflowCompleted notification, CancellationToken cance
{
_logger.LogDebug(
"Deleting completed workflow instance {WorkflowInstanceId}",
workflowExecutionContext.WorkflowInstanceId);
await _workflowInstanceManager.DeleteAsync(workflowExecutionContext.WorkflowInstance, cancellationToken);
workflowExecutionContext.WorkflowInstance.WorkflowInstanceId);
await _workflowInstanceManager.DeleteAsync(
workflowExecutionContext.WorkflowInstance,
cancellationToken);
}
else
{
await SaveWorkflowAsync(notification.WorkflowExecutionContext, cancellationToken);
}
}

private async ValueTask SaveWorkflowAsync(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken)
private async ValueTask SaveWorkflowAsync(
WorkflowExecutionContext workflowExecutionContext,
CancellationToken cancellationToken)
{
var workflowInstance = workflowExecutionContext.UpdateWorkflowInstance();
await _workflowInstanceManager.SaveAsync(workflowInstance, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public WorkflowExecutionLogEventHandler(IClock clock)

public Task Handle(ActivityExecuted notification, CancellationToken cancellationToken)
{
notification.WorkflowExecutionContext.ExecutionLog.Add(new ExecutionLogEntry(notification.Activity, _clock.GetCurrentInstant()));
notification.WorkflowExecutionContext.ExecutionLog.Add(
new ExecutionLogEntry(notification.Activity.Id, _clock.GetCurrentInstant()));

return Task.CompletedTask;
}
}
Expand Down
18 changes: 5 additions & 13 deletions src/core/Elsa.Core/Services/WorkflowHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ public async ValueTask<WorkflowInstance> RunWorkflowAsync(
correlationId,
cancellationToken);

return await RunWorkflowAsync(
workflowBlueprint,
workflowInstance,
activityId,
input,
cancellationToken);
return await RunWorkflowAsync(workflowBlueprint, workflowInstance, activityId, input, cancellationToken);
}


Expand All @@ -89,8 +84,7 @@ public async ValueTask<WorkflowInstance> RunWorkflowAsync(
cancellationToken);

if (workflowBlueprint == null)
throw new WorkflowException(
$"Workflow instance {workflowInstance.Id} references workflow definition {workflowInstance.WorkflowDefinitionId} version {workflowInstance.Version}, but no such workflow definition was found.");
throw new WorkflowException($"Workflow instance {workflowInstance.Id} references workflow definition {workflowInstance.WorkflowDefinitionId} version {workflowInstance.Version}, but no such workflow definition was found.");

return await RunWorkflowAsync(workflowBlueprint, workflowInstance, activityId, input, cancellationToken);
}
Expand Down Expand Up @@ -147,8 +141,7 @@ public async ValueTask<WorkflowInstance> RunWorkflowAsync(
if (statusEvent != null)
await _mediator.Publish(statusEvent, cancellationToken);

workflowExecutionContext.UpdateWorkflowInstance(workflowInstance);
return workflowInstance;
return workflowExecutionContext.UpdateWorkflowInstance();
}

private async Task BeginWorkflow(
Expand Down Expand Up @@ -204,7 +197,7 @@ private async ValueTask<bool> CanExecuteAsync(
activityBlueprint,
input);

var activity = await activityBlueprint.CreateActivityAsync();
var activity = await activityBlueprint.CreateActivityAsync(activityExecutionContext, cancellationToken);
return await activity.CanExecuteAsync(activityExecutionContext, cancellationToken);
}

Expand All @@ -227,8 +220,7 @@ private async ValueTask RunAsync(
activityBlueprint,
scheduledActivity.Input);

var activity = await activityBlueprint.CreateActivityAsync();

var activity = await activityBlueprint.CreateActivityAsync(activityExecutionContext, cancellationToken);
var result = await activityOperation(activityExecutionContext, activity, cancellationToken);
await _mediator.Publish(new ActivityExecuting(activityExecutionContext), cancellationToken);
await result.ExecuteAsync(activityExecutionContext, cancellationToken);
Expand Down
Loading

0 comments on commit bbf0cfa

Please sign in to comment.