mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-02 11:44:41 +08:00
Adding import command
--HG-- branch : 1.x
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Commands;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.ImportExport.Services;
|
||||
using Orchard.Security;
|
||||
using Orchard.Core.Navigation.Services;
|
||||
using Orchard.Settings;
|
||||
using Orchard.Core.Title.Models;
|
||||
|
||||
namespace Orchard.ImportExport.Commands {
|
||||
public class ImportExportCommands : DefaultOrchardCommandHandler {
|
||||
private readonly IImportExportService _importExportService;
|
||||
|
||||
public ImportExportCommands(IImportExportService importExportService) {
|
||||
_importExportService = importExportService;
|
||||
}
|
||||
|
||||
[OrchardSwitch]
|
||||
public string Filename { get; set; }
|
||||
|
||||
[CommandName("import file")]
|
||||
[CommandHelp("import file /Filename:<path> \r\n\t" + "Imports the content of a file.")]
|
||||
[OrchardSwitches("Filename")]
|
||||
public void ImportFile() {
|
||||
|
||||
if (String.IsNullOrEmpty(Filename)) {
|
||||
Context.Output.WriteLine(T("Invalid file path"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!File.Exists(Filename)) {
|
||||
Context.Output.WriteLine(T("File not found."));
|
||||
return;
|
||||
}
|
||||
|
||||
_importExportService.Import(File.ReadAllText(Filename));
|
||||
|
||||
Context.Output.WriteLine(T("Import running..."));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Commands\ImportExportCommands.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Models\ExportOptions.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
|
||||
Reference in New Issue
Block a user