diff --git a/src/OrchardCore.Modules/OrchardCore.Lists/Services/ContainerService.cs b/src/OrchardCore.Modules/OrchardCore.Lists/Services/ContainerService.cs index 43f93360f62..8ef110e0563 100644 --- a/src/OrchardCore.Modules/OrchardCore.Lists/Services/ContainerService.cs +++ b/src/OrchardCore.Modules/OrchardCore.Lists/Services/ContainerService.cs @@ -167,7 +167,7 @@ public async Task> QueryContainedItemsAsync( { if (enableOrdering) { - var beforeValue = int.Parse(pager.Before); + var beforeValue = Int32.Parse(pager.Before); query = _session.Query() .With(CreateOrderedContainedPartIndexFilter(beforeValue, null, contentItemId)) .OrderByDescending(x => x.Order); @@ -233,7 +233,7 @@ public async Task> QueryContainedItemsAsync( } else { - var afterValue = new DateTime(long.Parse(pager.After)); + var afterValue = new DateTime(Int64.Parse(pager.After)); query = _session.Query() .With(CreateOrderedContainedPartIndexFilter(null, null, contentItemId)); diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Drivers/WorkflowFaultEventDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Drivers/WorkflowFaultEventDisplayDriver.cs index f1da268f3d7..9de1a178b5c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Drivers/WorkflowFaultEventDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Drivers/WorkflowFaultEventDisplayDriver.cs @@ -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(model.ErrorFilter); diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Events/WorkflowFaultEvent.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Events/WorkflowFaultEvent.cs index a56c93b635e..3278d98b4cc 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Events/WorkflowFaultEvent.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Events/WorkflowFaultEvent.cs @@ -10,7 +10,7 @@ namespace OrchardCore.Workflows.Events { public class WorkflowFaultEvent : EventActivity { - private readonly IStringLocalizer S; + protected readonly IStringLocalizer S; private readonly IWorkflowScriptEvaluator _scriptEvaluator; public WorkflowFaultEvent( @@ -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"]; @@ -44,7 +45,7 @@ public override async Task 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; @@ -53,7 +54,7 @@ public override async Task 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}'); diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Handlers/DefaultWorkflowFaultHandler.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Handlers/DefaultWorkflowFaultHandler.cs index 2acbe72a0c5..117a3236cb2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Handlers/DefaultWorkflowFaultHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Handlers/DefaultWorkflowFaultHandler.cs @@ -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) { @@ -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, @@ -30,9 +32,7 @@ public async Task OnWorkflowFaultAsync(IWorkflowManager workflowManager, Workflo var input = new Dictionary { - { - WorkflowFaultModel.WorkflowFaultInputKey, faultContext - } + { WorkflowFaultModel.WorkflowFaultInputKey, faultContext }, }; await workflowManager.TriggerEventAsync(name, input); diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Services/WorkflowManager.cs b/src/OrchardCore.Modules/OrchardCore.Workflows/Services/WorkflowManager.cs index f923b308a52..9d2fcc7aaa2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Services/WorkflowManager.cs +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Services/WorkflowManager.cs @@ -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> _workflowValueSerializers; + private readonly IWorkflowFaultHandler _workflowFaultHandler; private readonly IDistributedLock _distributedLock; private readonly ILogger _logger; private readonly ILogger _missingActivityLogger; @@ -42,24 +42,24 @@ public WorkflowManager IWorkflowStore workflowRepository, IWorkflowIdGenerator workflowIdGenerator, Resolver> workflowValueSerializers, + IWorkflowFaultHandler workflowFaultHandler, IDistributedLock distributedLock, ILogger logger, ILogger missingActivityLogger, IStringLocalizer 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) diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/WorkflowFaultEvent.Fields.Design.cshtml b/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/WorkflowFaultEvent.Fields.Design.cshtml index 4d889280975..03ab8f8c571 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/WorkflowFaultEvent.Fields.Design.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/WorkflowFaultEvent.Fields.Design.cshtml @@ -2,7 +2,8 @@ @using OrchardCore.Workflows.Events @using OrchardCore.Workflows.Helpers @using OrchardCore.Workflows.ViewModels +

@Model.Activity.GetTitleOrDefault(() => T["Workflow Fault Event"])

-"@Model.Activity.ErrorFilter" \ No newline at end of file +"@Model.Activity.ErrorFilter" diff --git a/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/WorkflowFaultEvent.Fields.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/WorkflowFaultEvent.Fields.Edit.cshtml index ebdfef4859a..fdf807d86c1 100644 --- a/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/WorkflowFaultEvent.Fields.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Items/WorkflowFaultEvent.Fields.Edit.cshtml @@ -6,7 +6,7 @@
- @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."]
+ @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."]
@T["You can use input('{0}') to get error information, contains the following attributes:", WorkflowFaultModel.WorkflowFaultInputKey] @@ -29,10 +29,10 @@ \ No newline at end of file + diff --git a/src/OrchardCore/OrchardCore.Workflows.Abstractions/Services/IWorkflowFaultHandler.cs b/src/OrchardCore/OrchardCore.Workflows.Abstractions/Services/IWorkflowFaultHandler.cs index b85733e087c..d92c2441513 100644 --- a/src/OrchardCore/OrchardCore.Workflows.Abstractions/Services/IWorkflowFaultHandler.cs +++ b/src/OrchardCore/OrchardCore.Workflows.Abstractions/Services/IWorkflowFaultHandler.cs @@ -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); diff --git a/test/OrchardCore.Tests/Workflows/WorkflowManagerTests.cs b/test/OrchardCore.Tests/Workflows/WorkflowManagerTests.cs index f6c7d282249..d0b09e9596d 100644 --- a/test/OrchardCore.Tests/Workflows/WorkflowManagerTests.cs +++ b/test/OrchardCore.Tests/Workflows/WorkflowManagerTests.cs @@ -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)