Page IsClickable column must be nullable in order to support upgrades, add more defensive logic
This commit is contained in:
@ -17,6 +17,7 @@ using Oqtane.Repository;
|
||||
using Oqtane.Shared;
|
||||
using Oqtane.Enums;
|
||||
using Newtonsoft.Json;
|
||||
using System.Diagnostics;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable ConvertToUsingDeclaration
|
||||
@ -55,16 +56,25 @@ namespace Oqtane.Infrastructure
|
||||
{
|
||||
try
|
||||
{
|
||||
// verify master database contains a Tenant table ( ie. validate schema is properly provisioned )
|
||||
var provisioned = db.Tenant.Any();
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Message = "Master Database Not Installed Correctly";
|
||||
result.Message = "Master Database Not Installed Correctly. " + ex.Message;
|
||||
}
|
||||
}
|
||||
else
|
||||
else // cannot connect
|
||||
{
|
||||
result.Message = "Cannot Connect To Master Database";
|
||||
try
|
||||
{
|
||||
// get the actual connection error details
|
||||
db.Database.OpenConnection();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Message = "Cannot Connect To Master Database. " + ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -127,6 +137,7 @@ namespace Oqtane.Infrastructure
|
||||
{
|
||||
if (!string.IsNullOrEmpty(installation.Message))
|
||||
{
|
||||
Debug.WriteLine($"Oqtane Error: {installation.Message}");
|
||||
// problem with prior installation
|
||||
install.ConnectionString = "";
|
||||
}
|
||||
|
@ -5,7 +5,9 @@ using Newtonsoft.Json;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Shared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@ -48,21 +50,25 @@ namespace Oqtane.Infrastructure
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// **Note: this code is commented out on purpose - it provides an example of how to programmatically add a page to all existing sites on upgrade
|
||||
/// </summary>
|
||||
/// <param name="tenant"></param>
|
||||
/// <param name="scope"></param>
|
||||
private void Upgrade_1_0_0(Tenant tenant, IServiceScope scope)
|
||||
{
|
||||
var pageTemplates = new List<PageTemplate>();
|
||||
|
||||
// **Note: this code is commented out on purpose - it provides an example of how to programmatically add a page to all existing sites on upgrade
|
||||
|
||||
//var pageTemplates = new List<PageTemplate>();
|
||||
//
|
||||
//pageTemplates.Add(new PageTemplate
|
||||
//{
|
||||
// Name = "Test",
|
||||
// Parent = "",
|
||||
// Order = 1,
|
||||
// Path = "test",
|
||||
// Icon = Icons.Badge,
|
||||
// IsNavigation = true,
|
||||
// IsPersonalizable = false,
|
||||
// EditMode = false,
|
||||
// IsClickable = true,
|
||||
// PagePermissions = new List<Permission>
|
||||
// {
|
||||
// new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||
@ -84,8 +90,15 @@ namespace Oqtane.Infrastructure
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
|
||||
CreateSitePages(scope, pageTemplates);
|
||||
//
|
||||
//if (pageTemplates.Count != 0)
|
||||
//{
|
||||
// var sites = scope.ServiceProvider.GetRequiredService<ISiteRepository>();
|
||||
// foreach (Site site in sites.GetSites().ToList())
|
||||
// {
|
||||
// sites.CreatePages(site, pageTemplates);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void Upgrade_2_0_2(Tenant tenant, IServiceScope scope)
|
||||
@ -100,19 +113,28 @@ namespace Oqtane.Infrastructure
|
||||
{
|
||||
Directory.Delete(internalTemplatePath, true);
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
// error deleting directory
|
||||
Debug.WriteLine($"Oqtane Error: Error In 2.0.2 Upgrade Logic - {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// initialize SiteGuid
|
||||
var sites = scope.ServiceProvider.GetRequiredService<ISiteRepository>();
|
||||
foreach (Site site in sites.GetSites().ToList())
|
||||
try
|
||||
{
|
||||
site.SiteGuid = System.Guid.NewGuid().ToString();
|
||||
sites.UpdateSite(site);
|
||||
var sites = scope.ServiceProvider.GetRequiredService<ISiteRepository>();
|
||||
foreach (Site site in sites.GetSites().ToList())
|
||||
{
|
||||
site.SiteGuid = System.Guid.NewGuid().ToString();
|
||||
sites.UpdateSite(site);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// error populating guid
|
||||
Debug.WriteLine($"Oqtane Error: Error In 2.0.2 Upgrade Logic - {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,16 +150,5 @@ namespace Oqtane.Infrastructure
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateSitePages(IServiceScope scope, List<PageTemplate> pageTemplates)
|
||||
{
|
||||
if (pageTemplates.Count != 0)
|
||||
{
|
||||
var sites = scope.ServiceProvider.GetRequiredService<ISiteRepository>();
|
||||
foreach (Site site in sites.GetSites().ToList())
|
||||
{
|
||||
sites.CreatePages(site, pageTemplates);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user