mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Fixes #7441
This commit is contained in:
committed by
Sébastien Ros
parent
8a328902fd
commit
4b2e1ca19d
@@ -165,6 +165,13 @@ namespace Orchard.ImportExport.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(customSteps)) {
|
if (!String.IsNullOrEmpty(customSteps)) {
|
||||||
|
var customStepsList = customSteps.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
foreach (var customStepName in customStepsList) {
|
||||||
|
GetOrCreateElement(stepsElement, customStepName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Still need CustomStepsStep to support older export steps created by users
|
||||||
var customStepsElement = GetOrCreateElement(stepsElement, "CustomSteps");
|
var customStepsElement = GetOrCreateElement(stepsElement, "CustomSteps");
|
||||||
customStepsElement.Attr("Steps", customSteps);
|
customStepsElement.Attr("Steps", customSteps);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ using Orchard.Recipes.Services;
|
|||||||
namespace Orchard.ImportExport.Providers.ExportActions {
|
namespace Orchard.ImportExport.Providers.ExportActions {
|
||||||
public class BuildRecipeAction : ExportAction {
|
public class BuildRecipeAction : ExportAction {
|
||||||
private readonly IEnumerable<IRecipeBuilderStep> _recipeBuilderSteps;
|
private readonly IEnumerable<IRecipeBuilderStep> _recipeBuilderSteps;
|
||||||
|
private readonly IRecipeBuilderStepResolver _recipeBuilderStepResolver;
|
||||||
private readonly IRecipeBuilder _recipeBuilder;
|
private readonly IRecipeBuilder _recipeBuilder;
|
||||||
private readonly IOrchardServices _orchardServices;
|
private readonly IOrchardServices _orchardServices;
|
||||||
|
|
||||||
public BuildRecipeAction(IEnumerable<IRecipeBuilderStep> recipeBuilderSteps, IRecipeBuilder recipeBuilder, IOrchardServices orchardServices) {
|
public BuildRecipeAction(IRecipeBuilderStepResolver recipeBuilderStepResolver, IEnumerable<IRecipeBuilderStep> recipeBuilderSteps, IRecipeBuilder recipeBuilder, IOrchardServices orchardServices) {
|
||||||
_recipeBuilderSteps = recipeBuilderSteps;
|
_recipeBuilderSteps = recipeBuilderSteps;
|
||||||
|
_recipeBuilderStepResolver = recipeBuilderStepResolver;
|
||||||
_recipeBuilder = recipeBuilder;
|
_recipeBuilder = recipeBuilder;
|
||||||
_orchardServices = orchardServices;
|
_orchardServices = orchardServices;
|
||||||
|
|
||||||
@@ -60,10 +62,7 @@ namespace Orchard.ImportExport.Providers.ExportActions {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var exportStepNames = viewModel.Steps.Where(x => x.IsSelected).Select(x => x.Name);
|
var exportStepNames = viewModel.Steps.Where(x => x.IsSelected).Select(x => x.Name);
|
||||||
var stepsQuery = from name in exportStepNames
|
var stepsQuery = _recipeBuilderStepResolver.Resolve(exportStepNames);
|
||||||
let provider = _recipeBuilderSteps.SingleOrDefault(x => x.Name == name)
|
|
||||||
where provider != null
|
|
||||||
select provider;
|
|
||||||
var steps = stepsQuery.ToArray();
|
var steps = stepsQuery.ToArray();
|
||||||
var stepUpdater = new Updater(updater, secondHalf => String.Format("{0}.{1}", Prefix, secondHalf));
|
var stepUpdater = new Updater(updater, secondHalf => String.Format("{0}.{1}", Prefix, secondHalf));
|
||||||
foreach (var exportStep in steps) {
|
foreach (var exportStep in steps) {
|
||||||
@@ -86,7 +85,7 @@ namespace Orchard.ImportExport.Providers.ExportActions {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var stepElement in recipeBuilderStepsElement.Elements()) {
|
foreach (var stepElement in recipeBuilderStepsElement.Elements()) {
|
||||||
var step = _recipeBuilderSteps.SingleOrDefault(x => x.Name == stepElement.Name.LocalName);
|
var step = _recipeBuilderStepResolver.Resolve(stepElement.Name.LocalName);
|
||||||
|
|
||||||
if (step != null) {
|
if (step != null) {
|
||||||
var stepContext = new RecipeBuilderStepConfigurationContext(stepElement);
|
var stepContext = new RecipeBuilderStepConfigurationContext(stepElement);
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ namespace Orchard.Recipes.Providers.RecipeHandlers {
|
|||||||
/// Delegates execution of the step to the appropriate recipe execution step implementation.
|
/// Delegates execution of the step to the appropriate recipe execution step implementation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RecipeExecutionStepHandler : Component, IRecipeHandler {
|
public class RecipeExecutionStepHandler : Component, IRecipeHandler {
|
||||||
private readonly IEnumerable<IRecipeExecutionStep> _recipeExecutionSteps;
|
private readonly IRecipeExecutionStepResolver _recipeExecutionStepResolver;
|
||||||
public RecipeExecutionStepHandler(IEnumerable<IRecipeExecutionStep> recipeExecutionSteps) {
|
public RecipeExecutionStepHandler(IRecipeExecutionStepResolver recipeExecutionStepResolver) {
|
||||||
_recipeExecutionSteps = recipeExecutionSteps;
|
_recipeExecutionStepResolver = recipeExecutionStepResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExecuteRecipeStep(RecipeContext recipeContext) {
|
public void ExecuteRecipeStep(RecipeContext recipeContext) {
|
||||||
var executionStep = _recipeExecutionSteps.FirstOrDefault(x => x.Names.Contains(recipeContext.RecipeStep.Name));
|
var executionStep = _recipeExecutionStepResolver.Resolve(recipeContext.RecipeStep.Name);
|
||||||
var recipeExecutionContext = new RecipeExecutionContext {ExecutionId = recipeContext.ExecutionId, RecipeStep = recipeContext.RecipeStep};
|
var recipeExecutionContext = new RecipeExecutionContext {ExecutionId = recipeContext.ExecutionId, RecipeStep = recipeContext.RecipeStep};
|
||||||
|
|
||||||
if (executionStep != null) {
|
if (executionStep != null) {
|
||||||
|
|||||||
@@ -190,12 +190,16 @@
|
|||||||
<Compile Include="Recipes\Models\BuildContext.cs" />
|
<Compile Include="Recipes\Models\BuildContext.cs" />
|
||||||
<Compile Include="Recipes\Services\IRecipeBuilder.cs" />
|
<Compile Include="Recipes\Services\IRecipeBuilder.cs" />
|
||||||
<Compile Include="Recipes\Services\IRecipeBuilderStep.cs" />
|
<Compile Include="Recipes\Services\IRecipeBuilderStep.cs" />
|
||||||
|
<Compile Include="Recipes\Services\IRecipeBuilderStepResolver.cs" />
|
||||||
<Compile Include="Recipes\Services\IRecipeExecutionStep.cs" />
|
<Compile Include="Recipes\Services\IRecipeExecutionStep.cs" />
|
||||||
|
<Compile Include="Recipes\Services\IRecipeExecutionStepResolver.cs" />
|
||||||
<Compile Include="Recipes\Services\IRecipeExecutor.cs" />
|
<Compile Include="Recipes\Services\IRecipeExecutor.cs" />
|
||||||
<Compile Include="Recipes\Services\IRecipeResultAccessor.cs" />
|
<Compile Include="Recipes\Services\IRecipeResultAccessor.cs" />
|
||||||
<Compile Include="Recipes\Services\RecipeBuilder.cs" />
|
<Compile Include="Recipes\Services\RecipeBuilder.cs" />
|
||||||
<Compile Include="Recipes\Services\RecipeBuilderStep.cs" />
|
<Compile Include="Recipes\Services\RecipeBuilderStep.cs" />
|
||||||
<Compile Include="Recipes\Models\RecipeExecutionContext.cs" />
|
<Compile Include="Recipes\Models\RecipeExecutionContext.cs" />
|
||||||
|
<Compile Include="Recipes\Services\RecipeExecutionStepResolver.cs" />
|
||||||
|
<Compile Include="Recipes\Services\RecipeBuilderStepResolver.cs" />
|
||||||
<Compile Include="Recipes\Services\RecipeExecutionLogger.cs" />
|
<Compile Include="Recipes\Services\RecipeExecutionLogger.cs" />
|
||||||
<Compile Include="Recipes\Services\RecipeExecutionStep.cs" />
|
<Compile Include="Recipes\Services\RecipeExecutionStep.cs" />
|
||||||
<Compile Include="Recipes\Services\RecipeExecutor.cs" />
|
<Compile Include="Recipes\Services\RecipeExecutor.cs" />
|
||||||
|
|||||||
10
src/Orchard/Recipes/Services/IRecipeBuilderStepResolver.cs
Normal file
10
src/Orchard/Recipes/Services/IRecipeBuilderStepResolver.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Orchard.Recipes.Services
|
||||||
|
{
|
||||||
|
public interface IRecipeBuilderStepResolver : IDependency
|
||||||
|
{
|
||||||
|
IRecipeBuilderStep Resolve(string exportStepName);
|
||||||
|
IEnumerable<IRecipeBuilderStep> Resolve(IEnumerable<string> exportStepNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/Orchard/Recipes/Services/IRecipeExecutionStepResolver.cs
Normal file
10
src/Orchard/Recipes/Services/IRecipeExecutionStepResolver.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Orchard.Recipes.Services
|
||||||
|
{
|
||||||
|
public interface IRecipeExecutionStepResolver :IDependency
|
||||||
|
{
|
||||||
|
IRecipeExecutionStep Resolve(string importStepName);
|
||||||
|
IEnumerable<IRecipeExecutionStep> Resolve(IEnumerable<string> exportStepNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
src/Orchard/Recipes/Services/RecipeBuilderStepResolver.cs
Normal file
28
src/Orchard/Recipes/Services/RecipeBuilderStepResolver.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Orchard.Recipes.Services
|
||||||
|
{
|
||||||
|
public class RecipeBuilderStepResolver : IRecipeBuilderStepResolver
|
||||||
|
{
|
||||||
|
private readonly IEnumerable<IRecipeBuilderStep> _recipeBuilderSteps;
|
||||||
|
|
||||||
|
public RecipeBuilderStepResolver(IEnumerable<IRecipeBuilderStep> recipeBuilderSteps) {
|
||||||
|
_recipeBuilderSteps = recipeBuilderSteps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRecipeBuilderStep Resolve(string exportStepName) {
|
||||||
|
return _recipeBuilderSteps.SingleOrDefault(x => x.Name == exportStepName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<IRecipeBuilderStep> Resolve(IEnumerable<string> exportStepNames) {
|
||||||
|
return from name in exportStepNames
|
||||||
|
let provider = _recipeBuilderSteps.SingleOrDefault(x => x.Name == name)
|
||||||
|
where provider != null
|
||||||
|
select provider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
28
src/Orchard/Recipes/Services/RecipeExecutionStepResolver.cs
Normal file
28
src/Orchard/Recipes/Services/RecipeExecutionStepResolver.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Orchard.Recipes.Services
|
||||||
|
{
|
||||||
|
public class RecipeExecutionStepResolver : IRecipeExecutionStepResolver
|
||||||
|
{
|
||||||
|
private readonly IEnumerable<IRecipeExecutionStep> _recipeExecutionSteps;
|
||||||
|
|
||||||
|
public RecipeExecutionStepResolver(IEnumerable<IRecipeExecutionStep> recipeExecutionSteps) {
|
||||||
|
_recipeExecutionSteps = recipeExecutionSteps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRecipeExecutionStep Resolve(string importStepName) {
|
||||||
|
return _recipeExecutionSteps.SingleOrDefault(x => x.Names.Contains(importStepName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<IRecipeExecutionStep> Resolve(IEnumerable<string> importStepNames) {
|
||||||
|
return from name in importStepNames
|
||||||
|
let provider = _recipeExecutionSteps.SingleOrDefault(x => x.Names.Contains(name))
|
||||||
|
where provider != null
|
||||||
|
select provider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user