2010-02-04 12:24:18 -08:00
|
|
|
|
using System.Web.Mvc;
|
2010-02-05 18:03:58 -08:00
|
|
|
|
using Orchard.ContentManagement;
|
|
|
|
|
using Orchard.Data.Migrations;
|
|
|
|
|
using Orchard.Environment;
|
|
|
|
|
using Orchard.Environment.Configuration;
|
2010-02-05 15:29:49 -08:00
|
|
|
|
using Orchard.Setup.ViewModels;
|
2010-02-04 12:24:18 -08:00
|
|
|
|
using Orchard.Localization;
|
2010-02-05 13:36:01 -08:00
|
|
|
|
using Orchard.UI.Notify;
|
2010-02-04 12:24:18 -08:00
|
|
|
|
|
2010-02-05 15:29:49 -08:00
|
|
|
|
namespace Orchard.Setup.Controllers {
|
2010-02-04 12:24:18 -08:00
|
|
|
|
public class SetupController : Controller {
|
2010-02-05 13:36:01 -08:00
|
|
|
|
private readonly INotifier _notifier;
|
2010-02-05 18:03:58 -08:00
|
|
|
|
private readonly IDatabaseMigrationManager _databaseMigrationManager;
|
|
|
|
|
private readonly IOrchardHost _orchardHost;
|
2010-02-04 12:24:18 -08:00
|
|
|
|
|
2010-02-05 18:03:58 -08:00
|
|
|
|
public SetupController(
|
|
|
|
|
INotifier notifier,
|
|
|
|
|
IDatabaseMigrationManager databaseMigrationManager,
|
|
|
|
|
IOrchardHost orchardHost) {
|
2010-02-05 13:36:01 -08:00
|
|
|
|
_notifier = notifier;
|
2010-02-05 18:03:58 -08:00
|
|
|
|
_databaseMigrationManager = databaseMigrationManager;
|
|
|
|
|
_orchardHost = orchardHost;
|
2010-02-04 12:24:18 -08:00
|
|
|
|
T = NullLocalizer.Instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Localizer T { get; set; }
|
|
|
|
|
|
|
|
|
|
public ActionResult Index() {
|
2010-02-05 13:36:01 -08:00
|
|
|
|
return View(new SetupViewModel { AdminUsername = "admin" });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult Index(SetupViewModel model) {
|
|
|
|
|
TryUpdateModel(model);
|
|
|
|
|
|
|
|
|
|
if (!ModelState.IsValid) {
|
|
|
|
|
return View(model);
|
|
|
|
|
}
|
2010-02-05 18:03:58 -08:00
|
|
|
|
|
|
|
|
|
//notes: service call to initialize database:
|
|
|
|
|
//_databaseMigrationManager.CreateCoordinator(provider, dataFolder, connectionString);
|
|
|
|
|
// provider: SqlServer or SQLite
|
|
|
|
|
// dataFolder: physical path (map before calling). Builtin database will be created in this location
|
|
|
|
|
// connectionString: optional - if provided the dataFolder is essentially ignored, but should still be passed in
|
|
|
|
|
|
2010-02-05 13:36:01 -08:00
|
|
|
|
|
2010-02-05 18:03:58 -08:00
|
|
|
|
//notes: the other tool needed will be creating a standalone environment.
|
|
|
|
|
// in theory this environment can be used to resolve any normal components by interface, and those
|
|
|
|
|
// components will exist entirely in isolation - no crossover between the safemode container currently in effect
|
|
|
|
|
var shellSettings = new ShellSettings { Name = "temp" };
|
|
|
|
|
using (var finiteEnvironment = _orchardHost.CreateStandaloneEnvironment(shellSettings)) {
|
|
|
|
|
var contentManager = finiteEnvironment.Resolve<IContentManager>();
|
|
|
|
|
var yadda = contentManager.Create("yadda");
|
|
|
|
|
|
|
|
|
|
// create superuser
|
|
|
|
|
// set site name
|
|
|
|
|
// database
|
|
|
|
|
// redirect to the welcome page
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-05 13:36:01 -08:00
|
|
|
|
|
|
|
|
|
_notifier.Information(T("Setup succeeded"));
|
|
|
|
|
return RedirectToAction("Index");
|
2010-02-04 12:24:18 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|