diff --git a/src/Orchard.Web/Modules/Orchard.ImportExport/Commands/ImportExportCommands.cs b/src/Orchard.Web/Modules/Orchard.ImportExport/Commands/ImportExportCommands.cs new file mode 100644 index 000000000..f4d21e5ca --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.ImportExport/Commands/ImportExportCommands.cs @@ -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: \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...")); + } + + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.ImportExport/Orchard.ImportExport.csproj b/src/Orchard.Web/Modules/Orchard.ImportExport/Orchard.ImportExport.csproj index ecec320c1..0d8435f92 100644 --- a/src/Orchard.Web/Modules/Orchard.ImportExport/Orchard.ImportExport.csproj +++ b/src/Orchard.Web/Modules/Orchard.ImportExport/Orchard.ImportExport.csproj @@ -48,6 +48,7 @@ +