Skip to content

Commit

Permalink
merged changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pksorensen committed Nov 2, 2023
2 parents 85dd373 + b5bece6 commit 6292a0b
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 45 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
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, IAction action, 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
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"))
{


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 6292a0b

Please sign in to comment.