Restyling the recipe dropdown

Roughing in some recipe execution concepts...

--HG--
branch : recipe
This commit is contained in:
Suha Can
2011-02-14 16:30:14 -08:00
parent b66b738a24
commit 8ddb5b55b6
8 changed files with 67 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Recipes.Models;
@@ -21,21 +22,25 @@ namespace Orchard.Recipes.Services {
if (recipe == null)
return;
var executionId = Guid.NewGuid().ToString("n");
var recipeContext = new RecipeContext { Recipe = recipe };
// TODO: Run each step inside a transaction boundary.
// TODO: Output should go into a report.
// TODO: Eventually return a guid.tostring("n") execution id
// TODO: Enqueue steps for the step executor.
foreach (var recipeStep in recipe.RecipeSteps) {
recipeContext.RecipeStep = recipeStep;
recipeContext.Executed = false;
foreach (var handler in _recipeHandlers) {
handler.ExecuteRecipeStep(recipeContext);
foreach (var recipeHandler in _recipeHandlers) {
recipeHandler.ExecuteRecipeStep(recipeContext);
}
if (!recipeContext.Executed) {
Logger.Error("Could not execute recipe step '{0}' because the recipe handler was not found.", recipeContext.RecipeStep.Name);
}
}
// TODO: figure out shell settings and shell descriptor for processing engine to run under
// _processingEngine.AddTask(null, null, "IRecipeStepEvents_DoWork", null);
}
}
}

View File

@@ -216,11 +216,6 @@ namespace Orchard.Setup.Services {
}
private void CreateTenantData(SetupContext context, IWorkContextScope environment) {
var recipeManager = environment.Resolve<IRecipeManager>();
if (context.Recipe != null) {
recipeManager.Execute(Recipes().Where(r => r.Name == context.Recipe).FirstOrDefault());
}
// create superuser
var membershipService = environment.Resolve<IMembershipService>();
var user =
@@ -349,6 +344,11 @@ Modules are created by other users of Orchard just like you so if you feel up to
menuItem.As<MenuPart>().OnMainMenu = true;
menuItem.As<MenuItemPart>().Url = "";
var recipeManager = environment.Resolve<IRecipeManager>();
if (context.Recipe != null) {
recipeManager.Execute(Recipes().Where(r => r.Name == context.Recipe).FirstOrDefault());
}
//null check: temporary fix for running setup in command line
if (HttpContext.Current != null) {
authenticationService.SignIn(user, true);

View File

@@ -129,6 +129,8 @@ input[type="password"] {
}
select {
padding:3px;
border:1px solid #bdbcbc;
width:100%;
}

View File

@@ -193,11 +193,15 @@
<Compile Include="Mvc\ViewEngines\Razor\IRazorCompilationEvents.cs" />
<Compile Include="Recipes\Models\Recipe.cs" />
<Compile Include="Recipes\Models\RecipeContext.cs" />
<Compile Include="Recipes\Models\RecipeJournal.cs" />
<Compile Include="Recipes\Models\RecipeStep.cs" />
<Compile Include="Recipes\Services\IRecipeHandler.cs" />
<Compile Include="Recipes\Services\IRecipeHarvester.cs" />
<Compile Include="Recipes\Services\IRecipeJournal.cs" />
<Compile Include="Recipes\Services\IRecipeManager.cs" />
<Compile Include="Recipes\Services\IRecipeParser.cs" />
<Compile Include="Recipes\Services\IRecipeStepExecutor.cs" />
<Compile Include="Recipes\Services\IRecipeStepQueue.cs" />
<Compile Include="Security\IEncryptionService.cs" />
<Compile Include="Security\CurrentUserWorkContext.cs" />
<Compile Include="Security\Providers\DefaultEncryptionService.cs" />

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
namespace Orchard.Recipes.Models {
public class RecipeJournal {
public string ExecutionId { get; set; }
public RecipeJournalStatus Status { get; set; }
public IEnumerable<JournalMessage> Messages { get; set; }
}
public class JournalMessage {
public string Message { get; set; }
}
public enum RecipeJournalStatus {
Running,
Complete,
Failed
}
}

View File

@@ -0,0 +1,11 @@
using Orchard.Recipes.Models;
namespace Orchard.Recipes.Services {
public interface IRecipeJournal {
void StartExecution(string executionId);
void ExecutionComplete(string executionId);
void ExecutionFailed(string executionId);
void WriteJournalEntry(string executionId, string message);
RecipeJournal GetRecipeJournal(string executionId);
}
}

View File

@@ -0,0 +1,5 @@
namespace Orchard.Recipes.Services {
public interface IRecipeStepExecutor : IDependency {
bool ExecuteNextStep();
}
}

View File

@@ -0,0 +1,9 @@
using System;
using Orchard.Recipes.Models;
namespace Orchard.Recipes.Services {
public interface IRecipeStepQueue : IDependency {
void Enqueue(RecipeStep step, string executionId);
Tuple<RecipeStep, string> Dequeue();
}
}