Skip to content

Commit

Permalink
fix: merged dev in
Browse files Browse the repository at this point in the history
  • Loading branch information
pksorensen committed Nov 2, 2023
2 parents c5e9196 + 6e1bbc5 commit b5bece6
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 46 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v2


- name: Setup Git for Windows' minimal SDK
uses: git-for-windows/setup-git-for-windows-sdk@v1

- name: Print GIT verison
run: git --version

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
Expand Down Expand Up @@ -62,7 +68,7 @@ jobs:
- name: Print release verison
run: echo ${env:RELEASE_VERSION}

- name: Cleaning
run: dotnet clean

Expand Down
4 changes: 2 additions & 2 deletions apps/WorkflowEngine.DemoApp/WorkflowEngine.DemoApp.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Hangfire" Version="1.7.31" />
<PackageReference Include="Hangfire" Version="1.8.6" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 6 additions & 3 deletions src/WorkflowEngine.Core/ExpressionEngineExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public static async ValueTask<IDictionary<string, object>> ResolveInputs(this IE
{

var resolvedInputs = new Dictionary<string, object>();
if (inputs == null)
return resolvedInputs;


foreach (var input in inputs)
{
Expand All @@ -48,16 +51,16 @@ public static async ValueTask<IDictionary<string, object>> ResolveInputs(this IE
}

}

}

return resolvedInputs;

}
public static ValueTask<IDictionary<string,object>> ResolveInputs(this IExpressionEngine engine, ActionMetadata actionMetadata, ILogger logger)
public static ValueTask<IDictionary<string, object>> ResolveInputs(this IExpressionEngine engine, ActionMetadata actionMetadata, ILogger logger)
{
return engine.ResolveInputs(actionMetadata.Inputs, logger);

}
}
}
4 changes: 0 additions & 4 deletions src/WorkflowEngine.Core/IOutputsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ public interface IOutputsRepository
ValueTask<object> GetTriggerData(Guid id);
ValueTask AddInput(IRunContext context, IWorkflow workflow, IAction action);
ValueTask<object> GetOutputData(Guid id, string v);
ValueTask AddArrayItemAsync(IRunContext run, IWorkflow workflow, string key, IActionResult result);
ValueTask AddArrayInput(IRunContext context, IWorkflow workflow, IAction action);
// ValueTask StartScope(IRunContext context, IWorkflow workflow, IAction action);
ValueTask AddScopeItem(IRunContext context, IWorkflow workflow, IAction action, IActionResult result);
ValueTask EndScope(IRunContext run, IWorkflow workflow, IAction action);
ValueTask AddEvent(IRunContext run, IWorkflow workflow, IAction action, Event @event);
}
Expand Down
1 change: 1 addition & 0 deletions src/WorkflowEngine.Core/WorkflowActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ForLoopActionMetadata : ActionMetadata, IScopedActionMetadata
public interface IScopedActionMetadata
{
WorkflowActions Actions { get; set; }
string Type { get; set; }
}
public class WorkflowActions : Dictionary<string, ActionMetadata>
{
Expand Down
2 changes: 1 addition & 1 deletion src/WorkflowEngine.Core/WorkflowEngine.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
<PackageReference Include="Delegate.ExpressionEngine" Version="4.0.0" />
<PackageReference Include="Delegate.ExpressionEngine" Version="4.1.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
</ItemGroup>
Expand Down
7 changes: 2 additions & 5 deletions src/WorkflowEngine.Core/WorkflowExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ public WorkflowExecutor(ILogger<WorkflowExecutor> logger, IOutputsRepository ou
public ValueTask<IAction> GetNextAction(IRunContext context, IWorkflow workflow, IActionResult priorResult)
{
logger.LogInformation("Finding Next Action for {WorkflowId} and prior {@result} ", workflow.Id, priorResult);
//var action = workflow.Manifest.Actions.Single(c => c.Key == priorResult.Key);



var next = workflow.Manifest.Actions.FindNextAction(priorResult.Key);
//var parent = workflow.Manifest.Actions.FindParentAction(priorResult.Key) is ForLoopActionMetadata;


if (next.IsDefault())
return new ValueTask<IAction>();

Expand Down
2 changes: 1 addition & 1 deletion src/WorkflowEngine.Hangfire/HangfireWorkflowExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public async ValueTask<object> ExecuteAsync(IRunContext run, IWorkflow workflow,
(executor) => executor.ExecuteAsync(run, workflow, next, null));
// result.
}
else if (workflow.Manifest.Actions.FindParentAction(action.Key) is ForLoopActionMetadata scope)
else if (workflow.Manifest.Actions.FindParentAction(action.Key) is IScopedActionMetadata scope)
{
var scopeAction = run.CopyTo(new Action { ScopeMoveNext = true, Type = scope.Type, Key = action.Key.Substring(0, action.Key.LastIndexOf('.')), ScheduledTime = DateTimeOffset.UtcNow });

Expand Down
13 changes: 5 additions & 8 deletions src/WorkflowEngine.Hangfire/WorkflowEngine.Hangfire.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
Expand All @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Hangfire.Core" Version="1.7.31" />
<PackageReference Include="Hangfire.Core" Version="1.8.6" />

</ItemGroup>

Expand All @@ -21,11 +21,8 @@
<ItemGroup Condition="'$(TargetFramework)'=='net6.0'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
</ItemGroup>



<ItemGroup>
<ProjectReference Include="..\WorkflowEngine.Core\WorkflowEngine.Core.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WorkflowEngine.Core\WorkflowEngine.Core.csproj" />
</ItemGroup>

</Project>
50 changes: 30 additions & 20 deletions src/WorkflowEngine.Hangfire/WorkflowStarterBackgroundJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,31 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)

foreach (var workflow in await workflows.GetAllWorkflows())
{
var trigger = workflow.Manifest.Triggers.FirstOrDefault(t => t.Value.Type == "TimerTrigger");

if (!trigger.Equals(default(KeyValuePair<string, TriggerMetadata>)))
foreach (var trigger in workflow.Manifest.Triggers.Where(t => t.Value.Type == "TimerTrigger"))
{
workflow.Manifest = null;

jobs.AddOrUpdate<IHangfireWorkflowExecutor>(workflow.Id.ToString(),
(executor) => executor.TriggerAsync(new TriggerContext
{
Workflow = workflow,
Trigger = new Trigger

if (!trigger.Equals(default(KeyValuePair<string, TriggerMetadata>)))
{

workflow.Manifest = null;

jobs.AddOrUpdate(workflow.Id.ToString() + trigger.Key,
(System.Linq.Expressions.Expression<Action<IHangfireWorkflowExecutor>>)((executor) => executor.TriggerAsync(new TriggerContext
{
Inputs = trigger.Value.Inputs,
ScheduledTime = DateTimeOffset.UtcNow,
Type = trigger.Value.Type,
Key = trigger.Key
},
},null), trigger.Value.Inputs["cronExpression"] as string);

if (first && trigger.Value.Inputs.ContainsKey("runAtStartup") && (bool)trigger.Value.Inputs["runAtStartup"])
jobs.Trigger(workflow.Id.ToString());
Workflow = workflow,
Trigger = new Trigger
{
Inputs = trigger.Value.Inputs,
ScheduledTime = DateTimeOffset.UtcNow,
Type = trigger.Value.Type,
Key = trigger.Key
},
}, null)), trigger.Value.Inputs["cronExpression"] as string, GetTimeZone(trigger));

if (first && trigger.Value.Inputs.ContainsKey("runAtStartup") && (bool)trigger.Value.Inputs["runAtStartup"])
jobs.Trigger(workflow.Id.ToString());
}
}
}

Expand All @@ -66,7 +69,14 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)

}


static TimeZoneInfo GetTimeZone(KeyValuePair<string, TriggerMetadata> trigger)
{

if (trigger.Value.Inputs.ContainsKey("timezone") && trigger.Value.Inputs["timezone"] is string zone && !string.IsNullOrWhiteSpace(zone))
return TimeZoneInfo.FindSystemTimeZoneById(zone) ?? TimeZoneInfo.Utc;
return TimeZoneInfo.Utc;

}
}
}
}

0 comments on commit b5bece6

Please sign in to comment.