-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
NEST-326: Maintenance tasks for tenants
- Loading branch information
Showing
33 changed files
with
803 additions
and
1 deletion.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
Lombiq.Hosting.Tenants.Maintenance.Tests.UI/Extensions/MaintenanceExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Lombiq.Tests.UI.Services; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lombiq.Hosting.Tenants.Maintenance.Tests.UI.Extensions; | ||
|
||
public static class MaintenanceExtensions | ||
{ | ||
public static void SetUpdateSiteUrlMaintenanceConfiguration( | ||
this OrchardCoreUITestExecutorConfiguration configuration) => configuration.OrchardCoreConfiguration.BeforeAppStart += | ||
(_, argumentsBuilder) => | ||
{ | ||
argumentsBuilder | ||
.AddWithValue( | ||
"OrchardCore:Lombiq_Hosting_Tenants_Maintenance:UpdateSiteUrl:IsEnabled", | ||
value: true) | ||
.AddWithValue( | ||
"OrchardCore:Lombiq_Hosting_Tenants_Maintenance:UpdateSiteUrl:DefaultTenantSiteUrl", | ||
value: "https://test.com"); | ||
|
||
return Task.CompletedTask; | ||
}; | ||
} |
18 changes: 18 additions & 0 deletions
18
Lombiq.Hosting.Tenants.Maintenance.Tests.UI/Extensions/TestCaseUITestContextExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Atata; | ||
using Lombiq.Tests.UI.Extensions; | ||
using Lombiq.Tests.UI.Services; | ||
using OpenQA.Selenium; | ||
using Shouldly; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lombiq.Hosting.Tenants.Maintenance.Tests.UI.Extensions; | ||
|
||
public static class TestCaseUITestContextExtensions | ||
{ | ||
public static async Task TestSiteUrlMaintenanceExecution(this UITestContext context) | ||
{ | ||
await context.SignInDirectlyAsync(); | ||
await context.GoToAdminRelativeUrlAsync("/Settings/general"); | ||
context.Get(By.Name("ISite.BaseUrl")).GetValue().ShouldBe("https://test.com"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright © 2021, [Lombiq Technologies Ltd.](https://lombiq.com) | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 changes: 33 additions & 0 deletions
33
...q.Hosting.Tenants.Maintenance.Tests.UI/Lombiq.Hosting.Tenants.Maintenance.Tests.UI.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<Title>Lombiq Hosting - Tenants Maintenance for Orchard Core - UI Test Extensions</Title> | ||
<Authors>Lombiq Technologies</Authors> | ||
<Copyright>Copyright © 2021, Lombiq Technologies Ltd.</Copyright> | ||
<Description>Lombiq Hosting - Tenants Maintenance for Orchard Core - UI Test Extensions: Extension methods that test tenants maintenance for Orchard Core.</Description> | ||
<PackageIcon>NuGetIcon.png</PackageIcon> | ||
<PackageTags>OrchardCore;Lombiq;AspNetCore;Multitenancy;SaaS</PackageTags> | ||
<RepositoryUrl>https://github.com/Lombiq/Hosting-Tenants</RepositoryUrl> | ||
<PackageProjectUrl>https://github.com/Lombiq/Hosting-Tenants/blob/dev/Lombiq.Hosting.Tenants.Maintenance.Tests.UI/Readme.md</PackageProjectUrl> | ||
<PackageLicenseFile>License.md</PackageLicenseFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="'$(NuGetBuild)' != 'true'"> | ||
<ProjectReference Include="..\..\..\..\test\Lombiq.UITestingToolbox\Lombiq.Tests.UI\Lombiq.Tests.UI.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(NuGetBuild)' == 'true'"> | ||
<PackageReference Include="Lombiq.Tests.UI" Version="6.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="License.md" Pack="true" PackagePath="" /> | ||
<None Include="NuGetIcon.png" Pack="true" PackagePath="" /> | ||
<None Include="Readme.md" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Lombiq Hosting - Tenants Maintenance for Orchard Core - UI Test Extensions | ||
|
||
## About | ||
|
||
Extension methods that test tenants maintenance for Orchard Core, with the help of [Lombiq UI Testing Toolbox for Orchard Core](https://github.com/Lombiq/UI-Testing-Toolbox). | ||
|
||
Call these from a UI test project to verify the module's basic features; as seen in [Open-Source Orchard Core Extensions](https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions). |
6 changes: 6 additions & 0 deletions
6
Lombiq.Hosting.Tenants.Maintenance/Constants/DocumentCollections.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Lombiq.Hosting.Tenants.Maintenance.Constants; | ||
|
||
public static class DocumentCollections | ||
{ | ||
public const string Maintenance = nameof(Maintenance); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Lombiq.Hosting.Tenants.Maintenance.Constants; | ||
|
||
public static class FeatureNames | ||
{ | ||
public const string Module = "Lombiq.Hosting.Tenants.Maintenance"; | ||
public const string Maintenance = Module; | ||
public const string UpdateSiteUrl = Maintenance + "." + nameof(UpdateSiteUrl); | ||
public const string UpdateShellRequestUrls = Maintenance + "." + nameof(UpdateShellRequestUrls); | ||
} |
9 changes: 9 additions & 0 deletions
9
Lombiq.Hosting.Tenants.Maintenance/Extensions/MaintenanceTaskExecutionContextExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Lombiq.Hosting.Tenants.Maintenance.Models; | ||
|
||
namespace Lombiq.Hosting.Tenants.Maintenance.Extensions; | ||
|
||
public static class MaintenanceTaskExecutionContextExtensions | ||
{ | ||
public static bool WasLatestExecutionSuccessful(this MaintenanceTaskExecutionContext execution) => | ||
execution.LatestExecution?.IsSuccess == true; | ||
} |
25 changes: 25 additions & 0 deletions
25
Lombiq.Hosting.Tenants.Maintenance/Helpers/TenantUrlHelpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using OrchardCore.Environment.Shell; | ||
|
||
namespace Lombiq.Hosting.Tenants.Maintenance.Helpers; | ||
|
||
internal static class TenantUrlHelpers | ||
{ | ||
public static string ReplaceTenantName(string url, string tenantName) => | ||
// Evaluate the tenant name in lowercase as it will be used in the URL or request URL prefixes. | ||
#pragma warning disable CA1308 // Normalize strings to uppercase | ||
url?.Replace("{TenantName}", tenantName.ToLowerInvariant()); | ||
#pragma warning restore CA1308 // Normalize strings to uppercase | ||
|
||
public static string GetTenantUrl(string urlForDefaultTenant, string urlForAnyTenant, ShellSettings shellSettings) | ||
{ | ||
var evaluatedRequestUrl = !string.IsNullOrEmpty(urlForAnyTenant) | ||
? ReplaceTenantName(urlForAnyTenant, shellSettings.Name) | ||
: string.Empty; | ||
var defaultShellRequestUrl = | ||
string.IsNullOrEmpty(urlForDefaultTenant) | ||
? evaluatedRequestUrl | ||
: urlForDefaultTenant; | ||
|
||
return shellSettings.IsDefaultShell() ? defaultShellRequestUrl : evaluatedRequestUrl; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
Lombiq.Hosting.Tenants.Maintenance/Indexes/MaintenanceTaskExecutionIndex.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Lombiq.Hosting.Tenants.Maintenance.Constants; | ||
using Lombiq.Hosting.Tenants.Maintenance.Models; | ||
using System; | ||
using YesSql.Indexes; | ||
|
||
namespace Lombiq.Hosting.Tenants.Maintenance.Indexes; | ||
|
||
public class MaintenanceTaskExecutionIndex : MapIndex | ||
{ | ||
public string MaintenanceId { get; set; } | ||
public DateTime ExecutionTimeUtc { get; set; } | ||
public bool IsSuccess { get; set; } | ||
} | ||
|
||
public class MaintenanceTaskExecutionIndexProvider : IndexProvider<MaintenanceTaskExecutionData> | ||
{ | ||
public MaintenanceTaskExecutionIndexProvider() => | ||
CollectionName = DocumentCollections.Maintenance; | ||
|
||
public override void Describe(DescribeContext<MaintenanceTaskExecutionData> context) => | ||
context.For<MaintenanceTaskExecutionIndex>() | ||
.Map(execution => new MaintenanceTaskExecutionIndex | ||
{ | ||
MaintenanceId = execution.MaintenanceId, | ||
ExecutionTimeUtc = execution.ExecutionTimeUtc, | ||
IsSuccess = execution.IsSuccess, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright © 2021, [Lombiq Technologies Ltd.](https://lombiq.com) | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
- Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
44 changes: 44 additions & 0 deletions
44
Lombiq.Hosting.Tenants.Maintenance/Lombiq.Hosting.Tenants.Maintenance.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<AddRazorSupportForMvc>true</AddRazorSupportForMvc> | ||
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**;Tests\**</DefaultItemExcludes> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<Title>Lombiq Hosting - Tenants Maintenance for Orchard Core</Title> | ||
<Authors>Lombiq Technologies</Authors> | ||
<Copyright>Copyright © 2021, Lombiq Technologies Ltd.</Copyright> | ||
<Description>Lombiq Hosting - Tenants Maintenance for Orchard Core: With the help of this module you can execute maintenance tasks on tenants.</Description> | ||
<PackageIcon>NuGetIcon.png</PackageIcon> | ||
<PackageTags>OrchardCore;Lombiq;AspNetCore;Multitenancy;SaaS;Maintenance</PackageTags> | ||
<RepositoryUrl>https://github.com/Lombiq/Hosting-Tenants</RepositoryUrl> | ||
<PackageProjectUrl>https://github.com/Lombiq/Hosting-Tenants/blob/dev/Lombiq.Hosting.Tenants.Maintenance/Readme.md</PackageProjectUrl> | ||
<PackageLicenseFile>License.md</PackageLicenseFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="OrchardCore.Module.Targets" Version="1.5.0" /> | ||
<PackageReference Include="OrchardCore.ContentManagement" Version="1.5.0" /> | ||
<PackageReference Include="OrchardCore.ContentTypes.Abstractions" Version="1.5.0" /> | ||
<PackageReference Include="OrchardCore.DisplayManagement" Version="1.5.0" /> | ||
<PackageReference Include="OrchardCore.Settings" Version="1.5.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="License.md" Pack="true" PackagePath="" /> | ||
<None Include="Readme.md" /> | ||
<None Include="NuGetIcon.png" Pack="true" PackagePath="" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="node_modules\**" /> | ||
<None Remove="Tests\**" /> | ||
</ItemGroup> | ||
|
||
</Project> |
27 changes: 27 additions & 0 deletions
27
Lombiq.Hosting.Tenants.Maintenance/Maintenance/UpdateShellRequestUrl/Startup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Lombiq.Hosting.Tenants.Maintenance.Constants; | ||
using Lombiq.Hosting.Tenants.Maintenance.Services; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using OrchardCore.Environment.Shell.Configuration; | ||
using OrchardCore.Modules; | ||
|
||
namespace Lombiq.Hosting.Tenants.Maintenance.Maintenance.UpdateShellRequestUrl; | ||
|
||
[Feature(FeatureNames.UpdateShellRequestUrls)] | ||
public class Startup : StartupBase | ||
{ | ||
private readonly IShellConfiguration _shellConfiguration; | ||
|
||
public Startup(IShellConfiguration shellConfiguration) => | ||
_shellConfiguration = shellConfiguration; | ||
|
||
public override void ConfigureServices(IServiceCollection services) | ||
{ | ||
var options = new UpdateShellRequestUrlMaintenanceOptions(); | ||
var configSection = _shellConfiguration.GetSection("Lombiq_Hosting_Tenants_Maintenance:UpdateShellRequestUrl"); | ||
configSection.Bind(options); | ||
services.Configure<UpdateShellRequestUrlMaintenanceOptions>(configSection); | ||
|
||
services.AddScoped<IMaintenanceProvider, UpdateShellRequestUrlsMaintenanceProvider>(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
....Maintenance/Maintenance/UpdateShellRequestUrl/UpdateShellRequestUrlMaintenanceOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Lombiq.Hosting.Tenants.Maintenance.Maintenance.UpdateShellRequestUrl; | ||
|
||
public class UpdateShellRequestUrlMaintenanceOptions | ||
{ | ||
public bool IsEnabled { get; set; } | ||
public string DefaultShellRequestUrl { get; set; } | ||
public string RequestUrl { get; set; } | ||
public string RequestUrlPrefix { get; set; } | ||
} |
50 changes: 50 additions & 0 deletions
50
...aintenance/Maintenance/UpdateShellRequestUrl/UpdateShellRequestUrlsMaintenanceProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Lombiq.Hosting.Tenants.Maintenance.Extensions; | ||
using Lombiq.Hosting.Tenants.Maintenance.Helpers; | ||
using Lombiq.Hosting.Tenants.Maintenance.Models; | ||
using Lombiq.Hosting.Tenants.Maintenance.Services; | ||
using Microsoft.Extensions.Options; | ||
using OrchardCore.Environment.Shell; | ||
using System.Threading.Tasks; | ||
|
||
namespace Lombiq.Hosting.Tenants.Maintenance.Maintenance.UpdateShellRequestUrl; | ||
|
||
public class UpdateShellRequestUrlsMaintenanceProvider : MaintenanceProviderBase | ||
{ | ||
private readonly ShellSettings _shellSettings; | ||
private readonly IOptions<UpdateShellRequestUrlMaintenanceOptions> _options; | ||
private readonly IShellSettingsManager _shellSettingsManager; | ||
|
||
public UpdateShellRequestUrlsMaintenanceProvider( | ||
ShellSettings shellSettings, | ||
IOptions<UpdateShellRequestUrlMaintenanceOptions> options, | ||
IShellSettingsManager shellSettingsManager) | ||
{ | ||
_shellSettings = shellSettings; | ||
_options = options; | ||
_shellSettingsManager = shellSettingsManager; | ||
} | ||
|
||
public override Task<bool> ShouldExecuteAsync(MaintenanceTaskExecutionContext context) => | ||
Task.FromResult(_options.Value.IsEnabled && | ||
_shellSettings.IsDefaultShell() && | ||
!context.WasLatestExecutionSuccessful()); | ||
|
||
public override async Task ExecuteAsync(MaintenanceTaskExecutionContext context) | ||
{ | ||
var allShellSettings = await _shellSettingsManager.LoadSettingsAsync(); | ||
foreach (var shellSettings in allShellSettings) | ||
{ | ||
shellSettings.RequestUrlHost = TenantUrlHelpers.GetTenantUrl( | ||
_options.Value.DefaultShellRequestUrl, | ||
_options.Value.RequestUrl, | ||
shellSettings); | ||
shellSettings.RequestUrlPrefix = TenantUrlHelpers.ReplaceTenantName( | ||
_options.Value.RequestUrlPrefix, | ||
shellSettings.Name); | ||
|
||
await _shellSettingsManager.SaveSettingsAsync(shellSettings); | ||
} | ||
|
||
context.ReloadShellAfterMaintenanceCompletion = true; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
Lombiq.Hosting.Tenants.Maintenance/Maintenance/UpdateSiteUrl/Startup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Lombiq.Hosting.Tenants.Maintenance.Constants; | ||
using Lombiq.Hosting.Tenants.Maintenance.Services; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using OrchardCore.Environment.Shell.Configuration; | ||
using OrchardCore.Modules; | ||
|
||
namespace Lombiq.Hosting.Tenants.Maintenance.Maintenance.UpdateSiteUrl; | ||
|
||
[Feature(FeatureNames.UpdateSiteUrl)] | ||
public class Startup : StartupBase | ||
{ | ||
private readonly IShellConfiguration _shellConfiguration; | ||
|
||
public Startup(IShellConfiguration shellConfiguration) => | ||
_shellConfiguration = shellConfiguration; | ||
|
||
public override void ConfigureServices(IServiceCollection services) | ||
{ | ||
var options = new UpdateSiteUrlMaintenanceOptions(); | ||
var configSection = _shellConfiguration.GetSection("Lombiq_Hosting_Tenants_Maintenance:UpdateSiteUrl"); | ||
configSection.Bind(options); | ||
services.Configure<UpdateSiteUrlMaintenanceOptions>(configSection); | ||
|
||
services.AddScoped<IMaintenanceProvider, UpdateSiteUrlMaintenanceProvider>(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
....Hosting.Tenants.Maintenance/Maintenance/UpdateSiteUrl/UpdateSiteUrlMaintenanceOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Lombiq.Hosting.Tenants.Maintenance.Maintenance.UpdateSiteUrl; | ||
|
||
public class UpdateSiteUrlMaintenanceOptions | ||
{ | ||
public bool IsEnabled { get; set; } | ||
public string DefaultTenantSiteUrl { get; set; } | ||
public string SiteUrl { get; set; } | ||
} |
Oops, something went wrong.