-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #427 from sbwalker/master
Added ability to execute version specific code during framework upgrade (removed ApplicationVersion table and replaced with Version field on Tenant table), updated version number to 0.9.0 and renamed install scripts to match - this will be a baseline release which will be upgradeable
- Loading branch information
Showing
23 changed files
with
229 additions
and
144 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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 Oqtane.Models; | ||
|
||
namespace Oqtane.Infrastructure | ||
{ | ||
public interface IUpgradeManager | ||
{ | ||
void Upgrade(Tenant tenant, string version); | ||
} | ||
} |
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,93 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Oqtane.Extensions; | ||
using Oqtane.Models; | ||
using Oqtane.Repository; | ||
using Oqtane.Shared; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Oqtane.Infrastructure | ||
{ | ||
public class UpgradeManager : IUpgradeManager | ||
{ | ||
private readonly IAliasRepository _aliases; | ||
private readonly IServiceScopeFactory _serviceScopeFactory; | ||
|
||
public UpgradeManager(IAliasRepository aliases, IServiceScopeFactory serviceScopeFactory) | ||
{ | ||
_aliases = aliases; | ||
_serviceScopeFactory = serviceScopeFactory; | ||
} | ||
|
||
public void Upgrade(Tenant tenant, string version) | ||
{ | ||
// core framework upgrade logic - note that you can check if current tenant is Master if you only want to execute logic once | ||
var pageTemplates = new List<PageTemplate>(); | ||
|
||
switch (version) | ||
{ | ||
case "0.9.0": | ||
// add a page to all existing sites on upgrade | ||
|
||
//pageTemplates.Add(new PageTemplate | ||
//{ | ||
// Name = "Test", | ||
// Parent = "", | ||
// Path = "test", | ||
// Icon = Icons.Badge, | ||
// IsNavigation = true, | ||
// IsPersonalizable = false, | ||
// EditMode = false, | ||
// PagePermissions = new List<Permission> | ||
// { | ||
// new Permission(PermissionNames.View, Constants.AdminRole, true), | ||
// new Permission(PermissionNames.View, Constants.AllUsersRole, true), | ||
// new Permission(PermissionNames.Edit, Constants.AdminRole, true) | ||
// }.EncodePermissions(), | ||
// PageTemplateModules = new List<PageTemplateModule> | ||
// { | ||
// new PageTemplateModule | ||
// { | ||
// ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Login.Index).ToModuleDefinitionName(), Title = "Test", Pane = "Content", | ||
// ModulePermissions = new List<Permission> | ||
// { | ||
// new Permission(PermissionNames.View, Constants.AdminRole, true), | ||
// new Permission(PermissionNames.View, Constants.AllUsersRole, true), | ||
// new Permission(PermissionNames.Edit, Constants.AdminRole, true) | ||
// }.EncodePermissions(), | ||
// Content = "" | ||
// } | ||
// } | ||
//}); | ||
CreateSitePages(tenant, pageTemplates); | ||
break; | ||
} | ||
} | ||
|
||
private void CreateSitePages(Tenant tenant, List<PageTemplate> pageTemplates) | ||
{ | ||
if (pageTemplates.Count != 0) | ||
{ | ||
var processed = new List<Site>(); | ||
foreach (Alias alias in _aliases.GetAliases().Where(item => item.TenantId == tenant.TenantId)) | ||
{ | ||
if (!processed.Exists(item => item.SiteId == alias.SiteId)) | ||
{ | ||
using (var scope = _serviceScopeFactory.CreateScope()) | ||
{ | ||
var siteState = scope.ServiceProvider.GetRequiredService<SiteState>(); | ||
siteState.Alias = alias; | ||
var sites = scope.ServiceProvider.GetRequiredService<ISiteRepository>(); | ||
var site = sites.GetSite(alias.SiteId); | ||
if (site != null) | ||
{ | ||
sites.CreatePages(site, pageTemplates); | ||
} | ||
processed.Add(site); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.