From 9605d216e662691114b673aaa649d9ba413f357d Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Mon, 12 Oct 2015 12:54:59 +0200 Subject: [PATCH] Renamed a method and improved logging messages. - Renamed ImportedAll to ImportCompleted. - Added a "batch label" to the BatchedInvoke method to be able to better identify what's being executed from the log files. --- .../Providers/Executors/ContentStep.cs | 16 ++++++++-------- .../ContentManagement/Handlers/ContentHandler.cs | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Recipes/Providers/Executors/ContentStep.cs b/src/Orchard.Web/Modules/Orchard.Recipes/Providers/Executors/ContentStep.cs index f9b42d2f3..90fd57f66 100644 --- a/src/Orchard.Web/Modules/Orchard.Recipes/Providers/Executors/ContentStep.cs +++ b/src/Orchard.Web/Modules/Orchard.Recipes/Providers/Executors/ContentStep.cs @@ -76,12 +76,12 @@ namespace Orchard.Recipes.Providers.Executors { // Import Data. public override void Execute(RecipeExecutionContext context) { // Run the import. - BatchedInvoke(context, (itemId, nextIdentityValue, element, importContentSession, elementDictionary) => { + BatchedInvoke(context, "Import", (itemId, nextIdentityValue, element, importContentSession, elementDictionary) => { _orchardServices.ContentManager.Import(element, importContentSession); }); // Invoke ImportCompleted. - BatchedInvoke(context, (itemId, nextIdentityValue, element, importContentSession, elementDictionary) => { + BatchedInvoke(context, "ImportCompleted", (itemId, nextIdentityValue, element, importContentSession, elementDictionary) => { var contentItem = importContentSession.Get(itemId, VersionOptions.Latest); var importContentContext = new ImportContentContext(contentItem, elementDictionary[nextIdentityValue], importContentSession); foreach (var handler in _handlers.Value) { @@ -90,7 +90,7 @@ namespace Orchard.Recipes.Providers.Executors { }); } - private void BatchedInvoke(RecipeExecutionContext context, Action> contentItemAction) { + private void BatchedInvoke(RecipeExecutionContext context, string batchLabel, Action> contentItemAction) { var importContentSession = new ImportContentSession(_orchardServices.ContentManager); // Populate local dictionary with elements and their ids. @@ -103,14 +103,14 @@ namespace Orchard.Recipes.Providers.Executors { // Determine if the import is to be batched in multiple transactions. var batchSize = GetBatchSizeForDataStep(context.RecipeStep.Step); - Logger.Debug("Using batch size {0}.", batchSize); var startIndex = 0; var itemIndex = 0; - Logger.Debug("Using batch size {0}.", batchSize); - + + Logger.Debug("Using batch size {0} for '{1}'.", batchSize, batchLabel); + try { while (startIndex < elementDictionary.Count) { - Logger.Debug("Batch execution starting at index {0}.", startIndex); + Logger.Debug("Batch '{0}' execution starting at index {1}.", batchLabel, startIndex); importContentSession.InitializeBatch(startIndex, batchSize); // The session determines which items are included in the current batch @@ -141,7 +141,7 @@ namespace Orchard.Recipes.Providers.Executors { _transactionManager.RequireNew(); } - Logger.Debug("Finished batch starting at index {0}.", startIndex); + Logger.Debug("Finished batch '{0}' starting at index {1}.", batchLabel, startIndex); } } catch (Exception) { diff --git a/src/Orchard/ContentManagement/Handlers/ContentHandler.cs b/src/Orchard/ContentManagement/Handlers/ContentHandler.cs index 181c3dea7..970fff82c 100644 --- a/src/Orchard/ContentManagement/Handlers/ContentHandler.cs +++ b/src/Orchard/ContentManagement/Handlers/ContentHandler.cs @@ -104,7 +104,7 @@ namespace Orchard.ContentManagement.Handlers { Filters.Add(new InlineStorageFilter { OnImported = handler }); } - protected void OnImportedAll(Action handler) where TPart : class, IContent { + protected void OnImportCompleted(Action handler) where TPart : class, IContent { Filters.Add(new InlineStorageFilter { OnImportCompleted = handler }); } @@ -419,7 +419,7 @@ namespace Orchard.ContentManagement.Handlers { void IContentHandler.ImportCompleted(ImportContentContext importContentContext) { foreach (var filter in Filters.OfType()) filter.ImportCompleted(importContentContext); - ImportedAll(importContentContext); + ImportCompleted(importContentContext); } void IContentHandler.Exporting(ExportContentContext context) { @@ -511,7 +511,7 @@ namespace Orchard.ContentManagement.Handlers { protected virtual void Importing(ImportContentContext context) { } protected virtual void Imported(ImportContentContext context) { } - protected virtual void ImportedAll(ImportContentContext context) { } + protected virtual void ImportCompleted(ImportContentContext context) { } protected virtual void Exporting(ExportContentContext context) { } protected virtual void Exported(ExportContentContext context) { } protected virtual void Restoring(RestoreContentContext context) { }