mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-19 18:27:55 +08:00
Hooking up an import export service.
--HG-- branch : dev
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ImportExport.Services;
|
||||
using Orchard.ImportExport.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.ImportExport.Controllers {
|
||||
public class AdminController : Controller {
|
||||
public AdminController(IOrchardServices services) {
|
||||
private readonly IImportExportService _importExportService;
|
||||
|
||||
public AdminController(IOrchardServices services, IImportExportService importExportService) {
|
||||
_importExportService = importExportService;
|
||||
Services = services;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -29,12 +34,13 @@ namespace Orchard.ImportExport.Controllers {
|
||||
if (String.IsNullOrEmpty(Request.Files["RecipeFile"].FileName)) {
|
||||
throw new ArgumentException(T("Please choose a recipe file to import.").Text);
|
||||
}
|
||||
_importExportService.Import(new StreamReader(Request.Files["RecipeFile"].InputStream).ReadToEnd());
|
||||
|
||||
Services.Notifier.Information(T("Your recipe has been imported."));
|
||||
return RedirectToAction("Import");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error(T("Import failed {0}", exception.Message));
|
||||
Services.Notifier.Error(T("Import failed: {0}", exception.Message));
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
@@ -48,6 +48,8 @@
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\IImportExportService.cs" />
|
||||
<Compile Include="Services\ImportExportService.cs" />
|
||||
<Compile Include="ViewModels\ExportViewModel.cs" />
|
||||
<Compile Include="ViewModels\ImportViewModel.cs" />
|
||||
</ItemGroup>
|
||||
|
@@ -0,0 +1,7 @@
|
||||
namespace Orchard.ImportExport.Services {
|
||||
public interface IImportExportService : IDependency {
|
||||
void Import(string recipe);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,20 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Recipes.Services;
|
||||
|
||||
namespace Orchard.ImportExport.Services {
|
||||
[UsedImplicitly]
|
||||
public class ImportExportService : IImportExportService {
|
||||
public ImportExportService(IRecipeParser recipeParser, IRecipeManager recipeManager) {
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public void Import(string recipe) {
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user