Esempio n. 1
0
 public static string Import(this IImportExportService service, string recipeText)
 {
     var context = new ImportActionContext {
         RecipeDocument = XDocument.Parse(recipeText, LoadOptions.PreserveWhitespace)
     };
     service.Import(context);
     return context.ExecutionId;
 }
Esempio n. 2
0
 public string Import(ImportActionContext context, IEnumerable<IImportAction> actions = null) {
     foreach (var action in actions ?? _importActions) {
         action.Execute(context);
     }
     return context.ExecutionId;
 }
Esempio n. 3
0
 public abstract void Execute(ImportActionContext context);
Esempio n. 4
0
        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;
        }