ability to specify PageTemplates for modules
This commit is contained in:
@ -199,10 +199,6 @@ namespace Oqtane.Infrastructure
|
||||
if (result.Success)
|
||||
{
|
||||
result = CreateSite(install);
|
||||
if (result.Success)
|
||||
{
|
||||
result = MigrateSites();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -685,77 +681,6 @@ namespace Oqtane.Infrastructure
|
||||
return result;
|
||||
}
|
||||
|
||||
private Installation MigrateSites()
|
||||
{
|
||||
var result = new Installation { Success = false, Message = string.Empty };
|
||||
|
||||
// get site upgrades
|
||||
Dictionary<string, Type> siteupgrades = new Dictionary<string, Type>();
|
||||
var assemblies = AppDomain.CurrentDomain.GetOqtaneAssemblies();
|
||||
foreach (Assembly assembly in assemblies)
|
||||
{
|
||||
foreach (var type in assembly.GetTypes(typeof(ISiteMigration)))
|
||||
{
|
||||
if (Attribute.IsDefined(type, typeof(SiteMigrationAttribute)))
|
||||
{
|
||||
var attribute = (SiteMigrationAttribute)Attribute.GetCustomAttribute(type, typeof(SiteMigrationAttribute));
|
||||
siteupgrades.Add(attribute.AliasName + " " + attribute.Version, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// execute site upgrades
|
||||
if (siteupgrades.Count > 0)
|
||||
{
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
var aliases = scope.ServiceProvider.GetRequiredService<IAliasRepository>();
|
||||
var tenantManager = scope.ServiceProvider.GetRequiredService<ITenantManager>();
|
||||
var sites = scope.ServiceProvider.GetRequiredService<ISiteRepository>();
|
||||
var logger = scope.ServiceProvider.GetRequiredService<ILogManager>();
|
||||
|
||||
foreach (var alias in aliases.GetAliases().ToList().Where(item => item.IsDefault))
|
||||
{
|
||||
foreach (var upgrade in siteupgrades)
|
||||
{
|
||||
var aliasname = upgrade.Key.Split(' ').First();
|
||||
// in the future this equality condition could use RegEx to allow for more flexible matching
|
||||
if (string.Equals(alias.Name, aliasname, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
tenantManager.SetTenant(alias.TenantId);
|
||||
var site = sites.GetSites().FirstOrDefault(item => item.SiteId == alias.SiteId);
|
||||
if (site != null)
|
||||
{
|
||||
var version = upgrade.Key.Split(' ').Last();
|
||||
if (string.IsNullOrEmpty(site.Version) || Version.Parse(version) > Version.Parse(site.Version))
|
||||
{
|
||||
try
|
||||
{
|
||||
var obj = ActivatorUtilities.CreateInstance(scope.ServiceProvider, upgrade.Value) as ISiteMigration;
|
||||
if (obj != null)
|
||||
{
|
||||
obj.Up(site, alias);
|
||||
site.Version = version;
|
||||
sites.UpdateSite(site);
|
||||
logger.Log(alias.SiteId, Shared.LogLevel.Information, "Site Migration", LogFunction.Other, "Site Migrated Successfully To Version {version} For {Alias}", version, alias.Name);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Log(alias.SiteId, Shared.LogLevel.Error, "Site Migration", LogFunction.Other, ex, "An Error Occurred Executing Site Migration {Type} For {Alias} And Version {Version}", upgrade.Value, alias.Name, version);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.Success = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
private string DenormalizeConnectionString(string connectionString)
|
||||
{
|
||||
var dataDirectory = AppDomain.CurrentDomain.GetData(Constants.DataDirectory)?.ToString();
|
||||
|
Reference in New Issue
Block a user