mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-09 11:21:04 +08:00
Incremental work on recipe builder and execution step configuration.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ImportExport.Models;
|
||||
using Orchard.ImportExport.Services;
|
||||
using Orchard.ImportExport.ViewModels;
|
||||
using Orchard.Localization;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.ImportExport.Models {
|
||||
public class ExportActionConfigurationContext : ConfigurationContext {
|
||||
public ExportActionConfigurationContext(XElement configurationElement) : base(configurationElement) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.ImportExport.Models {
|
||||
[Obsolete]
|
||||
public class ExportOptions {
|
||||
public IEnumerable<string> CustomSteps { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.ImportExport.Models {
|
||||
public class ImportActionConfigurationContext : ConfigurationContext {
|
||||
protected ImportActionConfigurationContext(XElement configurationElement) : base(configurationElement) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.ImportExport.Services {
|
||||
namespace Orchard.ImportExport.Models {
|
||||
public class ImportActionContext {
|
||||
public ActionResult ActionResult { get; set; }
|
||||
}
|
||||
@@ -84,6 +84,8 @@
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Providers\ExportActions\BuildRecipeAction.cs" />
|
||||
<Compile Include="Models\ExportActionConfigurationContext.cs" />
|
||||
<Compile Include="Models\ImportActionConfigurationContext.cs" />
|
||||
<Compile Include="ViewModels\RecipeExecutionStepViewModel.cs" />
|
||||
<Compile Include="Services\ISetupService.cs" />
|
||||
<Compile Include="Services\SetupContext.cs" />
|
||||
@@ -93,8 +95,8 @@
|
||||
<Compile Include="Recipes\Builders\CustomStepsStep.cs" />
|
||||
<Compile Include="Services\ImportAction.cs" />
|
||||
<Compile Include="Services\ExportAction.cs" />
|
||||
<Compile Include="Services\ImportActionContext.cs" />
|
||||
<Compile Include="Services\ExportActionContext.cs" />
|
||||
<Compile Include="Models\ImportActionContext.cs" />
|
||||
<Compile Include="Models\ExportActionContext.cs" />
|
||||
<Compile Include="Services\ExportContext.cs" />
|
||||
<Compile Include="Services\IImportAction.cs" />
|
||||
<Compile Include="Services\IExportAction.cs" />
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ImportExport.Models;
|
||||
using Orchard.ImportExport.Services;
|
||||
using Orchard.ImportExport.ViewModels;
|
||||
using Orchard.Mvc;
|
||||
@@ -64,6 +65,21 @@ namespace Orchard.ImportExport.Providers.ExportActions {
|
||||
return shapeFactory.EditorTemplate(TemplateName: "ExportActions/BuildRecipe", Model: viewModel, Prefix: Prefix);
|
||||
}
|
||||
|
||||
public override void Configure(ExportActionConfigurationContext context) {
|
||||
var recipeBuilderStepsElement = context.ConfigurationElement.Element("RecipeBuilderSteps");
|
||||
if (recipeBuilderStepsElement == null)
|
||||
return;
|
||||
|
||||
foreach (var step in _recipeBuilderSteps) {
|
||||
var stepConfigurationElement = recipeBuilderStepsElement.Element(step.Name);
|
||||
|
||||
if (stepConfigurationElement != null) {
|
||||
var stepContext = new RecipeBuilderStepConfigurationContext(stepConfigurationElement);
|
||||
step.Configure(stepContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Execute(ExportActionContext context) {
|
||||
var recipeDocument = _importExportService.Export(RecipeBuilderSteps);
|
||||
var recipe = _recipeParser.ParseRecipe(recipeDocument);
|
||||
|
||||
@@ -8,9 +8,11 @@ using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Features;
|
||||
using Orchard.ImportExport.Models;
|
||||
using Orchard.ImportExport.Services;
|
||||
using Orchard.ImportExport.ViewModels;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Recipes.Models;
|
||||
using Orchard.Recipes.Services;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
@@ -129,6 +131,24 @@ namespace Orchard.ImportExport.Providers.ImportActions {
|
||||
return shapeFactory.EditorTemplate(TemplateName: "ImportActions/UploadRecipe", Model: viewModel, Prefix: Prefix);
|
||||
}
|
||||
|
||||
public override void Configure(ImportActionConfigurationContext context) {
|
||||
ResetSite = context.ConfigurationElement.Attr<bool>("ResetSite");
|
||||
SuperUserPassword = context.ConfigurationElement.Attr("SuperUserPassword");
|
||||
|
||||
var executionStepsElement = context.ConfigurationElement.Element("RecipeExecutionSteps");
|
||||
if (executionStepsElement == null)
|
||||
return;
|
||||
|
||||
foreach (var step in _recipeExecutionSteps) {
|
||||
var stepConfigurationElement = executionStepsElement.Element(step.Name);
|
||||
|
||||
if (stepConfigurationElement != null) {
|
||||
var stepContext = new RecipeExecutionStepConfigurationContext(stepConfigurationElement);
|
||||
step.Configure(stepContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Execute(ImportActionContext context) {
|
||||
if (RecipeDocument == null)
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ImportExport.Models;
|
||||
|
||||
namespace Orchard.ImportExport.Services {
|
||||
public abstract class ExportAction : Component, IExportAction {
|
||||
@@ -17,6 +19,9 @@ namespace Orchard.ImportExport.Services {
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void Configure(ExportActionConfigurationContext context) {
|
||||
}
|
||||
|
||||
public abstract void Execute(ExportActionContext context);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ImportExport.Models;
|
||||
|
||||
namespace Orchard.ImportExport.Services {
|
||||
public interface IExportAction : IDependency {
|
||||
@@ -7,6 +9,7 @@ namespace Orchard.ImportExport.Services {
|
||||
|
||||
dynamic BuildEditor(dynamic shapeFactory);
|
||||
dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater);
|
||||
void Configure(ExportActionConfigurationContext context);
|
||||
void Execute(ExportActionContext context);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ImportExport.Models;
|
||||
|
||||
namespace Orchard.ImportExport.Services {
|
||||
public interface IImportAction : IDependency {
|
||||
@@ -7,6 +8,7 @@ namespace Orchard.ImportExport.Services {
|
||||
|
||||
dynamic BuildEditor(dynamic shapeFactory);
|
||||
dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater);
|
||||
void Configure(ImportActionConfigurationContext context);
|
||||
void Execute(ImportActionContext context);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ImportExport.Models;
|
||||
|
||||
namespace Orchard.ImportExport.Services {
|
||||
public abstract class ImportAction : Component, IImportAction {
|
||||
@@ -17,6 +18,9 @@ namespace Orchard.ImportExport.Services {
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void Configure(ImportActionConfigurationContext context) {
|
||||
}
|
||||
|
||||
public abstract void Execute(ImportActionContext context);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using Orchard.ContentManagement;
|
||||
using Orchard.Environment.Features;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Modules.ViewModels;
|
||||
using Orchard.Recipes.Models;
|
||||
using Orchard.Recipes.Services;
|
||||
|
||||
namespace Orchard.Modules.Recipes.Builders {
|
||||
@@ -48,6 +49,11 @@ namespace Orchard.Modules.Recipes.Builders {
|
||||
return shapeFactory.EditorTemplate(TemplateName: "BuilderSteps/Feature", Model: viewModel, Prefix: Prefix);
|
||||
}
|
||||
|
||||
public override void Configure(RecipeBuilderStepConfigurationContext context) {
|
||||
ExportEnabledFeatures = context.ConfigurationElement.Attr<bool>("ExportEnabledFeatures");
|
||||
ExportDisabledFeatures = context.ConfigurationElement.Attr<bool>("ExportDisabledFeatures");
|
||||
}
|
||||
|
||||
public override void Build(BuildContext context) {
|
||||
if (!ExportEnabledFeatures && !ExportDisabledFeatures)
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
@@ -23,6 +24,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
||||
_contentDefinitionManager = contentDefinitionManager;
|
||||
_orchardServices = orchardServices;
|
||||
_contentDefinitionWriter = contentDefinitionWriter;
|
||||
VersionHistoryOptions = VersionHistoryOptions.Published;
|
||||
}
|
||||
|
||||
public override string Name {
|
||||
@@ -67,6 +69,21 @@ namespace Orchard.Recipes.Providers.Builders {
|
||||
return shapeFactory.EditorTemplate(TemplateName: "BuilderSteps/Content", Model: viewModel, Prefix: Prefix);
|
||||
}
|
||||
|
||||
public override void Configure(RecipeBuilderStepConfigurationContext context) {
|
||||
var schemaContentTypeNames = context.ConfigurationElement.Attr("SchemaContentTypes");
|
||||
var dataContentTypeNames = context.ConfigurationElement.Attr("DataContentTypes");
|
||||
var versionHistoryOptions = context.ConfigurationElement.Attr<VersionHistoryOptions?>("VersionHistoryOptions");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(schemaContentTypeNames))
|
||||
SchemaContentTypes = schemaContentTypeNames.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(dataContentTypeNames))
|
||||
DataContentTypes = dataContentTypeNames.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
|
||||
if(versionHistoryOptions != null)
|
||||
VersionHistoryOptions = versionHistoryOptions.Value;
|
||||
}
|
||||
|
||||
public override void Build(BuildContext context) {
|
||||
var dataContentTypes = DataContentTypes;
|
||||
var schemaContentTypes = SchemaContentTypes;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Recipes.Models;
|
||||
using Orchard.Recipes.Services;
|
||||
using Orchard.Recipes.ViewModels;
|
||||
|
||||
@@ -55,6 +56,16 @@ namespace Orchard.Recipes.Providers.Builders {
|
||||
return shapeFactory.EditorTemplate(TemplateName: "BuilderSteps/RecipeMetadata", Model: viewModel, Prefix: Prefix);
|
||||
}
|
||||
|
||||
public override void Configure(RecipeBuilderStepConfigurationContext context) {
|
||||
RecipeName = context.ConfigurationElement.Attr("RecipeName");
|
||||
RecipeDescription = context.ConfigurationElement.Attr("RecipeDescription");
|
||||
RecipeAuthor = context.ConfigurationElement.Attr("RecipeAuthor");
|
||||
RecipeWebsite = context.ConfigurationElement.Attr("RecipeWebsite");
|
||||
RecipeTags = context.ConfigurationElement.Attr("RecipeTags");
|
||||
RecipeVersion = context.ConfigurationElement.Attr("RecipeVersion");
|
||||
IsSetupRecipe = context.ConfigurationElement.Attr<bool>("IsSetupRecipe");
|
||||
}
|
||||
|
||||
public override void Build(BuildContext context) {
|
||||
var recipeElement = context.RecipeDocument.Element("Orchard").Element("Recipe");
|
||||
|
||||
|
||||
@@ -53,6 +53,10 @@ namespace Orchard.Recipes.Providers.Executors {
|
||||
return shapeFactory.EditorTemplate(TemplateName: "ExecutionSteps/Content", Model: viewModel, Prefix: Prefix);
|
||||
}
|
||||
|
||||
public override void Configure(RecipeExecutionStepConfigurationContext context) {
|
||||
BatchSize = context.ConfigurationElement.Attr<int?>("BatchSize");
|
||||
}
|
||||
|
||||
public override void UpdateStep(UpdateRecipeExecutionStepContext context) {
|
||||
SetBatchSizeForDataStep(context.Step, BatchSize);
|
||||
}
|
||||
|
||||
@@ -151,6 +151,9 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Environment\Extensions\Helpers\ExtensionManagerExtensions.cs" />
|
||||
<Compile Include="Mvc\Updater.cs" />
|
||||
<Compile Include="Recipes\Models\ConfigurationContext.cs" />
|
||||
<Compile Include="Recipes\Models\RecipeBuilderStepConfigurationContext.cs" />
|
||||
<Compile Include="Recipes\Models\RecipeExecutionStepConfigurationContext.cs" />
|
||||
<Compile Include="Recipes\Models\RecipeResult.cs" />
|
||||
<Compile Include="Recipes\Models\RecipeStepResult.cs" />
|
||||
<Compile Include="Recipes\Models\BuildContext.cs" />
|
||||
|
||||
11
src/Orchard/Recipes/Models/ConfigurationContext.cs
Normal file
11
src/Orchard/Recipes/Models/ConfigurationContext.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Orchard.Recipes.Models {
|
||||
public class ConfigurationContext {
|
||||
protected ConfigurationContext(XElement configurationElement) {
|
||||
ConfigurationElement = configurationElement;
|
||||
}
|
||||
|
||||
public XElement ConfigurationElement { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Orchard.Recipes.Models {
|
||||
public class RecipeBuilderStepConfigurationContext : ConfigurationContext {
|
||||
public RecipeBuilderStepConfigurationContext(XElement configurationElement) : base(configurationElement) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Orchard.Recipes.Models {
|
||||
public class RecipeExecutionStepConfigurationContext : ConfigurationContext {
|
||||
public RecipeExecutionStepConfigurationContext(XElement configurationElement) : base(configurationElement) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.Recipes.Services {
|
||||
public interface IRecipeBuilderStep : IDependency {
|
||||
@@ -19,6 +21,7 @@ namespace Orchard.Recipes.Services {
|
||||
|
||||
dynamic BuildEditor(dynamic shapeFactory);
|
||||
dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater);
|
||||
void Configure(RecipeBuilderStepConfigurationContext configurationElement);
|
||||
void Build(BuildContext context);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ namespace Orchard.Recipes.Services {
|
||||
LocalizedString Description { get; }
|
||||
dynamic BuildEditor(dynamic shapeFactory);
|
||||
dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater);
|
||||
void Configure(RecipeExecutionStepConfigurationContext context);
|
||||
void UpdateStep(UpdateRecipeExecutionStepContext context);
|
||||
void Execute(RecipeExecutionContext context);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.Recipes.Services {
|
||||
public abstract class RecipeBuilderStep : Component, IRecipeBuilderStep {
|
||||
@@ -21,6 +22,9 @@ namespace Orchard.Recipes.Services {
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void Configure(RecipeBuilderStepConfigurationContext context) {
|
||||
}
|
||||
|
||||
public virtual void Build(BuildContext context) {}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,9 @@ namespace Orchard.Recipes.Services {
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual void Configure(RecipeExecutionStepConfigurationContext context) {
|
||||
}
|
||||
|
||||
public virtual void UpdateStep(UpdateRecipeExecutionStepContext context) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user