mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Improved recipe logging to give a trail of executed tasks
This commit is contained in:
@@ -13,9 +13,11 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
public class CommandRecipeHandler : IRecipeHandler {
|
||||
private readonly ICommandManager _commandManager;
|
||||
private readonly CommandParser _commandParser;
|
||||
private readonly IRecipeJournal _recipeJournal;
|
||||
|
||||
public CommandRecipeHandler (ICommandManager commandManager) {
|
||||
public CommandRecipeHandler(ICommandManager commandManager, IRecipeJournal recipeJournal) {
|
||||
_commandManager = commandManager;
|
||||
_recipeJournal = recipeJournal;
|
||||
_commandParser = new CommandParser();
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
@@ -44,6 +46,9 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
|
||||
foreach (var command in commands) {
|
||||
if (!String.IsNullOrEmpty(command)) {
|
||||
if (!String.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
||||
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, string.Format("Commands: Executing item {0}.", command));
|
||||
}
|
||||
var commandParameters = _commandParser.ParseCommandParameters(command);
|
||||
var input = new StringReader("");
|
||||
var output = new StringWriter();
|
||||
|
@@ -12,10 +12,12 @@ 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) {
|
||||
public DataRecipeHandler(IOrchardServices orchardServices, ITransactionManager transactionManager, IRecipeJournal recipeJournal) {
|
||||
_orchardServices = orchardServices;
|
||||
_transactionManager = transactionManager;
|
||||
_recipeJournal = recipeJournal;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -53,6 +55,10 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
//so that dependencies can be managed within the same transaction
|
||||
var nextIdentity = importContentSession.GetNextInBatch();
|
||||
while (nextIdentity != null) {
|
||||
if (!string.IsNullOrEmpty(recipeContext.ExecutionId) && elementDictionary[nextIdentity.ToString()].HasAttributes) {
|
||||
var itemId = elementDictionary[nextIdentity.ToString()].FirstAttribute.Value;
|
||||
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, string.Format("Data: Importing {0}.", itemId));
|
||||
}
|
||||
_orchardServices.ContentManager.Import(
|
||||
elementDictionary[nextIdentity.ToString()],
|
||||
importContentSession);
|
||||
|
@@ -17,14 +17,17 @@ 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) {
|
||||
IExtensionManager extensionManager,
|
||||
IRecipeJournal recipeJournal) {
|
||||
_packagingSourceManager = packagingSourceManager;
|
||||
_packageManager = packageManager;
|
||||
_extensionManager = extensionManager;
|
||||
_recipeJournal = recipeJournal;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
@@ -87,6 +90,9 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
|
||||
if (packagingEntry != null) {
|
||||
if (!ModuleAlreadyInstalled(packagingEntry.PackageId)) {
|
||||
if (!string.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
||||
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, string.Format("Installing module: {0}.", packagingEntry.Title));
|
||||
}
|
||||
_packageManager.Install(packagingEntry.PackageId, packagingEntry.Version, packagingSource.FeedUrl, HostingEnvironment.MapPath("~/"));
|
||||
}
|
||||
installed = true;
|
||||
|
@@ -16,11 +16,13 @@ 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) {
|
||||
public SettingsRecipeHandler(ISiteService siteService, IContentManager contentManager, Lazy<IEnumerable<IContentHandler>> handlers, IRecipeJournal recipeJournal) {
|
||||
_siteService = siteService;
|
||||
_contentManager = contentManager;
|
||||
_handlers = handlers;
|
||||
_recipeJournal = recipeJournal;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -56,6 +58,10 @@ namespace Orchard.Recipes.RecipeHandlers {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
||||
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, string.Format("Setting: {0}.", contentPart.PartDefinition.Name));
|
||||
}
|
||||
|
||||
ImportSettingPart(contentPart, partElement);
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ namespace Orchard.Recipes.Services {
|
||||
return false;
|
||||
}
|
||||
_recipeJournal.WriteJournalEntry(executionId, string.Format("Executing step {0}.", nextRecipeStep.Name));
|
||||
var recipeContext = new RecipeContext { RecipeStep = nextRecipeStep, Executed = false };
|
||||
var recipeContext = new RecipeContext { RecipeStep = nextRecipeStep, Executed = false, ExecutionId = executionId };
|
||||
try {
|
||||
_recipeExecuteEventHandler.RecipeStepExecuting(executionId, recipeContext);
|
||||
foreach (var recipeHandler in _recipeHandlers) {
|
||||
|
@@ -14,13 +14,16 @@ 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) {
|
||||
IRepository<PermissionRecord> permissionRepository,
|
||||
IRecipeJournal recipeJournal) {
|
||||
_roleService = roleService;
|
||||
_roleRecordRepository = roleRecordRepository;
|
||||
_permissionRepository = permissionRepository;
|
||||
_recipeJournal = recipeJournal;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -38,6 +41,10 @@ namespace Orchard.Roles.ImportExport {
|
||||
foreach (var roleElement in recipeContext.RecipeStep.Step.Elements()) {
|
||||
var roleName = roleElement.Attribute("Name").Value;
|
||||
|
||||
if (string.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
||||
_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, string.Format("Roles: Executing item {0}.", roleName));
|
||||
}
|
||||
|
||||
var role = _roleService.GetRoleByName(roleName);
|
||||
if (role == null) {
|
||||
_roleService.CreateRole(roleName);
|
||||
|
@@ -2,5 +2,6 @@
|
||||
public class RecipeContext {
|
||||
public RecipeStep RecipeStep { get; set; }
|
||||
public bool Executed { get; set; }
|
||||
public string ExecutionId { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user