public void Import(string recipeText) { var recipe = _recipeParser.ParseRecipe(recipeText); _recipeManager.Execute(recipe); UpdateShell(); }
public IEnumerable <Recipe> HarvestRecipes(string extensionId) { var recipes = new List <Recipe>(); var extension = _extensionManager.GetExtension(extensionId); if (extension != null) { var recipeLocation = Path.Combine(extension.Location, extensionId, "Recipes"); var recipeFiles = _webSiteFolder.ListFiles(recipeLocation, true); recipeFiles.Where(r => r.EndsWith(".recipe.xml", StringComparison.OrdinalIgnoreCase)).ToList().ForEach(r => { try { recipes.Add(_recipeParser.ParseRecipe(_webSiteFolder.ReadFile(r))); } catch (Exception ex) { Logger.Error(ex, "Error while parsing recipe file '{0}'.", r); } }); } else { Logger.Error("Could not discover recipes because module '{0}' was not found.", extensionId); } return(recipes); }
public ActionResult ExportPOST(ExportViewModel viewModel) { if (!Services.Authorizer.Authorize(Permissions.Export, T("Not allowed to export."))) { return(new HttpUnauthorizedResult()); } var actions = _exportActions.OrderByDescending(x => x.Priority).ToList(); foreach (var action in actions) { action.UpdateEditor(Services.New, this); } var exportActionContext = new ExportActionContext(); _importExportService.Export(exportActionContext, actions); var recipeDocument = exportActionContext.RecipeDocument; var exportFilePath = _importExportService.WriteExportFile(recipeDocument); var recipe = _recipeParser.ParseRecipe(recipeDocument); var exportFileName = recipe.GetExportFileName(); return(File(exportFilePath, "text/xml", exportFileName)); }
public string Import(string recipeText) { var recipe = _recipeParser.ParseRecipe(recipeText); var executionId = _recipeManager.Execute(recipe); UpdateShell(); return(executionId); }
public override void Execute(ImportActionContext context) { var recipeDocument = context.RecipeDocument ?? RecipeDocument; if (recipeDocument == null) { return; } // Give each execution step a chance to augment the recipe step before it will be scheduled. PrepareRecipe(recipeDocument); // Sets the request timeout to a configurable amount of seconds to give enough time to execute custom recipes. if (_orchardServices.WorkContext.HttpContext != null) { _orchardServices.WorkContext.HttpContext.Server.ScriptTimeout = RecipeExecutionTimeout; } // Suspend background task execution. _sweepGenerator.Terminate(); // Import or setup using the specified recipe. var executionId = ResetSite ? Setup(recipeDocument) : ExecuteRecipe(recipeDocument); if (executionId == null) { _orchardServices.Notifier.Warning(T("The recipe contained no steps. No work was scheduled.")); _sweepGenerator.Activate(); return; } // Resume background tasks once import/setup completes. var recipe = _recipeParser.ParseRecipe(recipeDocument); var activateSweepGeneratorStep = new RecipeStep(Guid.NewGuid().ToString("N"), recipe.Name, "ActivateSweepGenerator", new XElement("ActivateSweepGenerator")); _recipeStepQueue.Enqueue(executionId, activateSweepGeneratorStep); _recipeStepResultRepository.Create(new RecipeStepResultRecord { ExecutionId = executionId, RecipeName = recipe.Name, StepId = activateSweepGeneratorStep.Id, StepName = activateSweepGeneratorStep.Name }); context.ExecutionId = executionId; context.RecipeDocument = recipeDocument; }
private IEnumerable <Recipe> HarvestRecipes(ExtensionDescriptor extension) { var recipes = new List <Recipe>(); var recipeLocation = Path.Combine(extension.Location, extension.Id, "Recipes"); var recipeFiles = _webSiteFolder.ListFiles(recipeLocation, true); recipeFiles.Where(r => r.EndsWith(".recipe.xml", StringComparison.OrdinalIgnoreCase)).ToList().ForEach(r => { try { recipes.Add(_recipeParser.ParseRecipe(_webSiteFolder.ReadFile(r))); } catch (Exception ex) { Logger.Error(ex, "Error while parsing recipe file '{0}'.", r); } }); return(recipes); }
public IEnumerable <Recipe> HarvestRecipes(string extensionId) { var recipes = new List <Recipe>(); var extension = _extensionManager.GetExtension(extensionId); if (extension != null) { var recipeLocation = Path.Combine(extension.Location, extensionId, "Recipes"); var recipeFiles = _webSiteFolder.ListFiles(recipeLocation, true); recipes.AddRange( from recipeFile in recipeFiles where recipeFile.EndsWith(".recipe.xml", StringComparison.OrdinalIgnoreCase) select _recipeParser.ParseRecipe(_webSiteFolder.ReadFile(recipeFile))); } else { Logger.Error("Could not discover recipes because module '{0}' was not found.", extensionId); } return(recipes); }
public void ParseRecipeThrowsOnInvalidXml() { Assert.Throws(typeof(XmlException), () => _recipeParser.ParseRecipe("<reipe></recipe>")); }
public static Recipe ParseRecipe(this IRecipeParser recipeParser, string recipeText) { var recipeDocument = XDocument.Parse(recipeText, LoadOptions.PreserveWhitespace); return(recipeParser.ParseRecipe(recipeDocument)); }