mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#5532: Checking for recipe steps having executed.
If no steps were scheduled, the user stays on the Import screen and a notification is displayed. Fixes #5532
This commit is contained in:
@@ -12,6 +12,7 @@ using Orchard.ImportExport.Services;
|
|||||||
using Orchard.ImportExport.ViewModels;
|
using Orchard.ImportExport.ViewModels;
|
||||||
using Orchard.Mvc;
|
using Orchard.Mvc;
|
||||||
using Orchard.Recipes.Services;
|
using Orchard.Recipes.Services;
|
||||||
|
using Orchard.UI.Notify;
|
||||||
|
|
||||||
namespace Orchard.ImportExport.Providers.ImportActions {
|
namespace Orchard.ImportExport.Providers.ImportActions {
|
||||||
public class UploadRecipeAction : ImportAction {
|
public class UploadRecipeAction : ImportAction {
|
||||||
@@ -136,6 +137,12 @@ namespace Orchard.ImportExport.Providers.ImportActions {
|
|||||||
_orchardServices.WorkContext.HttpContext.Server.ScriptTimeout = 600;
|
_orchardServices.WorkContext.HttpContext.Server.ScriptTimeout = 600;
|
||||||
|
|
||||||
var executionId = ResetSite ? Setup() : ExecuteRecipe();
|
var executionId = ResetSite ? Setup() : ExecuteRecipe();
|
||||||
|
|
||||||
|
if(executionId == null) {
|
||||||
|
_orchardServices.Notifier.Warning(T("The recipe contained no steps. No work was scheduled."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
context.ActionResult = new RedirectToRouteResult(new RouteValueDictionary(new { action = "ImportResult", controller = "Admin", area = "Orchard.ImportExport", executionId = executionId }));
|
context.ActionResult = new RedirectToRouteResult(new RouteValueDictionary(new { action = "ImportResult", controller = "Admin", area = "Orchard.ImportExport", executionId = executionId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Localization;
|
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
using Orchard.Recipes.Events;
|
using Orchard.Recipes.Events;
|
||||||
using Orchard.Recipes.Models;
|
using Orchard.Recipes.Models;
|
||||||
|
|
||||||
namespace Orchard.Recipes.Services {
|
namespace Orchard.Recipes.Services {
|
||||||
public class RecipeManager : IRecipeManager {
|
public class RecipeManager : Component, IRecipeManager {
|
||||||
private readonly IRecipeStepQueue _recipeStepQueue;
|
private readonly IRecipeStepQueue _recipeStepQueue;
|
||||||
private readonly IRecipeScheduler _recipeScheduler;
|
private readonly IRecipeScheduler _recipeScheduler;
|
||||||
private readonly IRecipeExecuteEventHandler _recipeExecuteEventHandler;
|
private readonly IRecipeExecuteEventHandler _recipeExecuteEventHandler;
|
||||||
@@ -22,17 +22,18 @@ namespace Orchard.Recipes.Services {
|
|||||||
_recipeScheduler = recipeScheduler;
|
_recipeScheduler = recipeScheduler;
|
||||||
_recipeExecuteEventHandler = recipeExecuteEventHandler;
|
_recipeExecuteEventHandler = recipeExecuteEventHandler;
|
||||||
_recipeStepResultRecordRepository = recipeStepResultRecordRepository;
|
_recipeStepResultRecordRepository = recipeStepResultRecordRepository;
|
||||||
|
|
||||||
Logger = NullLogger.Instance;
|
|
||||||
T = NullLocalizer.Instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Localizer T { get; set; }
|
|
||||||
public ILogger Logger { get; set; }
|
|
||||||
|
|
||||||
public string Execute(Recipe recipe) {
|
public string Execute(Recipe recipe) {
|
||||||
if (recipe == null)
|
if (recipe == null) {
|
||||||
|
Logger.Information("Cannot execute a null recipe. No work has been scheduled.");
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!recipe.RecipeSteps.Any()) {
|
||||||
|
Logger.Information("Recipe '{0}' contains no steps. No work has been scheduled.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var executionId = Guid.NewGuid().ToString("n");
|
var executionId = Guid.NewGuid().ToString("n");
|
||||||
Logger.Information("Executing recipe '{0}' using ExecutionId {1}.", recipe.Name, executionId);
|
Logger.Information("Executing recipe '{0}' using ExecutionId {1}.", recipe.Name, executionId);
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ using Orchard.Recipes.Models;
|
|||||||
|
|
||||||
namespace Orchard.Recipes.Services {
|
namespace Orchard.Recipes.Services {
|
||||||
public class RecipeParser : Component, IRecipeParser {
|
public class RecipeParser : Component, IRecipeParser {
|
||||||
|
public Recipe ParseRecipe(XDocument recipeDocument) {
|
||||||
|
return ParseRecipe(recipeDocument.ToString(SaveOptions.DisableFormatting));
|
||||||
|
}
|
||||||
|
|
||||||
public Recipe ParseRecipe(string recipeText) {
|
public Recipe ParseRecipe(string recipeText) {
|
||||||
var recipe = new Recipe();
|
var recipe = new Recipe();
|
||||||
|
|||||||
@@ -30,7 +30,11 @@ namespace Orchard.Recipes.Services {
|
|||||||
|
|
||||||
public string Execute(Recipe recipe) {
|
public string Execute(Recipe recipe) {
|
||||||
var executionId = _recipeManager.Execute(recipe);
|
var executionId = _recipeManager.Execute(recipe);
|
||||||
|
|
||||||
|
// Only need to update the shell if work was actually done.
|
||||||
|
if(executionId != null)
|
||||||
UpdateShell();
|
UpdateShell();
|
||||||
|
|
||||||
return executionId;
|
return executionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user