mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Incremental work on reset site action.
This commit is contained in:
@@ -6,6 +6,14 @@ Website: http://orchardproject.net
|
||||
Version: 1.9.1
|
||||
OrchardVersion: 1.9
|
||||
Description: Provides content item data import and export capability.
|
||||
FeatureDescription: Imports and exports content item data
|
||||
Features:
|
||||
Orchard.ImportExport:
|
||||
Name: Import Export
|
||||
Description: Imports and exports content item data.
|
||||
Category: Content
|
||||
Dependencies: Orchard.jQuery, Orchard.Recipes
|
||||
Orchard.ImportExport.ResetSite
|
||||
Name: Reset Site Action
|
||||
Description: Adds a Reset Site action to the Import screen.
|
||||
Category: Hosting
|
||||
Dependencies: Orchard.ImportExport, Orchard.MultiTenancy
|
||||
@@ -111,6 +111,10 @@
|
||||
<Name>Orchard.Core</Name>
|
||||
<Private>false</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.MultiTenancy\Orchard.MultiTenancy.csproj">
|
||||
<Project>{72457126-e118-4171-a08f-9a709ee4b7fc}</Project>
|
||||
<Name>Orchard.MultiTenancy</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard.Recipes\Orchard.Recipes.csproj">
|
||||
<Project>{fc1d74e8-7a4d-48f4-83de-95c6173780c4}</Project>
|
||||
<Name>Orchard.Recipes</Name>
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
using Orchard.ContentManagement;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.ImportExport.Services;
|
||||
using Orchard.ImportExport.ViewModels;
|
||||
using Orchard.MultiTenancy.Services;
|
||||
|
||||
namespace Orchard.ImportExport.Providers.ImportActions {
|
||||
[OrchardFeature("Orchard.ImportExport.ResetSite")]
|
||||
public class ResetSiteAction : ImportAction {
|
||||
private readonly ITenantService _tenantService;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
|
||||
public ResetSiteAction(ITenantService tenantService, ShellSettings shellSettings) {
|
||||
_tenantService = tenantService;
|
||||
_shellSettings = shellSettings;
|
||||
}
|
||||
|
||||
public override string Name { get { return "ResetSite"; } }
|
||||
|
||||
@@ -16,18 +28,24 @@ namespace Orchard.ImportExport.Providers.ImportActions {
|
||||
}
|
||||
|
||||
public bool ResetSite { get; set; }
|
||||
public bool DropTables { get; set; }
|
||||
|
||||
public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater) {
|
||||
var viewModel = new ResetSiteViewModel();
|
||||
if (updater != null) {
|
||||
ResetSite = viewModel.ResetSite;
|
||||
DropTables = viewModel.DropTables;
|
||||
}
|
||||
|
||||
return shapeFactory.EditorTemplate(TemplateName: "ImportActions/ResetSite", Model: viewModel, Prefix: Prefix);
|
||||
}
|
||||
|
||||
public override void Execute(ImportActionContext context) {
|
||||
// Reset site.
|
||||
_shellSettings.State = TenantState.Disabled;
|
||||
_tenantService.ResetTenant(_shellSettings, DropTables);
|
||||
_shellSettings.DataProvider = null;
|
||||
_tenantService.UpdateTenant(_shellSettings);
|
||||
context.ActionResult = new RedirectResult("~/");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ImportExport.Services;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.ImportExport.Providers.ImportActions {
|
||||
public class UploadRecipeAction : ImportAction {
|
||||
@@ -29,19 +27,16 @@ namespace Orchard.ImportExport.Providers.ImportActions {
|
||||
|
||||
if (updater != null) {
|
||||
var request = _orchardServices.WorkContext.HttpContext.Request;
|
||||
var file = request.Files["RecipeFile"];
|
||||
if (String.IsNullOrEmpty(file.FileName)) {
|
||||
updater.AddModelError("RecipeFile", T("Please choose a recipe file to import."));
|
||||
_orchardServices.Notifier.Error(T("Please choose a recipe file to import."));
|
||||
}
|
||||
else
|
||||
File = file;
|
||||
File = request.Files["RecipeFile"];
|
||||
}
|
||||
|
||||
return shapeFactory.EditorTemplate(TemplateName: "ImportActions/UploadRecipe", Prefix: Prefix);
|
||||
}
|
||||
|
||||
public override void Execute(ImportActionContext context) {
|
||||
if (File == null || File.ContentLength == 0)
|
||||
return;
|
||||
|
||||
var executionId = _importExportService.Import(new StreamReader(File.InputStream).ReadToEnd());
|
||||
context.ActionResult = new RedirectToRouteResult(new RouteValueDictionary(new { action = "ImportResult", controller = "Admin", area = "Orchard.ImportExport", executionId = executionId }));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
namespace Orchard.ImportExport.ViewModels {
|
||||
public class ResetSiteViewModel {
|
||||
public bool ResetSite { get; set; }
|
||||
public bool DropTables { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,16 @@
|
||||
@model Orchard.ImportExport.ViewModels.ResetSiteViewModel
|
||||
@{
|
||||
Script.Require("ShapesBase");
|
||||
}
|
||||
<fieldset>
|
||||
<div>
|
||||
@Html.CheckBoxFor(m => m.ResetSite)
|
||||
@Html.LabelFor(m => m.ResetSite, T("Reset Site").ToString(), new {@class = "forcheckbox"})
|
||||
@Html.Hint(T("Check this option to completely clean your site before importing the uploaded recipe."))
|
||||
@Html.Hint(T("Check this option to resets your site to its uninitialized state."))
|
||||
</div>
|
||||
<div data-controllerid="@Html.FieldIdFor(m => m.ResetSite)">
|
||||
@Html.CheckBoxFor(m => m.DropTables)
|
||||
@Html.LabelFor(m => m.DropTables, T("Drop Tables").ToString(), new { @class = "forcheckbox" })
|
||||
@Html.Hint(T("Check this option to also drop all of the database tables of the current tenant."))
|
||||
</div>
|
||||
</fieldset>
|
||||
Reference in New Issue
Block a user