mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
- Adding TenantState to the ShellSettings.
- Changes to the setup controller, multi tenancy controller/command handler to accomodate new ShellSettings like host,url prefix and state. - Integration tests. --HG-- branch : dev
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Orchard.MultiTenancy {
|
||||
public void GetNavigation(NavigationBuilder builder) {
|
||||
builder.Add("MultiTenancy", "2",
|
||||
menu => menu
|
||||
.Add("Manage Tenants", "1.0", item => item.Action("List", "Admin", new { area = "Orchard.MultiTenancy" }).Permission(Permissions.ManageTenants))
|
||||
.Add("Manage Tenants", "1.0", item => item.Action("Index", "Admin", new { area = "Orchard.MultiTenancy" }).Permission(Permissions.ManageTenants))
|
||||
.Add("Add New Tenant", "1.1", item => item.Action("Add", "Admin", new { area = "Orchard.MultiTenancy" }).Permission(Permissions.ManageTenants)));
|
||||
}
|
||||
}
|
||||
|
@@ -17,9 +17,6 @@ namespace Orchard.MultiTenancy.Commands {
|
||||
[OrchardSwitch]
|
||||
public string UrlPrefix { get; set; }
|
||||
|
||||
[OrchardSwitch]
|
||||
public string ConnectionString { get; set; }
|
||||
|
||||
[CommandHelp("tenant list: Display current tenants of a site")]
|
||||
[CommandName("tenant list")]
|
||||
public void List() {
|
||||
@@ -31,22 +28,25 @@ namespace Orchard.MultiTenancy.Commands {
|
||||
Context.Output.WriteLine(T("Name: ") + tenant.Name);
|
||||
Context.Output.WriteLine(T("Provider: ") + tenant.DataProvider);
|
||||
Context.Output.WriteLine(T("ConnectionString: ") + tenant.DataConnectionString);
|
||||
Context.Output.WriteLine(T("Prefix: ") + tenant.DataTablePrefix);
|
||||
Context.Output.WriteLine(T("Data Table Prefix: ") + tenant.DataTablePrefix);
|
||||
Context.Output.WriteLine(T("Request Url Host: ") + tenant.RequestUrlHost);
|
||||
Context.Output.WriteLine(T("Request Url Prefix: ") + tenant.RequestUrlPrefix);
|
||||
Context.Output.WriteLine(T("State: ") + tenant.State.ToString());
|
||||
Context.Output.WriteLine(T("---------------------------"));
|
||||
}
|
||||
}
|
||||
|
||||
[CommandHelp("tenant add <tenantName> <providerName> <dataPrefix> /ConnectionString:<SQL connection string> /Host:<hostname> /UrlPrefix:<url prefix>" +
|
||||
[CommandHelp("tenant add <tenantName> /Host:<hostname> /UrlPrefix:<url prefix>" +
|
||||
": create new tenant named <tenantName> on the site")]
|
||||
[CommandName("tenant add")]
|
||||
public void Create(string tenantName, string providerName, string prefix) {
|
||||
public void Create(string tenantName) {
|
||||
Context.Output.WriteLine(T("Creating tenant"));
|
||||
_tenantService.CreateTenant(
|
||||
new ShellSettings {
|
||||
Name = tenantName,
|
||||
DataProvider = providerName,
|
||||
DataConnectionString = ConnectionString,
|
||||
DataTablePrefix = prefix
|
||||
RequestUrlHost = Host,
|
||||
RequestUrlPrefix = UrlPrefix,
|
||||
State = new TenantState("Uninitialized")
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,7 +64,10 @@ namespace Orchard.MultiTenancy.Commands {
|
||||
Context.Output.WriteLine(T("Name: ") + tenant.Name);
|
||||
Context.Output.WriteLine(T("Provider: ") + tenant.DataProvider);
|
||||
Context.Output.WriteLine(T("ConnectionString: ") + tenant.DataConnectionString);
|
||||
Context.Output.WriteLine(T("Prefix: ") + tenant.DataTablePrefix);
|
||||
Context.Output.WriteLine(T("Data Table Prefix: ") + tenant.DataTablePrefix);
|
||||
Context.Output.WriteLine(T("Request Url Host: ") + tenant.RequestUrlHost);
|
||||
Context.Output.WriteLine(T("Request Url Prefix: ") + tenant.RequestUrlPrefix);
|
||||
Context.Output.WriteLine(T("State: ") + tenant.State.ToString());
|
||||
Context.Output.WriteLine(T("---------------------------"));
|
||||
}
|
||||
}
|
||||
|
@@ -21,11 +21,7 @@ namespace Orchard.MultiTenancy.Controllers {
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
public ActionResult Index() {
|
||||
return View("List", new TenantsListViewModel { TenantSettings = _tenantService.GetTenants() });
|
||||
}
|
||||
|
||||
public ActionResult List() {
|
||||
return View(new TenantsListViewModel { TenantSettings = _tenantService.GetTenants() });
|
||||
return View(new TenantsIndexViewModel { TenantSettings = _tenantService.GetTenants() });
|
||||
}
|
||||
|
||||
public ActionResult Add() {
|
||||
@@ -40,12 +36,12 @@ namespace Orchard.MultiTenancy.Controllers {
|
||||
_tenantService.CreateTenant(
|
||||
new ShellSettings {
|
||||
Name = viewModel.Name,
|
||||
DataProvider = viewModel.DataProvider,
|
||||
DataConnectionString = viewModel.ConnectionString,
|
||||
DataTablePrefix = viewModel.Prefix
|
||||
RequestUrlHost = viewModel.RequestUrlHost,
|
||||
RequestUrlPrefix = viewModel.RequestUrlPrefix,
|
||||
State = new TenantState("Uninitialized")
|
||||
});
|
||||
|
||||
return RedirectToAction("List");
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Services.Notifier.Error(T("Creating Tenant failed: ") + exception.Message);
|
||||
|
@@ -66,14 +66,14 @@
|
||||
<Compile Include="Services\ITenantService.cs" />
|
||||
<Compile Include="Services\TenantService.cs" />
|
||||
<Compile Include="ViewModels\TenantsAddViewModel.cs" />
|
||||
<Compile Include="ViewModels\TenantsListViewModel.cs" />
|
||||
<Compile Include="ViewModels\TenantsIndexViewModel.cs" />
|
||||
<Compile Include="Permissions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Module.txt" />
|
||||
<Content Include="Views\Admin\Add.ascx" />
|
||||
<Content Include="Views\Admin\List.ascx" />
|
||||
<Content Include="Views\Admin\Index.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
|
@@ -6,10 +6,8 @@ namespace Orchard.MultiTenancy.ViewModels {
|
||||
public class TenantsAddViewModel : BaseViewModel {
|
||||
[Required, DisplayName("Tenant Name:")]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public string DataProvider { get; set; }
|
||||
public string ConnectionString { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
public string RequestUrlHost { get; set; }
|
||||
public string RequestUrlPrefix { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ using Orchard.Environment.Configuration;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.MultiTenancy.ViewModels {
|
||||
public class TenantsListViewModel : BaseViewModel {
|
||||
public IEnumerable<ShellSettings> TenantSettings { get; set; }
|
||||
public class TenantsIndexViewModel : BaseViewModel {
|
||||
public IEnumerable<ShellSettings> TenantSettings { get; set; }
|
||||
}
|
||||
}
|
@@ -9,12 +9,10 @@
|
||||
<fieldset>
|
||||
<label for="Name"><%=_Encoded("Tenant Name") %></label>
|
||||
<input id="Name" class="textMedium" name="Name" type="text" /><br />
|
||||
<label for="DataProvider"><%=_Encoded("Data Provider Name") %></label>
|
||||
<input id="DataProvider" class="textMedium" name="DataProvider" type="text" /><br />
|
||||
<label for="Name"><%=_Encoded("Connection String") %></label>
|
||||
<input id="ConnectionString" class="textMedium" name="ConnectionString" type="text" /><br />
|
||||
<label for="Name"><%=_Encoded("Prefix") %></label>
|
||||
<input id="Prefix" class="textMedium" name="Prefix" type="text" /><br />
|
||||
<label for="RequestUrlHost"><%=_Encoded("Host Prefix") %></label>
|
||||
<input id="RequestUrlHost" class="textMedium" name="RequestUrlHost" type="text" /><br />
|
||||
<label for="RequestUrlPrefix"><%=_Encoded("Url Prefix") %></label>
|
||||
<input id="RequestUrlPrefix" class="textMedium" name="RequestUrlPrefix" type="text" /><br />
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<input type="submit" class="button primaryAction" value="<%=_Encoded("Save") %>" />
|
||||
|
@@ -1,21 +1,26 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<TenantsListViewModel>" %>
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<TenantsIndexViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<%@ Import Namespace="Orchard.MultiTenancy.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.ContentManagement"%>
|
||||
<h1><%=Html.TitleForPage(T("List of Site's Tenants").ToString())%></h1>
|
||||
<table class="items">
|
||||
<colgroup>
|
||||
<col id="Name" />
|
||||
<col id="Provider" />
|
||||
<col id="Data Provider" />
|
||||
<col id="ConnectionString" />
|
||||
<col id="Prefix" />
|
||||
<col id="TablePrefix" />
|
||||
<col id="RequestUrlHost" />
|
||||
<col id="RequestUrlPrefix" />
|
||||
<col id="TenantState" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<td scope="col"><%=_Encoded("Name") %></td>
|
||||
<td scope="col"><%=_Encoded("Provider") %></td>
|
||||
<td scope="col"><%=_Encoded("Data Provider") %></td>
|
||||
<td scope="col"><%=_Encoded("ConnectionString") %></td>
|
||||
<td scope="col"><%=_Encoded("Prefix") %></td>
|
||||
<td scope="col"><%=_Encoded("Table Prefix") %></td>
|
||||
<td scope="col"><%=_Encoded("Request Url Host") %></td>
|
||||
<td scope="col"><%=_Encoded("Request Url Prefix") %></td>
|
||||
<td scope="col"><%=_Encoded("State") %></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><%
|
||||
@@ -25,7 +30,10 @@
|
||||
<td><%= tenant.DataProvider %></td>
|
||||
<td><%= tenant.DataConnectionString %></td>
|
||||
<td><%= tenant.DataTablePrefix %></td>
|
||||
<td><%= tenant.RequestUrlHost %></td>
|
||||
<td><%= tenant.RequestUrlPrefix %></td>
|
||||
<td><%= tenant.State %></td>
|
||||
</tr><%
|
||||
} %>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
@@ -163,6 +163,7 @@ namespace Orchard.Setup.Controllers {
|
||||
}
|
||||
}
|
||||
|
||||
shellSettings.State = new TenantState("Running");
|
||||
_shellSettingsManager.SaveSettings(shellSettings);
|
||||
|
||||
_orchardHost.Reinitialize_Obsolete();
|
||||
|
Reference in New Issue
Block a user