Converting database update page from webforms to razor

Adding routes on the migration module
Adding navigation item on the migration module
Fixing feature naming on codegeneration module

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues 2010-10-01 11:49:43 -07:00
parent ac5243d184
commit 5befbad6be
12 changed files with 83 additions and 25 deletions

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web.Hosting;
using Orchard.Commands;
using Orchard.Data.Migration.Generator;
@ -15,7 +14,6 @@ using Orchard.Localization;
namespace Orchard.CodeGeneration.Commands {
[OrchardFeature("Generate")]
public class CodeGenerationCommands : DefaultOrchardCommandHandler {
private readonly IExtensionManager _extensionManager;

View File

@ -1,4 +1,4 @@
Name: Code generation module
Name: Code generation
antiforgery: enabled
author: The Orchard Team
website: http://orchardproject.net
@ -6,6 +6,6 @@ version: 0.1.0
orchardversion: 0.6.0
description:
features:
Generate:
Orchard.CodeGeneration:
Description: Tools to create Orchard components.
Category: Developer

View File

@ -1,4 +1,4 @@
Name: Experimental module
Name: Experimental
antiforgery: enabled
author: The Orchard Team
website: http://orchardproject.net

View File

@ -0,0 +1,15 @@
using Orchard.Localization;
using Orchard.UI.Navigation;
namespace Orchard.Migrations {
public class AdminMenu : INavigationProvider {
public Localizer T { get; set; }
public string MenuName { get { return "admin"; } }
public void GetNavigation(NavigationBuilder builder) {
builder.Add(T("Developer"), "10",
menu => menu
.Add(T("Migration"), "1.0", item => item.Action("Index", "DatabaseUpdate", new { area = "Orchard.Migrations" })));
}
}
}

View File

@ -8,7 +8,7 @@ using Orchard.Environment.Extensions;
namespace Orchard.Migrations.Commands {
[OrchardFeature("Orchard.Migration")]
[OrchardFeature("Orchard.Migrations")]
public class DataMigrationCommands : DefaultOrchardCommandHandler {
private readonly IDataMigrationManager _dataMigrationManager;
private readonly IDataMigrationInterpreter _dataMigrationInterpreter;

View File

@ -1,14 +1,15 @@
using System;
using System.Web.Mvc;
using Orchard.Data.Migration.Generator;
using Orchard.Localization;
using Orchard.Environment.Extensions;
using Orchard.Localization;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
namespace Orchard.Migrations.Controllers {
[ValidateInput(false)]
[Admin]
[Admin, OrchardFeature("DatabaseUpdate")]
public class DatabaseUpdateController : Controller {
private readonly ISchemaCommandGenerator _schemaCommandGenerator;
@ -26,7 +27,6 @@ namespace Orchard.Migrations.Controllers {
public ActionResult UpdateDatabase() {
try {
_schemaCommandGenerator.UpdateDatabase();
Services.Notifier.Information(T("Database updated successfuly"));
}
@ -34,7 +34,7 @@ namespace Orchard.Migrations.Controllers {
Services.Notifier.Error(T("An error occured while updating the database: {0}", ex.Message));
}
return RedirectToAction("Index");
return RedirectToAction("Index");
}
}
}

View File

@ -1,4 +1,4 @@
Name: Migration module
Name: Migrations
antiforgery: enabled
author: The Orchard Team
website: http://orchardproject.net
@ -6,10 +6,10 @@ version: 0.1.0
orchardversion: 0.6.0
description:
features:
Orchard.Migration:
Description: Data migration commands.
Category: Migrations
DatabaseMigration:
Description: Database migration action.
Dependencies: Orchard.Migration
Category: Migrations
Orchard.Migrations:
Description: Data migration commands.
Category: Developer
DatabaseUpdate:
Description: Automatically updates database schema.
Dependencies: Orchard.Migrations
Category: Developer

View File

@ -68,13 +68,15 @@
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\DatabaseUpdateController.cs" />
<Compile Include="Commands\DataMigrationCommands.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Routes.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
<Content Include="Views\DatabaseUpdate\Index.aspx" />
<None Include="Views\DatabaseUpdate\Index.cshtml" />
<Content Include="Web.config" />
<Content Include="Views\Web.config" />
</ItemGroup>

View File

@ -0,0 +1,47 @@
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.Mvc.Routes;
namespace Orchard.Migrations {
public class Routes : IRouteProvider {
public void GetRoutes(ICollection<RouteDescriptor> routes) {
foreach (var routeDescriptor in GetRoutes())
routes.Add(routeDescriptor);
}
public IEnumerable<RouteDescriptor> GetRoutes() {
return new[] {
new RouteDescriptor {
Route = new Route(
"Admin/Migrations/",
new RouteValueDictionary {
{"area", "Orchard.Migrations"},
{"controller", "DatabaseUpdate"},
{"action", "Index"}
},
new RouteValueDictionary(),
new RouteValueDictionary {
{"area", "Orchard.Migrations"}
},
new MvcRouteHandler())
},
new RouteDescriptor {
Route = new Route(
"Admin/Migrations/UpdateDatabase",
new RouteValueDictionary {
{"area", "Orchard.Migrations"},
{"controller", "DatabaseUpdate"},
{"action", "UpdateDatabase"}
},
new RouteValueDictionary(),
new RouteValueDictionary {
{"area", "Orchard.Migrations"}
},
new MvcRouteHandler())
}
};
}
}
}

View File

@ -1,4 +0,0 @@
<%@ Page Language="C#" Inherits="Orchard.Mvc.ViewPage<BaseViewModel>"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<h1><%: Html.TitleForPage(T("Data Migration").ToString()) %></h1>
<p><%: Html.ActionLink(T("Update Database").ToString(), "UpdateDatabase", "DatabaseUpdate") %></p>

View File

@ -0,0 +1,2 @@
<h1>@Html.TitleForPage(T("Data Migration").ToString())</h1>
<p>@Html.ActionLink(T("Update Database").ToString(), "UpdateDatabase", "DatabaseUpdate")</p>

View File

@ -1,10 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Razor.Web;
using System.Reflection;
using System.Text;
using System.Threading;
using Orchard.Environment;
using Orchard.Environment.Extensions.Loaders;