mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Added logging to replace removed recipe journals.
This commit is contained in:
@@ -37,6 +37,8 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Information("Executing recipe step '{0}'; ExecutionId={1}", recipeContext.RecipeStep.Name, recipeContext.ExecutionId);
|
||||||
|
|
||||||
var commands =
|
var commands =
|
||||||
recipeContext.RecipeStep.Step.Value
|
recipeContext.RecipeStep.Step.Value
|
||||||
.Split(new[] {"\r\n", "\n"}, StringSplitOptions.RemoveEmptyEntries)
|
.Split(new[] {"\r\n", "\n"}, StringSplitOptions.RemoveEmptyEntries)
|
||||||
@@ -44,18 +46,22 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
|
|
||||||
foreach (var command in commands) {
|
foreach (var command in commands) {
|
||||||
if (!String.IsNullOrEmpty(command)) {
|
if (!String.IsNullOrEmpty(command)) {
|
||||||
if (!String.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
Logger.Information("Executing command: {0}", command);
|
||||||
// TODO: ************** LOGGING
|
try {
|
||||||
//_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Commands: Executing item {0}.", command).Text);
|
|
||||||
}
|
|
||||||
var commandParameters = _commandParser.ParseCommandParameters(command);
|
var commandParameters = _commandParser.ParseCommandParameters(command);
|
||||||
var input = new StringReader("");
|
var input = new StringReader("");
|
||||||
var output = new StringWriter();
|
var output = new StringWriter();
|
||||||
_commandManager.Execute(new CommandParameters { Arguments = commandParameters.Arguments, Input = input, Output = output, Switches = commandParameters.Switches });
|
_commandManager.Execute(new CommandParameters { Arguments = commandParameters.Arguments, Input = input, Output = output, Switches = commandParameters.Switches });
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Error(ex, "Error while executing command: {0}", command);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recipeContext.Executed = true;
|
recipeContext.Executed = true;
|
||||||
|
Logger.Information("Finished executing recipe step '{0}'.", recipeContext.RecipeStep.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Information("Executing recipe step '{0}'; ExecutionId={1}", recipeContext.RecipeStep.Name, recipeContext.ExecutionId);
|
||||||
|
|
||||||
var importContentSession = new ImportContentSession(_orchardServices.ContentManager);
|
var importContentSession = new ImportContentSession(_orchardServices.ContentManager);
|
||||||
|
|
||||||
// Populate local dictionary with elements and their ids
|
// Populate local dictionary with elements and their ids
|
||||||
@@ -43,24 +45,32 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
//Determine if the import is to be batched in multiple transactions
|
//Determine if the import is to be batched in multiple transactions
|
||||||
var startIndex = 0;
|
var startIndex = 0;
|
||||||
int batchSize = GetBatchSizeForDataStep(recipeContext.RecipeStep.Step);
|
int batchSize = GetBatchSizeForDataStep(recipeContext.RecipeStep.Step);
|
||||||
|
Logger.Debug("Using batch size {0}.", batchSize);
|
||||||
|
|
||||||
//Run the import
|
//Run the import
|
||||||
try {
|
try {
|
||||||
while (startIndex < elementDictionary.Count) {
|
while (startIndex < elementDictionary.Count) {
|
||||||
|
Logger.Debug("Importing batch starting at index {0}.", startIndex);
|
||||||
importContentSession.InitializeBatch(startIndex, batchSize);
|
importContentSession.InitializeBatch(startIndex, batchSize);
|
||||||
|
|
||||||
//the session determines which items are included in the current batch
|
//the session determines which items are included in the current batch
|
||||||
//so that dependencies can be managed within the same transaction
|
//so that dependencies can be managed within the same transaction
|
||||||
var nextIdentity = importContentSession.GetNextInBatch();
|
var nextIdentity = importContentSession.GetNextInBatch();
|
||||||
while (nextIdentity != null) {
|
while (nextIdentity != null) {
|
||||||
if (!string.IsNullOrEmpty(recipeContext.ExecutionId) && elementDictionary[nextIdentity.ToString()].HasAttributes) {
|
var itemId = "";
|
||||||
var itemId = elementDictionary[nextIdentity.ToString()].FirstAttribute.Value;
|
if (elementDictionary[nextIdentity.ToString()].HasAttributes) {
|
||||||
// TODO: ************** LOGGING
|
itemId = elementDictionary[nextIdentity.ToString()].FirstAttribute.Value;
|
||||||
//_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Data: Importing {0}.", itemId).Text);
|
|
||||||
}
|
}
|
||||||
|
Logger.Information("Importing data item '{0}'.", itemId);
|
||||||
|
try {
|
||||||
_orchardServices.ContentManager.Import(
|
_orchardServices.ContentManager.Import(
|
||||||
elementDictionary[nextIdentity.ToString()],
|
elementDictionary[nextIdentity.ToString()],
|
||||||
importContentSession);
|
importContentSession);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Error(ex, "Error while importing data item '{0}'.", itemId);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
nextIdentity = importContentSession.GetNextInBatch();
|
nextIdentity = importContentSession.GetNextInBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +80,8 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
if (startIndex < elementDictionary.Count) {
|
if (startIndex < elementDictionary.Count) {
|
||||||
_transactionManager.RequireNew();
|
_transactionManager.RequireNew();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Debug("Finished importing batch starting at index {0}.", startIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception) {
|
catch (Exception) {
|
||||||
@@ -79,6 +91,7 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
recipeContext.Executed = true;
|
recipeContext.Executed = true;
|
||||||
|
Logger.Information("Finished executing recipe step '{0}'.", recipeContext.RecipeStep.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, XElement> CreateElementDictionary(XElement step) {
|
private Dictionary<string, XElement> CreateElementDictionary(XElement step) {
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Information("Executing recipe step '{0}'; ExecutionId={1}", recipeContext.RecipeStep.Name, recipeContext.ExecutionId);
|
||||||
|
|
||||||
var featuresToEnable = new List<string>();
|
var featuresToEnable = new List<string>();
|
||||||
var featuresToDisable = new List<string>();
|
var featuresToDisable = new List<string>();
|
||||||
foreach (var attribute in recipeContext.RecipeStep.Step.Attributes()) {
|
foreach (var attribute in recipeContext.RecipeStep.Step.Attributes()) {
|
||||||
@@ -37,7 +39,7 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
featuresToEnable = ParseFeatures(attribute.Value);
|
featuresToEnable = ParseFeatures(attribute.Value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logger.Error("Unrecognized attribute {0} encountered in step Feature. Skipping.", attribute.Name.LocalName);
|
Logger.Warning("Unrecognized attribute '{0}' encountered; skipping", attribute.Name.LocalName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,14 +56,17 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (featuresToDisable.Count != 0) {
|
if (featuresToDisable.Any()) {
|
||||||
|
Logger.Information("Disabling features: {0}", String.Join(";", featuresToDisable));
|
||||||
_featureManager.DisableFeatures(featuresToDisable, true);
|
_featureManager.DisableFeatures(featuresToDisable, true);
|
||||||
}
|
}
|
||||||
if (featuresToEnable.Count != 0) {
|
if (featuresToEnable.Any()) {
|
||||||
|
Logger.Information("Enabling features: {0}", String.Join(";", featuresToEnable));
|
||||||
_featureManager.EnableFeatures(featuresToEnable, true);
|
_featureManager.EnableFeatures(featuresToEnable, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
recipeContext.Executed = true;
|
recipeContext.Executed = true;
|
||||||
|
Logger.Information("Finished executing recipe step '{0}'.", recipeContext.RecipeStep.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<string> ParseFeatures(string csv) {
|
private static List<string> ParseFeatures(string csv) {
|
||||||
|
|||||||
@@ -46,36 +46,55 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Information("Executing recipe step '{0}'; ExecutionId={1}", recipeContext.RecipeStep.Name, recipeContext.ExecutionId);
|
||||||
|
|
||||||
foreach (var metadataElement in recipeContext.RecipeStep.Step.Elements()) {
|
foreach (var metadataElement in recipeContext.RecipeStep.Step.Elements()) {
|
||||||
|
Logger.Debug("Processing element '{0}'.", metadataElement.Name.LocalName);
|
||||||
switch (metadataElement.Name.LocalName) {
|
switch (metadataElement.Name.LocalName) {
|
||||||
case "Types":
|
case "Types":
|
||||||
foreach (var element in metadataElement.Elements()) {
|
foreach (var element in metadataElement.Elements()) {
|
||||||
var typeElement = element;
|
var typeElement = element;
|
||||||
var typeName = XmlConvert.DecodeName(element.Name.LocalName);
|
var typeName = XmlConvert.DecodeName(element.Name.LocalName);
|
||||||
|
|
||||||
|
Logger.Information("Importing content type '{0}'.", typeName);
|
||||||
|
try {
|
||||||
_contentDefinitonEventHandlers.ContentTypeImporting(new ContentTypeImportingContext { ContentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(typeName), ContentTypeName = typeName });
|
_contentDefinitonEventHandlers.ContentTypeImporting(new ContentTypeImportingContext { ContentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(typeName), ContentTypeName = typeName });
|
||||||
_contentDefinitionManager.AlterTypeDefinition(typeName, alteration => _contentDefinitionReader.Merge(typeElement, alteration));
|
_contentDefinitionManager.AlterTypeDefinition(typeName, alteration => _contentDefinitionReader.Merge(typeElement, alteration));
|
||||||
_contentDefinitonEventHandlers.ContentTypeImported(new ContentTypeImportedContext { ContentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(typeName) });
|
_contentDefinitonEventHandlers.ContentTypeImported(new ContentTypeImportedContext { ContentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(typeName) });
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Error(ex, "Error while importing content type '{0}'.", typeName);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Parts":
|
case "Parts":
|
||||||
// create dynamic part.
|
|
||||||
foreach (var element in metadataElement.Elements()) {
|
foreach (var element in metadataElement.Elements()) {
|
||||||
var partElement = element;
|
var partElement = element;
|
||||||
var partName = XmlConvert.DecodeName(element.Name.LocalName);
|
var partName = XmlConvert.DecodeName(element.Name.LocalName);
|
||||||
|
|
||||||
|
Logger.Information("Importing content part '{0}'.", partName);
|
||||||
|
try {
|
||||||
_contentDefinitonEventHandlers.ContentPartImporting(new ContentPartImportingContext { ContentPartDefinition = _contentDefinitionManager.GetPartDefinition(partName), ContentPartName = partName });
|
_contentDefinitonEventHandlers.ContentPartImporting(new ContentPartImportingContext { ContentPartDefinition = _contentDefinitionManager.GetPartDefinition(partName), ContentPartName = partName });
|
||||||
_contentDefinitionManager.AlterPartDefinition(partName, alteration => _contentDefinitionReader.Merge(partElement, alteration));
|
_contentDefinitionManager.AlterPartDefinition(partName, alteration => _contentDefinitionReader.Merge(partElement, alteration));
|
||||||
_contentDefinitonEventHandlers.ContentPartImported(new ContentPartImportedContext { ContentPartDefinition = _contentDefinitionManager.GetPartDefinition(partName)});
|
_contentDefinitonEventHandlers.ContentPartImported(new ContentPartImportedContext { ContentPartDefinition = _contentDefinitionManager.GetPartDefinition(partName)});
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Error(ex, "Error while importing content part '{0}'.", partName);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Logger.Error("Unrecognized element {0} encountered in step Metadata. Skipping.", metadataElement.Name.LocalName);
|
Logger.Warning("Unrecognized element '{0}' encountered; skipping", metadataElement.Name.LocalName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recipeContext.Executed = true;
|
recipeContext.Executed = true;
|
||||||
|
Logger.Information("Finished executing recipe step '{0}'.", recipeContext.RecipeStep.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,8 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Information("Executing recipe step '{0}'; ExecutionId={1}", recipeContext.RecipeStep.Name, recipeContext.ExecutionId);
|
||||||
|
|
||||||
bool runAll = false;
|
bool runAll = false;
|
||||||
var features = new List<string>();
|
var features = new List<string>();
|
||||||
foreach (var attribute in recipeContext.RecipeStep.Step.Attributes()) {
|
foreach (var attribute in recipeContext.RecipeStep.Step.Attributes()) {
|
||||||
@@ -37,21 +39,35 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
runAll = true;
|
runAll = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logger.Error("Unrecognized attribute {0} encountered in step Migration. Skipping.", attribute.Name.LocalName);
|
Logger.Warning("Unrecognized attribute '{0}' encountered; skipping.", attribute.Name.LocalName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runAll) {
|
if (runAll) {
|
||||||
foreach (var feature in _dataMigrationManager.GetFeaturesThatNeedUpdate()) {
|
foreach (var feature in _dataMigrationManager.GetFeaturesThatNeedUpdate()) {
|
||||||
|
Logger.Information("Updating feature '{0}'.", feature);
|
||||||
|
try {
|
||||||
_dataMigrationManager.Update(feature);
|
_dataMigrationManager.Update(feature);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Error(ex, "Error while updating feature '{0}'", feature);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Logger.Information("Updating features: {0}", String.Join(";", features));
|
||||||
|
try {
|
||||||
_dataMigrationManager.Update(features);
|
_dataMigrationManager.Update(features);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Error(ex, "Error while updating features: {0}", String.Join(";", features));
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// run migrations
|
|
||||||
recipeContext.Executed = true;
|
recipeContext.Executed = true;
|
||||||
|
Logger.Information("Finished executing recipe step '{0}'.", recipeContext.RecipeStep.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<string> ParseFeatures(string csv) {
|
private static List<string> ParseFeatures(string csv) {
|
||||||
|
|||||||
@@ -37,8 +37,10 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
if (!String.Equals(recipeContext.RecipeStep.Name, "Module", StringComparison.OrdinalIgnoreCase)) {
|
if (!String.Equals(recipeContext.RecipeStep.Name, "Module", StringComparison.OrdinalIgnoreCase)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string packageId = null, version = null, repository = null;
|
|
||||||
|
|
||||||
|
Logger.Information("Executing recipe step '{0}'; ExecutionId={1}", recipeContext.RecipeStep.Name, recipeContext.ExecutionId);
|
||||||
|
|
||||||
|
string packageId = null, version = null, repository = null;
|
||||||
foreach (var attribute in recipeContext.RecipeStep.Step.Attributes()) {
|
foreach (var attribute in recipeContext.RecipeStep.Step.Attributes()) {
|
||||||
if (String.Equals(attribute.Name.LocalName, "packageId", StringComparison.OrdinalIgnoreCase)) {
|
if (String.Equals(attribute.Name.LocalName, "packageId", StringComparison.OrdinalIgnoreCase)) {
|
||||||
packageId = attribute.Value;
|
packageId = attribute.Value;
|
||||||
@@ -85,10 +87,7 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
|
|
||||||
if (packagingEntry != null) {
|
if (packagingEntry != null) {
|
||||||
if (!ModuleAlreadyInstalled(packagingEntry.PackageId)) {
|
if (!ModuleAlreadyInstalled(packagingEntry.PackageId)) {
|
||||||
if (!string.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
Logger.Information("Installing module {0}.", packagingEntry.Title);
|
||||||
// TODO: ************** LOGGING
|
|
||||||
//_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Installing module: {0}.", packagingEntry.Title).Text);
|
|
||||||
}
|
|
||||||
_packageManager.Install(packagingEntry.PackageId, packagingEntry.Version, packagingSource.FeedUrl, HostingEnvironment.MapPath("~/"));
|
_packageManager.Install(packagingEntry.PackageId, packagingEntry.Version, packagingSource.FeedUrl, HostingEnvironment.MapPath("~/"));
|
||||||
}
|
}
|
||||||
installed = true;
|
installed = true;
|
||||||
@@ -99,6 +98,7 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
recipeContext.Executed = true;
|
recipeContext.Executed = true;
|
||||||
|
Logger.Information("Finished executing recipe step '{0}'.", recipeContext.RecipeStep.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ModuleAlreadyInstalled(string packageId) {
|
private bool ModuleAlreadyInstalled(string packageId) {
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Information("Executing recipe step '{0}'; ExecutionId={1}", recipeContext.RecipeStep.Name, recipeContext.ExecutionId);
|
||||||
|
|
||||||
var siteContentItem = _siteService.GetSiteSettings().ContentItem;
|
var siteContentItem = _siteService.GetSiteSettings().ContentItem;
|
||||||
|
|
||||||
var importContentSession = new ImportContentSession(_contentManager);
|
var importContentSession = new ImportContentSession(_contentManager);
|
||||||
@@ -54,19 +56,22 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
Logger.Information("Importing settings part '{0}'.", contentPart.PartDefinition.Name);
|
||||||
// TODO: ************** LOGGING
|
try {
|
||||||
//_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Setting: {0}.", contentPart.PartDefinition.Name).Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImportSettingPart(contentPart, partElement);
|
ImportSettingPart(contentPart, partElement);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Error(ex, "Error while importing settings part '{0}'.", contentPart.PartDefinition.Name);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var contentHandler in Handlers) {
|
foreach (var contentHandler in Handlers) {
|
||||||
contentHandler.Imported(context);
|
contentHandler.Imported(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
recipeContext.Executed = true;
|
recipeContext.Executed = true;
|
||||||
|
Logger.Information("Finished executing recipe step '{0}'.", recipeContext.RecipeStep.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ImportSettingPart(ContentPart sitePart, XElement element) {
|
private void ImportSettingPart(ContentPart sitePart, XElement element) {
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Information("Executing recipe step '{0}'; ExecutionId={1}", recipeContext.RecipeStep.Name, recipeContext.ExecutionId);
|
||||||
|
|
||||||
bool enable = false, current = false;
|
bool enable = false, current = false;
|
||||||
string packageId = null, version = null, repository = null;
|
string packageId = null, version = null, repository = null;
|
||||||
|
|
||||||
@@ -66,12 +68,12 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
repository = attribute.Value;
|
repository = attribute.Value;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logger.Error("Unrecognized attribute {0} encountered in step Theme. Skipping.", attribute.Name.LocalName);
|
Logger.Warning("Unrecognized attribute '{0}' encountered; skipping.", attribute.Name.LocalName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packageId == null) {
|
if (packageId == null) {
|
||||||
throw new InvalidOperationException("PackageId is required in a Theme declaration in a recipe file.");
|
throw new InvalidOperationException("The PackageId attribute is required on a Theme declaration in a recipe file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// download and install theme from the orchard feed or a custom feed if repository is specified.
|
// download and install theme from the orchard feed or a custom feed if repository is specified.
|
||||||
@@ -101,13 +103,17 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
|
|
||||||
if (packagingEntry != null) {
|
if (packagingEntry != null) {
|
||||||
if (!ThemeAlreadyInstalled(packagingEntry.PackageId)) {
|
if (!ThemeAlreadyInstalled(packagingEntry.PackageId)) {
|
||||||
|
Logger.Information("Installing theme package '{0}'.", packagingEntry.PackageId);
|
||||||
_packageManager.Install(packagingEntry.PackageId, packagingEntry.Version, packagingSource.FeedUrl, HostingEnvironment.MapPath("~/"));
|
_packageManager.Install(packagingEntry.PackageId, packagingEntry.Version, packagingSource.FeedUrl, HostingEnvironment.MapPath("~/"));
|
||||||
}
|
}
|
||||||
if (current) {
|
if (current) {
|
||||||
|
Logger.Information("Enabling theme '{0}'.", packagingEntry.Title);
|
||||||
_themeService.EnableThemeFeatures(packagingEntry.Title);
|
_themeService.EnableThemeFeatures(packagingEntry.Title);
|
||||||
|
Logger.Information("Setting theme '{0}' as the site theme.", packagingEntry.Title);
|
||||||
_siteThemeService.SetSiteTheme(packagingEntry.Title);
|
_siteThemeService.SetSiteTheme(packagingEntry.Title);
|
||||||
}
|
}
|
||||||
else if (enable) {
|
else if (enable) {
|
||||||
|
Logger.Information("Enabling theme '{0}'.", packagingEntry.Title);
|
||||||
_themeService.EnableThemeFeatures(packagingEntry.Title);
|
_themeService.EnableThemeFeatures(packagingEntry.Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,10 +121,11 @@ namespace Orchard.Recipes.RecipeHandlers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!installed) {
|
if (!installed) {
|
||||||
throw new InvalidOperationException(string.Format("Theme {0} was not found in the specified location.", packageId));
|
throw new InvalidOperationException(string.Format("Theme '{0}' was not found in the specified location.", packageId));
|
||||||
}
|
}
|
||||||
|
|
||||||
recipeContext.Executed = true;
|
recipeContext.Executed = true;
|
||||||
|
Logger.Information("Finished executing recipe step '{0}'.", recipeContext.RecipeStep.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ThemeAlreadyInstalled(string packageId) {
|
private bool ThemeAlreadyInstalled(string packageId) {
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ namespace Orchard.Recipes.Services {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
var executionId = Guid.NewGuid().ToString("n");
|
var executionId = Guid.NewGuid().ToString("n");
|
||||||
// TODO: ************** LOGGING
|
Logger.Information("Executing recipe '{0}' using ExecutionId {1}.", recipe.Name, executionId);
|
||||||
//_recipeJournal.ExecutionStart(executionId);
|
|
||||||
_recipeExecuteEventHandler.ExecutionStart(executionId, recipe);
|
_recipeExecuteEventHandler.ExecutionStart(executionId, recipe);
|
||||||
|
|
||||||
foreach (var recipeStep in recipe.RecipeSteps) {
|
foreach (var recipeStep in recipe.RecipeSteps) {
|
||||||
|
|||||||
@@ -29,13 +29,11 @@ namespace Orchard.Recipes.Services {
|
|||||||
public bool ExecuteNextStep(string executionId) {
|
public bool ExecuteNextStep(string executionId) {
|
||||||
var nextRecipeStep = _recipeStepQueue.Dequeue(executionId);
|
var nextRecipeStep = _recipeStepQueue.Dequeue(executionId);
|
||||||
if (nextRecipeStep == null) {
|
if (nextRecipeStep == null) {
|
||||||
// TODO: ************** LOGGING
|
Logger.Information("Recipe execution {0} completed.", executionId);
|
||||||
//_recipeJournal.ExecutionComplete(executionId);
|
|
||||||
_recipeExecuteEventHandler.ExecutionComplete(executionId);
|
_recipeExecuteEventHandler.ExecutionComplete(executionId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// TODO: ************** LOGGING
|
Logger.Information("Running all recipe handlers for step '{0}'.", nextRecipeStep.Name);
|
||||||
//_recipeJournal.WriteJournalEntry(executionId, string.Format("Executing step {0}.", nextRecipeStep.Name));
|
|
||||||
var recipeContext = new RecipeContext { RecipeStep = nextRecipeStep, Executed = false, ExecutionId = executionId };
|
var recipeContext = new RecipeContext { RecipeStep = nextRecipeStep, Executed = false, ExecutionId = executionId };
|
||||||
try {
|
try {
|
||||||
_recipeExecuteEventHandler.RecipeStepExecuting(executionId, recipeContext);
|
_recipeExecuteEventHandler.RecipeStepExecuting(executionId, recipeContext);
|
||||||
@@ -45,28 +43,16 @@ namespace Orchard.Recipes.Services {
|
|||||||
_recipeExecuteEventHandler.RecipeStepExecuted(executionId, recipeContext);
|
_recipeExecuteEventHandler.RecipeStepExecuted(executionId, recipeContext);
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
Logger.Error(exception, "Recipe execution {0} was cancelled because a step failed to execute", executionId);
|
Logger.Error(exception, "Recipe execution {0} failed because the step '{1}' failed.", executionId, nextRecipeStep.Name);
|
||||||
while (_recipeStepQueue.Dequeue(executionId) != null);
|
while (_recipeStepQueue.Dequeue(executionId) != null);
|
||||||
// TODO: ************** LOGGING
|
var message = T("Recipe execution with ID {0} failed because the step '{1}' failed to execute. The following exception was thrown:\n{2}\nRefer to the error logs for more information.", executionId, nextRecipeStep.Name, exception.Message);
|
||||||
//_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);
|
|
||||||
// TODO: ************** LOGGING
|
|
||||||
//_recipeJournal.WriteJournalEntry(executionId, message.ToString());
|
|
||||||
|
|
||||||
throw new OrchardCoreException(message);
|
throw new OrchardCoreException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!recipeContext.Executed) {
|
if (!recipeContext.Executed) {
|
||||||
Logger.Error("Could not execute recipe step '{0}' because the recipe handler was not found.", recipeContext.RecipeStep.Name);
|
Logger.Error("Recipe execution {0} failed because no matching handler for recipe step '{1}' was found.", executionId, recipeContext.RecipeStep.Name);
|
||||||
while (_recipeStepQueue.Dequeue(executionId) != null);
|
while (_recipeStepQueue.Dequeue(executionId) != null);
|
||||||
// TODO: ************** LOGGING
|
var message = T("Recipe execution with ID {0} failed because no matching handler for recipe step '{1}' was found. Refer to the error logs for more information.", executionId, nextRecipeStep.Name);
|
||||||
//_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);
|
|
||||||
// TODO: ************** LOGGING
|
|
||||||
//_recipeJournal.WriteJournalEntry(executionId, message.ToString());
|
|
||||||
|
|
||||||
throw new OrchardCoreException(message);
|
throw new OrchardCoreException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,16 +33,16 @@ namespace Orchard.Roles.ImportExport {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.Information("Executing recipe step '{0}'; ExecutionId={1}", recipeContext.RecipeStep.Name, recipeContext.ExecutionId);
|
||||||
|
|
||||||
var installedPermissions = _roleService.GetInstalledPermissions().SelectMany(p => p.Value).ToList();
|
var installedPermissions = _roleService.GetInstalledPermissions().SelectMany(p => p.Value).ToList();
|
||||||
|
|
||||||
foreach (var roleElement in recipeContext.RecipeStep.Step.Elements()) {
|
foreach (var roleElement in recipeContext.RecipeStep.Step.Elements()) {
|
||||||
var roleName = roleElement.Attribute("Name").Value;
|
var roleName = roleElement.Attribute("Name").Value;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(recipeContext.ExecutionId)) {
|
Logger.Information("Processing role '{0}'.", roleName);
|
||||||
// TODO: ************** LOGGING
|
|
||||||
//_recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Roles: Executing item {0}.", roleName).Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
try {
|
||||||
var role = _roleService.GetRoleByName(roleName);
|
var role = _roleService.GetRoleByName(roleName);
|
||||||
if (role == null) {
|
if (role == null) {
|
||||||
_roleService.CreateRole(roleName);
|
_roleService.CreateRole(roleName);
|
||||||
@@ -56,7 +56,14 @@ namespace Orchard.Roles.ImportExport {
|
|||||||
// union to keep existing permissions
|
// union to keep existing permissions
|
||||||
_roleService.UpdateRole(role.Id, role.Name, permissionsValid.Union(role.RolesPermissions.Select(p => p.Permission.Name)));
|
_roleService.UpdateRole(role.Id, role.Name, permissionsValid.Union(role.RolesPermissions.Select(p => p.Permission.Name)));
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Logger.Error(ex, "Error while processing role '{0}'.", roleName);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
recipeContext.Executed = true;
|
recipeContext.Executed = true;
|
||||||
|
Logger.Information("Finished executing recipe step '{0}'.", recipeContext.RecipeStep.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user