mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-24 21:43:37 +08:00
- MultiTenancy module lists current tenants of the site.
- TenantService abstraction to list/add tenants. - TenantCommand and multitenancy admin controllers on top of the tenantservice. - Simple Tenant list UI for the backend. --HG-- branch : dev
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
using Orchard.Commands;
|
||||||
|
using Orchard.MultiTenancy.Services;
|
||||||
|
|
||||||
|
namespace Orchard.MultiTenancy.Commands {
|
||||||
|
public class TenantCommand : DefaultOrchardCommandHandler {
|
||||||
|
private readonly ITenantService _tenantService;
|
||||||
|
|
||||||
|
public TenantCommand(ITenantService tenantService) {
|
||||||
|
_tenantService = tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandHelp("tenant list: Display current tenants of a site")]
|
||||||
|
[CommandName("tenant list")]
|
||||||
|
public void List() {
|
||||||
|
Context.Output.WriteLine(T("List of tenants"));
|
||||||
|
Context.Output.WriteLine(T("---------------------------"));
|
||||||
|
|
||||||
|
var tenants = _tenantService.GetTenants();
|
||||||
|
foreach (var tenant in tenants) {
|
||||||
|
Context.Output.WriteLine(T("---------------------------"));
|
||||||
|
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.DataPrefix);
|
||||||
|
Context.Output.WriteLine(T("---------------------------"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,18 +1,26 @@
|
|||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
using Orchard.MultiTenancy.Services;
|
||||||
using Orchard.MultiTenancy.ViewModels;
|
using Orchard.MultiTenancy.ViewModels;
|
||||||
|
|
||||||
namespace Orchard.MultiTenancy.Controllers {
|
namespace Orchard.MultiTenancy.Controllers {
|
||||||
[ValidateInput(false)]
|
[ValidateInput(false)]
|
||||||
public class AdminController : Controller {
|
public class AdminController : Controller {
|
||||||
public AdminController() {
|
private readonly ITenantService _tenantService;
|
||||||
|
|
||||||
|
public AdminController(ITenantService tenantService) {
|
||||||
|
_tenantService = tenantService;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Localizer T { get; set; }
|
private Localizer T { get; set; }
|
||||||
|
|
||||||
public ActionResult List() {
|
public ActionResult List() {
|
||||||
return View(new TenantsListViewModel());
|
return View(new TenantsListViewModel { TenantSettings = _tenantService.GetTenants() });
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult Add() {
|
||||||
|
return View(new TenantsAddViewModel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -58,14 +58,19 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AdminMenu.cs" />
|
<Compile Include="AdminMenu.cs" />
|
||||||
|
<Compile Include="Commands\TenantCommand.cs" />
|
||||||
<Compile Include="Controllers\AdminController.cs" />
|
<Compile Include="Controllers\AdminController.cs" />
|
||||||
|
<Compile Include="Services\ITenantService.cs" />
|
||||||
|
<Compile Include="Services\TenantService.cs" />
|
||||||
|
<Compile Include="ViewModels\TenantsAddViewModel.cs" />
|
||||||
<Compile Include="ViewModels\TenantsListViewModel.cs" />
|
<Compile Include="ViewModels\TenantsListViewModel.cs" />
|
||||||
<Compile Include="Permissions.cs" />
|
<Compile Include="Permissions.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Module.txt" />
|
<Content Include="Module.txt" />
|
||||||
<Content Include="Views\Admin\List.aspx" />
|
<Content Include="Views\Admin\Add.aspx" />
|
||||||
|
<Content Include="Views\Admin\List.ascx" />
|
||||||
<Content Include="Web.config" />
|
<Content Include="Web.config" />
|
||||||
<Content Include="Views\Web.config" />
|
<Content Include="Views\Web.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -0,0 +1,8 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Orchard.Environment.Configuration;
|
||||||
|
|
||||||
|
namespace Orchard.MultiTenancy.Services {
|
||||||
|
public interface ITenantService : IDependency {
|
||||||
|
IEnumerable<ShellSettings> GetTenants();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,20 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Orchard.Environment.Configuration;
|
||||||
|
|
||||||
|
namespace Orchard.MultiTenancy.Services {
|
||||||
|
public class TenantService : ITenantService {
|
||||||
|
private readonly IShellSettingsManager _shellSettingsManager;
|
||||||
|
|
||||||
|
public TenantService(IShellSettingsManager shellSettingsManager) {
|
||||||
|
_shellSettingsManager = shellSettingsManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Implementation of ITenantService
|
||||||
|
|
||||||
|
public IEnumerable<ShellSettings> GetTenants() {
|
||||||
|
return _shellSettingsManager.LoadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,6 @@
|
|||||||
|
using Orchard.Mvc.ViewModels;
|
||||||
|
|
||||||
|
namespace Orchard.MultiTenancy.ViewModels {
|
||||||
|
public class TenantsAddViewModel : BaseViewModel {
|
||||||
|
}
|
||||||
|
}
|
@@ -1,6 +1,9 @@
|
|||||||
using Orchard.Mvc.ViewModels;
|
using System.Collections.Generic;
|
||||||
|
using Orchard.Environment.Configuration;
|
||||||
|
using Orchard.Mvc.ViewModels;
|
||||||
|
|
||||||
namespace Orchard.MultiTenancy.ViewModels {
|
namespace Orchard.MultiTenancy.ViewModels {
|
||||||
public class TenantsListViewModel : BaseViewModel {
|
public class TenantsListViewModel : BaseViewModel {
|
||||||
|
public IEnumerable<ShellSettings> TenantSettings { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<TenantsListViewModel>" %>
|
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<TenantsAddViewModel>" %>
|
||||||
<%@ Import Namespace="Orchard.MultiTenancy.ViewModels"%>
|
<%@ Import Namespace="Orchard.MultiTenancy.ViewModels"%>
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" >
|
<html xmlns="http://www.w3.org/1999/xhtml" >
|
||||||
<head runat="server">
|
<head id="Head1" runat="server">
|
||||||
<title>List</title>
|
<title>Add a new Tenant</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
Tenants
|
Add tenant...
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@@ -0,0 +1,31 @@
|
|||||||
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<TenantsListViewModel>" %>
|
||||||
|
<%@ 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="ConnectionString" />
|
||||||
|
<col id="Prefix" />
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td scope="col"><%=_Encoded("Name") %></td>
|
||||||
|
<td scope="col"><%=_Encoded("Provider") %></td>
|
||||||
|
<td scope="col"><%=_Encoded("ConnectionString") %></td>
|
||||||
|
<td scope="col"><%=_Encoded("Prefix") %></td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody><%
|
||||||
|
foreach (var tenant in Model.TenantSettings) { %>
|
||||||
|
<tr>
|
||||||
|
<td><%= tenant.Name %></td>
|
||||||
|
<td><%= tenant.DataProvider %></td>
|
||||||
|
<td><%= tenant.DataConnectionString %></td>
|
||||||
|
<td><%= tenant.DataPrefix %></td>
|
||||||
|
</tr><%
|
||||||
|
} %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
Reference in New Issue
Block a user