Esempio n. 1
0
        public string Execute(Recipe recipe)
        {
            if (recipe == null)
            {
                return(null);
            }

            var executionId = Guid.NewGuid().ToString("n");

            _recipeJournal.ExecutionStart(executionId);
            _recipeExecuteEventHandler.ExecutionStart(executionId, recipe);

            foreach (var recipeStep in recipe.RecipeSteps)
            {
                _recipeStepQueue.Enqueue(executionId, recipeStep);
            }
            _recipeScheduler.ScheduleWork(executionId);

            return(executionId);
        }
        public string Execute(Recipe recipe)
        {
            if (recipe == null)
            {
                throw new ArgumentNullException("recipe");
            }

            if (!recipe.RecipeSteps.Any())
            {
                Logger.Information("Recipe '{0}' contains no steps. No work has been scheduled.");
                return(null);
            }

            var executionId = Guid.NewGuid().ToString("n");

            ThreadContext.Properties["ExecutionId"] = executionId;

            try {
                Logger.Information("Executing recipe '{0}'.", recipe.Name);
                _recipeExecuteEventHandler.ExecutionStart(executionId, recipe);

                foreach (var recipeStep in recipe.RecipeSteps)
                {
                    _recipeStepQueue.Enqueue(executionId, recipeStep);
                    _recipeStepResultRecordRepository.Create(new RecipeStepResultRecord {
                        ExecutionId = executionId,
                        RecipeName  = recipe.Name,
                        StepId      = recipeStep.Id,
                        StepName    = recipeStep.Name
                    });
                }
                _recipeScheduler.ScheduleWork(executionId);

                return(executionId);
            }
            finally {
                ThreadContext.Properties["ExecutionId"] = null;
            }
        }