Skip to content

Commit

Permalink
Tweaks on merged PR. (#14073)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkech authored Aug 4, 2023
1 parent 2eed4fa commit 9db3db9
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public async Task<IEnumerable<ContentItem>> QueryContainedItemsAsync(
{
if (enableOrdering)
{
var beforeValue = int.Parse(pager.Before);
var beforeValue = Int32.Parse(pager.Before);
query = _session.Query<ContentItem>()
.With(CreateOrderedContainedPartIndexFilter(beforeValue, null, contentItemId))
.OrderByDescending(x => x.Order);
Expand Down Expand Up @@ -233,7 +233,7 @@ public async Task<IEnumerable<ContentItem>> QueryContainedItemsAsync(
}
else
{
var afterValue = new DateTime(long.Parse(pager.After));
var afterValue = new DateTime(Int64.Parse(pager.After));
query = _session.Query<ContentItem>()
.With(CreateOrderedContainedPartIndexFilter(null, null, contentItemId));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ protected override void EditActivity(WorkflowFaultEvent activity, WorkflowFaultV
{
model.ErrorFilter = activity.ErrorFilter.Expression;
}

protected override void UpdateActivity(WorkflowFaultViewModel model, WorkflowFaultEvent activity)
{
activity.ErrorFilter = new WorkflowExpression<bool>(model.ErrorFilter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace OrchardCore.Workflows.Events
{
public class WorkflowFaultEvent : EventActivity
{
private readonly IStringLocalizer<WorkflowFaultEvent> S;
protected readonly IStringLocalizer<WorkflowFaultEvent> S;
private readonly IWorkflowScriptEvaluator _scriptEvaluator;

public WorkflowFaultEvent(
Expand All @@ -20,6 +20,7 @@ public WorkflowFaultEvent(
S = stringLocalizer;
_scriptEvaluator = scriptEvaluator;
}

public override string Name => nameof(WorkflowFaultEvent);
public override LocalizedString DisplayText => S["Catch Workflow Fault Event"];
public override LocalizedString Category => S["Background"];
Expand All @@ -44,7 +45,7 @@ public override async Task<bool> CanExecuteAsync(WorkflowExecutionContext workfl
{
var faultModel = workflowContext.Input[WorkflowFaultModel.WorkflowFaultInputKey] as WorkflowFaultModel;

//Avoid endless loops
// Avoid endless loops.
if (faultModel == null || faultModel.WorkflowName == workflowContext.WorkflowType.Name)
{
return false;
Expand All @@ -53,7 +54,7 @@ public override async Task<bool> CanExecuteAsync(WorkflowExecutionContext workfl
return await _scriptEvaluator.EvaluateAsync(ErrorFilter, workflowContext);
}

private string GetDefaultValue()
private static string GetDefaultValue()
{
var sample = $@"//sample code
var errorInfo= input('{WorkflowFaultModel.WorkflowFaultInputKey}');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
using OrchardCore.Workflows.Events;
using OrchardCore.Workflows.Models;
using OrchardCore.Workflows.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using OrchardCore.Workflows.Events;
using OrchardCore.Workflows.Models;
using OrchardCore.Workflows.Services;

namespace OrchardCore.Workflows.Handlers
{
public class DefaultWorkflowFaultHandler : IWorkflowFaultHandler
{
public async Task OnWorkflowFaultAsync(IWorkflowManager workflowManager, WorkflowExecutionContext workflowContext,
public async Task OnWorkflowFaultAsync(
IWorkflowManager workflowManager,
WorkflowExecutionContext workflowContext,
ActivityContext activityContext,
Exception exception)
{
Expand All @@ -19,7 +21,7 @@ public async Task OnWorkflowFaultAsync(IWorkflowManager workflowManager, Workflo
{
WorkflowId = workflowContext.Workflow.WorkflowId,
WorkflowName = workflowContext.WorkflowType.Name,
ExecutedActivityCount = workflowContext.ExecutedActivities.Count(),
ExecutedActivityCount = workflowContext.ExecutedActivities.Count,
FaultMessage = workflowContext.Workflow.FaultMessage,
ActivityId = activityContext.ActivityRecord.ActivityId,
ActivityTypeName = activityContext.Activity.Name,
Expand All @@ -30,9 +32,7 @@ public async Task OnWorkflowFaultAsync(IWorkflowManager workflowManager, Workflo

var input = new Dictionary<string, object>
{
{
WorkflowFaultModel.WorkflowFaultInputKey, faultContext
}
{ WorkflowFaultModel.WorkflowFaultInputKey, faultContext },
};

await workflowManager.TriggerEventAsync(name, input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public class WorkflowManager : IWorkflowManager

private readonly IActivityLibrary _activityLibrary;
private readonly IWorkflowTypeStore _workflowTypeStore;
private readonly IWorkflowFaultHandler _workflowFaultHandler;
private readonly IWorkflowStore _workflowStore;
private readonly IWorkflowIdGenerator _workflowIdGenerator;
private readonly Resolver<IEnumerable<IWorkflowValueSerializer>> _workflowValueSerializers;
private readonly IWorkflowFaultHandler _workflowFaultHandler;
private readonly IDistributedLock _distributedLock;
private readonly ILogger _logger;
private readonly ILogger<MissingActivity> _missingActivityLogger;
Expand All @@ -42,24 +42,24 @@ public WorkflowManager
IWorkflowStore workflowRepository,
IWorkflowIdGenerator workflowIdGenerator,
Resolver<IEnumerable<IWorkflowValueSerializer>> workflowValueSerializers,
IWorkflowFaultHandler workflowFaultHandler,
IDistributedLock distributedLock,
ILogger<WorkflowManager> logger,
ILogger<MissingActivity> missingActivityLogger,
IStringLocalizer<MissingActivity> missingActivityLocalizer,
IClock clock,
IWorkflowFaultHandler workflowFaultHandler)
IClock clock)
{
_activityLibrary = activityLibrary;
_workflowTypeStore = workflowTypeRepository;
_workflowStore = workflowRepository;
_workflowIdGenerator = workflowIdGenerator;
_workflowValueSerializers = workflowValueSerializers;
_workflowFaultHandler = workflowFaultHandler;
_distributedLock = distributedLock;
_logger = logger;
_missingActivityLogger = missingActivityLogger;
_missingActivityLocalizer = missingActivityLocalizer;
_clock = clock;
_workflowFaultHandler = workflowFaultHandler;
}

public Workflow NewWorkflow(WorkflowType workflowType, string correlationId = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
@using OrchardCore.Workflows.Events
@using OrchardCore.Workflows.Helpers
@using OrchardCore.Workflows.ViewModels

<header>
<h4><i class="fa fa-exclamation-circle"></i>@Model.Activity.GetTitleOrDefault(() => T["Workflow Fault Event"])</h4>
</header>
<em>&quot;@Model.Activity.ErrorFilter&quot;</em>
<em>&quot;@Model.Activity.ErrorFilter&quot;</em>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div id="@Html.IdFor(x => x.ErrorFilter)_editor" asp-for="Text" style="min-height: 400px;" class="form-control"></div>
<textarea asp-for="ErrorFilter" hidden>@Html.Raw(Model.ErrorFilter)</textarea>
<span asp-validation-for="ErrorFilter"></span>
<span class="hint">@T["Check the captured workflow error information and return a Boolean value. If it is true, it will be processed by the current workflow. Javascript syntax."]</span><br/>
<span class="hint">@T["Check the captured workflow error information and return a Boolean value. If it is true, it will be processed by the current workflow. Javascript syntax."]</span><br />
<span class="hint">
@T["You can use input('{0}') to get error information, contains the following attributes:", WorkflowFaultModel.WorkflowFaultInputKey]
</span>
Expand All @@ -29,10 +29,10 @@
<script at="Foot" depends-on="monaco">
$(function () {
require(['vs/editor/editor.main'], function () {
var settings= {
"automaticLayout": true,
"language": "javascript"
};
var settings = {
"automaticLayout": true,
"language": "javascript"
};
var html = document.getElementsByTagName("html")[0];
const mutationObserver = new MutationObserver(setTheme);
Expand All @@ -59,4 +59,4 @@
});
});
});
</script>
</script>
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using OrchardCore.Workflows.Models;
using System;
using System.Threading.Tasks;
using OrchardCore.Workflows.Models;

namespace OrchardCore.Workflows.Services
{
public interface IWorkflowFaultHandler
{
Task OnWorkflowFaultAsync(IWorkflowManager workflowManager,
Task OnWorkflowFaultAsync(
IWorkflowManager workflowManager,
WorkflowExecutionContext workflowContext,
ActivityContext activityContext,
Exception exception);
Expand Down
4 changes: 2 additions & 2 deletions test/OrchardCore.Tests/Workflows/WorkflowManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ WorkflowType workflowType
workflowStore.Object,
workflowIdGenerator.Object,
workflowValueSerializers,
workflowFaultHandler.Object,
distributedLock.Object,
workflowManagerLogger.Object,
missingActivityLogger.Object,
missingActivityLocalizer.Object,
clock.Object,
workflowFaultHandler.Object
clock.Object
);

foreach (var activity in activities)
Expand Down

0 comments on commit 9db3db9

Please sign in to comment.