mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-20 02:37:55 +08:00
Removed recipe journals.
This commit is contained in:
@@ -56,7 +56,6 @@ namespace Orchard.Tests.Modules.ImportExport.Services {
|
||||
builder.RegisterType<RecipeHarvester>().As<IRecipeHarvester>();
|
||||
builder.RegisterType<RecipeStepExecutor>().As<IRecipeStepExecutor>();
|
||||
builder.RegisterType<StubStepQueue>().As<IRecipeStepQueue>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<StubRecipeJournal>().As<IRecipeJournal>();
|
||||
builder.RegisterType<StubRecipeScheduler>().As<IRecipeScheduler>();
|
||||
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
|
||||
builder.RegisterType<StubAppDataFolder>().As<IAppDataFolder>();
|
||||
|
@@ -17,7 +17,6 @@ namespace Orchard.Tests.Modules.Media.Services {
|
||||
private const string FolderName1 = "Folder1";
|
||||
private const string FolderName2 = "Folder2";
|
||||
private const string FolderName3 = "Folder3";
|
||||
private const string FolderRecipeJournal = "RecipeJournal";
|
||||
|
||||
private const string InnerDirectory = "MyDir";
|
||||
|
||||
@@ -54,11 +53,9 @@ namespace Orchard.Tests.Modules.Media.Services {
|
||||
[Test]
|
||||
public void GetMediaFoldersTest() {
|
||||
StorageProvider.ListFoldersPredicate = path => {
|
||||
return string.IsNullOrEmpty(path)
|
||||
? new[] {new StubStorageFolder(FolderName1)}
|
||||
: string.Equals(path, FolderName1)
|
||||
? new[] {new StubStorageFolder(FolderName2), new StubStorageFolder(FolderName3)}
|
||||
: string.Equals(path, FolderRecipeJournal) ? new[] { new StubStorageFolder(FolderRecipeJournal), new StubStorageFolder(FolderName1) } : new StubStorageFolder[] { };
|
||||
return string.IsNullOrEmpty(path) ? new[] {new StubStorageFolder(FolderName1)}
|
||||
: string.Equals(path, FolderName1) ? new[] {new StubStorageFolder(FolderName2), new StubStorageFolder(FolderName3)}
|
||||
: new StubStorageFolder[] { };
|
||||
};
|
||||
|
||||
IEnumerable<MediaFolder> mediaFolders = MediaService.GetMediaFolders(null);
|
||||
@@ -72,10 +69,6 @@ namespace Orchard.Tests.Modules.Media.Services {
|
||||
Assert.That(mediaFolders.Count(), Is.EqualTo(2), "Folder1 has 2 sub directories");
|
||||
Assert.That(mediaFolders.FirstOrDefault(mediaFolder => mediaFolder.Name.Equals(FolderName2)), Is.Not.Null, "Correct sub directory in root path");
|
||||
Assert.That(mediaFolders.FirstOrDefault(mediaFolder => mediaFolder.Name.Equals(FolderName3)), Is.Not.Null, "Correct sub directory in root path");
|
||||
|
||||
mediaFolders = MediaService.GetMediaFolders(FolderRecipeJournal);
|
||||
Assert.That(mediaFolders.Count(), Is.EqualTo(1), "Folder that contains RecipeJournal hides the RecipeJournal directory.");
|
||||
Assert.That(mediaFolders.FirstOrDefault(mediaFolder => mediaFolder.Name.Equals(FolderName1)), Is.Not.Null, "Correct sub directory in root path");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@@ -67,7 +67,6 @@ namespace Orchard.Tests.Modules.Recipes.RecipeHandlers {
|
||||
builder.RegisterType<ShellStateManager>().As<IShellStateManager>().SingleInstance();
|
||||
builder.RegisterType<StubEventBus>().As<IEventBus>().SingleInstance();
|
||||
builder.RegisterType<ModuleRecipeHandler>();
|
||||
builder.RegisterType<StubRecipeJournal>().As<IRecipeJournal>();
|
||||
builder.RegisterSource(new EventsRegistrationSource());
|
||||
}
|
||||
|
||||
|
@@ -70,7 +70,6 @@ namespace Orchard.Tests.Modules.Recipes.Services {
|
||||
builder.RegisterType<RecipeHarvester>().As<IRecipeHarvester>();
|
||||
builder.RegisterType<RecipeStepExecutor>().As<IRecipeStepExecutor>();
|
||||
builder.RegisterType<StubStepQueue>().As<IRecipeStepQueue>().InstancePerLifetimeScope();
|
||||
builder.RegisterType<StubRecipeJournal>().As<IRecipeJournal>();
|
||||
builder.RegisterType<StubRecipeScheduler>().As<IRecipeScheduler>();
|
||||
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
|
||||
builder.RegisterType<StubAppDataFolder>().As<IAppDataFolder>();
|
||||
@@ -152,28 +151,6 @@ namespace Orchard.Tests.Modules.Recipes.Services {
|
||||
}
|
||||
}
|
||||
|
||||
public class StubRecipeJournal : IRecipeJournal {
|
||||
public void ExecutionStart(string executionId) {
|
||||
}
|
||||
|
||||
public void ExecutionComplete(string executionId) {
|
||||
}
|
||||
|
||||
public void ExecutionFailed(string executionId) {
|
||||
}
|
||||
|
||||
public void WriteJournalEntry(string executionId, string message) {
|
||||
}
|
||||
|
||||
public RecipeJournal GetRecipeJournal(string executionId) {
|
||||
return new RecipeJournal();
|
||||
}
|
||||
|
||||
public RecipeStatus GetRecipeStatus(string executionId) {
|
||||
return RecipeStatus.Complete;
|
||||
}
|
||||
}
|
||||
|
||||
public class StubStepQueue : IRecipeStepQueue {
|
||||
readonly Queue<RecipeStep> _queue = new Queue<RecipeStep>();
|
||||
|
||||
|
@@ -16,19 +16,15 @@ namespace Orchard.ImportExport.Controllers {
|
||||
private readonly IImportExportService _importExportService;
|
||||
private readonly IContentDefinitionManager _contentDefinitionManager;
|
||||
private readonly ICustomExportStep _customExportStep;
|
||||
private readonly IRecipeJournal _recipeJournal;
|
||||
|
||||
public AdminController(
|
||||
IOrchardServices services,
|
||||
IImportExportService importExportService,
|
||||
IContentDefinitionManager contentDefinitionManager,
|
||||
ICustomExportStep customExportStep,
|
||||
IRecipeJournal recipeJournal
|
||||
) {
|
||||
ICustomExportStep customExportStep) {
|
||||
_importExportService = importExportService;
|
||||
_contentDefinitionManager = contentDefinitionManager;
|
||||
_customExportStep = customExportStep;
|
||||
_recipeJournal = recipeJournal;
|
||||
Services = services;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -54,18 +50,11 @@ namespace Orchard.ImportExport.Controllers {
|
||||
|
||||
if (ModelState.IsValid) {
|
||||
var executionId = _importExportService.Import(new StreamReader(Request.Files["RecipeFile"].InputStream).ReadToEnd());
|
||||
Services.Notifier.Information(T("Your recipe has been imported."));
|
||||
|
||||
return RedirectToAction("ImportResult", new { ExecutionId = executionId });
|
||||
// TODO: Figure out how to report the result. Probably add notifications from the actual import and then redirect to another action, which will display those notifications.
|
||||
}
|
||||
return View(new ImportViewModel());
|
||||
}
|
||||
|
||||
public ActionResult ImportResult(string executionId) {
|
||||
var journal = _recipeJournal.GetRecipeJournal(executionId);
|
||||
return View(journal);
|
||||
}
|
||||
|
||||
public ActionResult Export() {
|
||||
var customSteps = new List<string>();
|
||||
_customExportStep.Register(customSteps);
|
||||
|
@@ -25,6 +25,7 @@
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<TargetFrameworkProfile />
|
||||
<UseGlobalApplicationHostFile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -111,9 +112,6 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="RecipeHandlers\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Admin\ImportResult.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
|
@@ -1,30 +0,0 @@
|
||||
@model Orchard.Recipes.Models.RecipeJournal
|
||||
@{
|
||||
Layout.Title = T("Import Result").ToString();
|
||||
}
|
||||
<fieldset>
|
||||
<label>@T("Status"):</label>
|
||||
<span>@Model.Status</span>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<table class="items" summary="@T("These are messages logged during the import process")">
|
||||
<colgroup>
|
||||
<col id="Col1" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">@T("Message")</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@foreach (var message in Model.Messages)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@message.Message
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
@Html.ActionLink(T("Close").ToString(), "Import", null, new { @class = "button" })
|
@@ -72,7 +72,7 @@ namespace Orchard.Media.Services {
|
||||
Size = folder.GetSize(),
|
||||
LastUpdated = folder.GetLastUpdated(),
|
||||
MediaPath = folder.GetPath()
|
||||
}).Where(f => !f.Name.Equals("RecipeJournal", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -222,7 +222,6 @@ namespace Orchard.MediaLibrary.Services {
|
||||
public IEnumerable<IMediaFolder> GetMediaFolders(string relativePath) {
|
||||
return _storageProvider
|
||||
.ListFolders(relativePath)
|
||||
.Where(f => !f.GetName().Equals("RecipeJournal", StringComparison.OrdinalIgnoreCase))
|
||||
.Where(f => !f.GetName().StartsWith("_"))
|
||||
.Select(BuildMediaFolder)
|
||||
.ToList();
|
||||
|
@@ -25,6 +25,7 @@
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<TargetFrameworkProfile />
|
||||
<UseGlobalApplicationHostFile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -82,7 +83,6 @@
|
||||
<Compile Include="RecipeHandlers\ThemeRecipeHandler.cs" />
|
||||
<Compile Include="Routes.cs" />
|
||||
<Compile Include="Services\RecipeHarvester.cs" />
|
||||
<Compile Include="Services\RecipeJournalManager.cs" />
|
||||
<Compile Include="Services\RecipeManager.cs" />
|
||||
<Compile Include="Services\RecipeParser.cs" />
|
||||
<Compile Include="Services\RecipeScheduler.cs" />
|
||||
|
@@ -13,11 +13,9 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
public class CommandRecipeHandler : IRecipeHandler {
|
||||
private readonly ICommandManager _commandManager;
|
||||
private readonly CommandParser _commandParser;
|
||||
private readonly IRecipeJournal _recipeJournal;
|
||||
|
||||
public CommandRecipeHandler(ICommandManager commandManager, IRecipeJournal recipeJournal) {
|
||||
public CommandRecipeHandler(ICommandManager commandManager) {
|
||||
_commandManager = commandManager;
|
||||
_recipeJournal = recipeJournal;
|
||||
_commandParser = new CommandParser();
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
@@ -47,7 +45,8 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
foreach (var command in commands) {
|
||||
if (!String.IsNullOrEmpty(command)) {
|
||||
if (!String.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
||||
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Commands: Executing item {0}.", command).Text);
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Commands: Executing item {0}.", command).Text);
|
||||
}
|
||||
var commandParameters = _commandParser.ParseCommandParameters(command);
|
||||
var input = new StringReader("");
|
||||
|
@@ -12,12 +12,10 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
public class DataRecipeHandler : IRecipeHandler {
|
||||
private readonly IOrchardServices _orchardServices;
|
||||
private readonly ITransactionManager _transactionManager;
|
||||
private readonly IRecipeJournal _recipeJournal;
|
||||
|
||||
public DataRecipeHandler(IOrchardServices orchardServices, ITransactionManager transactionManager, IRecipeJournal recipeJournal) {
|
||||
public DataRecipeHandler(IOrchardServices orchardServices, ITransactionManager transactionManager) {
|
||||
_orchardServices = orchardServices;
|
||||
_transactionManager = transactionManager;
|
||||
_recipeJournal = recipeJournal;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -57,7 +55,8 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
while (nextIdentity != null) {
|
||||
if (!string.IsNullOrEmpty(recipeContext.ExecutionId) && elementDictionary[nextIdentity.ToString()].HasAttributes) {
|
||||
var itemId = elementDictionary[nextIdentity.ToString()].FirstAttribute.Value;
|
||||
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Data: Importing {0}.", itemId).Text);
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Data: Importing {0}.", itemId).Text);
|
||||
}
|
||||
_orchardServices.ContentManager.Import(
|
||||
elementDictionary[nextIdentity.ToString()],
|
||||
|
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Hosting;
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Environment.Features;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Packaging.Models;
|
||||
@@ -17,17 +15,14 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
private readonly IPackagingSourceManager _packagingSourceManager;
|
||||
private readonly IPackageManager _packageManager;
|
||||
private readonly IExtensionManager _extensionManager;
|
||||
private readonly IRecipeJournal _recipeJournal;
|
||||
|
||||
public ModuleRecipeHandler(
|
||||
IPackagingSourceManager packagingSourceManager,
|
||||
IPackageManager packageManager,
|
||||
IExtensionManager extensionManager,
|
||||
IRecipeJournal recipeJournal) {
|
||||
IExtensionManager extensionManager) {
|
||||
_packagingSourceManager = packagingSourceManager;
|
||||
_packageManager = packageManager;
|
||||
_extensionManager = extensionManager;
|
||||
_recipeJournal = recipeJournal;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
@@ -91,7 +86,8 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
if (packagingEntry != null) {
|
||||
if (!ModuleAlreadyInstalled(packagingEntry.PackageId)) {
|
||||
if (!string.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
||||
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Installing module: {0}.", packagingEntry.Title).Text);
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Installing module: {0}.", packagingEntry.Title).Text);
|
||||
}
|
||||
_packageManager.Install(packagingEntry.PackageId, packagingEntry.Version, packagingSource.FeedUrl, HostingEnvironment.MapPath("~/"));
|
||||
}
|
||||
|
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Policy;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
@@ -16,13 +14,11 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
private readonly ISiteService _siteService;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly Lazy<IEnumerable<IContentHandler>> _handlers;
|
||||
private readonly IRecipeJournal _recipeJournal;
|
||||
|
||||
public SettingsRecipeHandler(ISiteService siteService, IContentManager contentManager, Lazy<IEnumerable<IContentHandler>> handlers, IRecipeJournal recipeJournal) {
|
||||
public SettingsRecipeHandler(ISiteService siteService, IContentManager contentManager, Lazy<IEnumerable<IContentHandler>> handlers) {
|
||||
_siteService = siteService;
|
||||
_contentManager = contentManager;
|
||||
_handlers = handlers;
|
||||
_recipeJournal = recipeJournal;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -59,7 +55,8 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
||||
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Setting: {0}.", contentPart.PartDefinition.Name).Text);
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Setting: {0}.", contentPart.PartDefinition.Name).Text);
|
||||
}
|
||||
|
||||
ImportSettingPart(contentPart, partElement);
|
||||
|
@@ -1,146 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.FileSystems.Media;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.Recipes.Services {
|
||||
public class RecipeJournalManager : IRecipeJournal {
|
||||
private readonly IStorageProvider _storageProvider;
|
||||
private const string RecipeJournalFolder = "RecipeJournal";
|
||||
private const string WebConfig =
|
||||
@"
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy=""Script"">
|
||||
<clear/>
|
||||
<add name=""NotFound"" path=""*"" verb=""*"" type=""System.Web.HttpNotFoundHandler"" preCondition=""integratedMode"" requireAccess=""Script""/>
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>";
|
||||
|
||||
public RecipeJournalManager(IStorageProvider storageProvider) {
|
||||
_storageProvider = storageProvider;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public void ExecutionStart(string executionId) {
|
||||
var executionJournal = GetJournalFile(executionId);
|
||||
var xElement = XElement.Parse(ReadJournal(executionJournal));
|
||||
xElement.Element("Status").Value = "Started";
|
||||
WriteJournal(executionJournal, xElement);
|
||||
}
|
||||
|
||||
public void ExecutionComplete(string executionId) {
|
||||
var executionJournal = GetJournalFile(executionId);
|
||||
var xElement = XElement.Parse(ReadJournal(executionJournal));
|
||||
xElement.Element("Status").Value = "Complete";
|
||||
WriteJournal(executionJournal, xElement);
|
||||
}
|
||||
|
||||
public void ExecutionFailed(string executionId) {
|
||||
var executionJournal = GetJournalFile(executionId);
|
||||
var xElement = XElement.Parse(ReadJournal(executionJournal));
|
||||
xElement.Element("Status").Value = "Failed";
|
||||
WriteJournal(executionJournal, xElement);
|
||||
}
|
||||
|
||||
public void WriteJournalEntry(string executionId, string message) {
|
||||
var executionJournal = GetJournalFile(executionId);
|
||||
var xElement = XElement.Parse(ReadJournal(executionJournal));
|
||||
var journalEntry = new XElement("Message", message);
|
||||
xElement.Add(journalEntry);
|
||||
WriteJournal(executionJournal, xElement);
|
||||
}
|
||||
|
||||
public RecipeJournal GetRecipeJournal(string executionId) {
|
||||
var executionJournal = GetJournalFile(executionId);
|
||||
var xElement = XElement.Parse(ReadJournal(executionJournal));
|
||||
|
||||
var journal = new RecipeJournal { ExecutionId = executionId };
|
||||
var messages = new List<JournalMessage>();
|
||||
|
||||
journal.Status = ReadStatusFromJournal(xElement);
|
||||
foreach (var message in xElement.Elements("Message")) {
|
||||
messages.Add(new JournalMessage {Message = message.Value});
|
||||
}
|
||||
journal.Messages = messages;
|
||||
|
||||
return journal;
|
||||
}
|
||||
|
||||
public RecipeStatus GetRecipeStatus(string executionId) {
|
||||
var executionJournal = GetJournalFile(executionId);
|
||||
var xElement = XElement.Parse(ReadJournal(executionJournal));
|
||||
|
||||
return ReadStatusFromJournal(xElement);
|
||||
}
|
||||
|
||||
private IStorageFile GetJournalFile(string executionId) {
|
||||
IStorageFile journalFile;
|
||||
var journalPath = _storageProvider.Combine(RecipeJournalFolder, executionId);
|
||||
try {
|
||||
if (_storageProvider.TryCreateFolder(RecipeJournalFolder)) {
|
||||
var webConfigPath = _storageProvider.Combine(RecipeJournalFolder, "web.config");
|
||||
var webConfigFile = _storageProvider.CreateFile(webConfigPath);
|
||||
WriteWebConfig(webConfigFile);
|
||||
}
|
||||
journalFile = _storageProvider.GetFile(journalPath);
|
||||
}
|
||||
catch (ArgumentException) {
|
||||
journalFile = _storageProvider.CreateFile(journalPath);
|
||||
var recipeStepElement = new XElement("RecipeJournal");
|
||||
recipeStepElement.Add(new XElement("Status", "Unknown"));
|
||||
WriteJournal(journalFile, recipeStepElement);
|
||||
}
|
||||
|
||||
return journalFile;
|
||||
}
|
||||
|
||||
private static string ReadJournal(IStorageFile executionJournal) {
|
||||
using (var stream = executionJournal.OpenRead()) {
|
||||
using (var streamReader = new StreamReader(stream)) {
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteJournal(IStorageFile journalFile, XElement journal) {
|
||||
string content = journal.ToString();
|
||||
using (var stream = journalFile.CreateFile()) {
|
||||
using (var tw = new StreamWriter(stream)) {
|
||||
tw.Write(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteWebConfig(IStorageFile webConfigFile) {
|
||||
using (var stream = webConfigFile.OpenWrite()) {
|
||||
using (var tw = new StreamWriter(stream)) {
|
||||
tw.Write(WebConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static RecipeStatus ReadStatusFromJournal(XElement xElement) {
|
||||
switch (xElement.Element("Status").Value) {
|
||||
case "Started":
|
||||
return RecipeStatus.Started;
|
||||
case "Complete":
|
||||
return RecipeStatus.Complete;
|
||||
case "Failed":
|
||||
return RecipeStatus.Failed;
|
||||
default:
|
||||
return RecipeStatus.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,14 +8,14 @@ namespace Orchard.Recipes.Services {
|
||||
public class RecipeManager : IRecipeManager {
|
||||
private readonly IRecipeStepQueue _recipeStepQueue;
|
||||
private readonly IRecipeScheduler _recipeScheduler;
|
||||
private readonly IRecipeJournal _recipeJournal;
|
||||
private readonly IRecipeExecuteEventHandler _recipeExecuteEventHandler;
|
||||
|
||||
public RecipeManager(IRecipeStepQueue recipeStepQueue, IRecipeScheduler recipeScheduler, IRecipeJournal recipeJournal,
|
||||
public RecipeManager(
|
||||
IRecipeStepQueue recipeStepQueue,
|
||||
IRecipeScheduler recipeScheduler,
|
||||
IRecipeExecuteEventHandler recipeExecuteEventHandler) {
|
||||
_recipeStepQueue = recipeStepQueue;
|
||||
_recipeScheduler = recipeScheduler;
|
||||
_recipeJournal = recipeJournal;
|
||||
_recipeExecuteEventHandler = recipeExecuteEventHandler;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
@@ -30,7 +30,8 @@ namespace Orchard.Recipes.Services {
|
||||
return null;
|
||||
|
||||
var executionId = Guid.NewGuid().ToString("n");
|
||||
_recipeJournal.ExecutionStart(executionId);
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.ExecutionStart(executionId);
|
||||
_recipeExecuteEventHandler.ExecutionStart(executionId, recipe);
|
||||
|
||||
foreach (var recipeStep in recipe.RecipeSteps) {
|
||||
|
@@ -8,14 +8,14 @@ using Orchard.Recipes.Models;
|
||||
namespace Orchard.Recipes.Services {
|
||||
public class RecipeStepExecutor : IRecipeStepExecutor {
|
||||
private readonly IRecipeStepQueue _recipeStepQueue;
|
||||
private readonly IRecipeJournal _recipeJournal;
|
||||
private readonly IEnumerable<IRecipeHandler> _recipeHandlers;
|
||||
private readonly IRecipeExecuteEventHandler _recipeExecuteEventHandler;
|
||||
|
||||
public RecipeStepExecutor(IRecipeStepQueue recipeStepQueue, IRecipeJournal recipeJournal,
|
||||
IEnumerable<IRecipeHandler> recipeHandlers, IRecipeExecuteEventHandler recipeExecuteEventHandler) {
|
||||
public RecipeStepExecutor(
|
||||
IRecipeStepQueue recipeStepQueue,
|
||||
IEnumerable<IRecipeHandler> recipeHandlers,
|
||||
IRecipeExecuteEventHandler recipeExecuteEventHandler) {
|
||||
_recipeStepQueue = recipeStepQueue;
|
||||
_recipeJournal = recipeJournal;
|
||||
_recipeHandlers = recipeHandlers;
|
||||
_recipeExecuteEventHandler = recipeExecuteEventHandler;
|
||||
|
||||
@@ -29,11 +29,13 @@ namespace Orchard.Recipes.Services {
|
||||
public bool ExecuteNextStep(string executionId) {
|
||||
var nextRecipeStep= _recipeStepQueue.Dequeue(executionId);
|
||||
if (nextRecipeStep == null) {
|
||||
_recipeJournal.ExecutionComplete(executionId);
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.ExecutionComplete(executionId);
|
||||
_recipeExecuteEventHandler.ExecutionComplete(executionId);
|
||||
return false;
|
||||
}
|
||||
_recipeJournal.WriteJournalEntry(executionId, string.Format("Executing step {0}.", nextRecipeStep.Name));
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.WriteJournalEntry(executionId, string.Format("Executing step {0}.", nextRecipeStep.Name));
|
||||
var recipeContext = new RecipeContext { RecipeStep = nextRecipeStep, Executed = false, ExecutionId = executionId };
|
||||
try {
|
||||
_recipeExecuteEventHandler.RecipeStepExecuting(executionId, recipeContext);
|
||||
@@ -45,10 +47,12 @@ namespace Orchard.Recipes.Services {
|
||||
catch(Exception exception) {
|
||||
Logger.Error(exception, "Recipe execution {0} was cancelled because a step failed to execute", executionId);
|
||||
while (_recipeStepQueue.Dequeue(executionId) != null) ;
|
||||
_recipeJournal.ExecutionFailed(executionId);
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.ExecutionFailed(executionId);
|
||||
var message = T("Recipe execution with id {0} was cancelled because the \"{1}\" step failed to execute. The following exception was thrown: {2}. Refer to the error logs for more information.",
|
||||
executionId, nextRecipeStep.Name, exception.Message);
|
||||
_recipeJournal.WriteJournalEntry(executionId, message.ToString());
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.WriteJournalEntry(executionId, message.ToString());
|
||||
|
||||
throw new OrchardCoreException(message);
|
||||
}
|
||||
@@ -56,10 +60,12 @@ namespace Orchard.Recipes.Services {
|
||||
if (!recipeContext.Executed) {
|
||||
Logger.Error("Could not execute recipe step '{0}' because the recipe handler was not found.", recipeContext.RecipeStep.Name);
|
||||
while (_recipeStepQueue.Dequeue(executionId) != null) ;
|
||||
_recipeJournal.ExecutionFailed(executionId);
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.ExecutionFailed(executionId);
|
||||
var message = T("Recipe execution with id {0} was cancelled because the recipe handler for step \"{1}\" was not found. Refer to the error logs for more information.",
|
||||
executionId, nextRecipeStep.Name);
|
||||
_recipeJournal.WriteJournalEntry(executionId, message.ToString());
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.WriteJournalEntry(executionId, message.ToString());
|
||||
|
||||
throw new OrchardCoreException(message);
|
||||
}
|
||||
|
@@ -14,16 +14,13 @@ namespace Orchard.Roles.ImportExport {
|
||||
private readonly IRoleService _roleService;
|
||||
private readonly IRepository<RoleRecord> _roleRecordRepository;
|
||||
private readonly IRepository<PermissionRecord> _permissionRepository;
|
||||
private readonly IRecipeJournal _recipeJournal;
|
||||
|
||||
public RolesRecipeHandler(IRoleService roleService,
|
||||
IRepository<RoleRecord> roleRecordRepository,
|
||||
IRepository<PermissionRecord> permissionRepository,
|
||||
IRecipeJournal recipeJournal) {
|
||||
IRepository<PermissionRecord> permissionRepository) {
|
||||
_roleService = roleService;
|
||||
_roleRecordRepository = roleRecordRepository;
|
||||
_permissionRepository = permissionRepository;
|
||||
_recipeJournal = recipeJournal;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -42,7 +39,8 @@ namespace Orchard.Roles.ImportExport {
|
||||
var roleName = roleElement.Attribute("Name").Value;
|
||||
|
||||
if (string.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
||||
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Roles: Executing item {0}.", roleName).Text);
|
||||
// TODO: ************** LOGGING
|
||||
//_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Roles: Executing item {0}.", roleName).Text);
|
||||
}
|
||||
|
||||
var role = _roleService.GetRoleByName(roleName);
|
||||
|
@@ -347,11 +347,9 @@
|
||||
<Compile Include="Recipes\Events\IRecipeSchedulerEventHandler.cs" />
|
||||
<Compile Include="Recipes\Models\Recipe.cs" />
|
||||
<Compile Include="Recipes\Models\RecipeContext.cs" />
|
||||
<Compile Include="Recipes\Models\RecipeJournal.cs" />
|
||||
<Compile Include="Recipes\Models\RecipeStep.cs" />
|
||||
<Compile Include="Recipes\Services\IRecipeHandler.cs" />
|
||||
<Compile Include="Recipes\Services\IRecipeHarvester.cs" />
|
||||
<Compile Include="Recipes\Services\IRecipeJournal.cs" />
|
||||
<Compile Include="Recipes\Services\IRecipeManager.cs" />
|
||||
<Compile Include="Recipes\Services\IRecipeParser.cs" />
|
||||
<Compile Include="Recipes\Services\IRecipeScheduler.cs" />
|
||||
|
@@ -1,20 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Recipes.Models {
|
||||
public class RecipeJournal {
|
||||
public string ExecutionId { get; set; }
|
||||
public RecipeStatus Status { get; set; }
|
||||
public IEnumerable<JournalMessage> Messages { get; set; }
|
||||
}
|
||||
|
||||
public class JournalMessage {
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
public enum RecipeStatus {
|
||||
Unknown,
|
||||
Started,
|
||||
Complete,
|
||||
Failed
|
||||
}
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
using Orchard.Recipes.Models;
|
||||
|
||||
namespace Orchard.Recipes.Services {
|
||||
public interface IRecipeJournal : IDependency {
|
||||
void ExecutionStart(string executionId);
|
||||
void ExecutionComplete(string executionId);
|
||||
void ExecutionFailed(string executionId);
|
||||
void WriteJournalEntry(string executionId, string message);
|
||||
RecipeJournal GetRecipeJournal(string executionId);
|
||||
RecipeStatus GetRecipeStatus(string executionId);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user