improved error handling, improved consistency of console error messages, added ability to add a Decimal column in Migrations
This commit is contained in:
parent
32c49f74d3
commit
3bc5744007
|
@ -15,6 +15,7 @@ using Microsoft.Extensions.Caching.Memory;
|
|||
using System.Net;
|
||||
using Oqtane.Repository;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -130,7 +131,7 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"The satellite assemblies folder named '{culture}' is not found.");
|
||||
Debug.WriteLine($"Oqtane Error: The Satellite Assembly Folder For {culture} Does Not Exist");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +149,7 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Module " + instance.ModuleDefinition.ModuleDefinitionName + " dependency " + name + ".dll does not exist");
|
||||
Debug.WriteLine($"Oqtane Error: Module {instance.ModuleDefinition.ModuleDefinitionName} Dependency {name}.dll Does Not Exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +164,7 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Theme " + instance.Theme.ThemeName + " dependency " + name + ".dll does not exist" );
|
||||
Debug.WriteLine($"Oqtane Error: Theme {instance.Theme.ThemeName} Dependency {name}.dll Does Not Exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
@ -257,7 +258,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine($"Not Assembly : {dll.Name}");
|
||||
Debug.WriteLine($"Oqtane Error: Cannot Get Assembly Name For {dll.Name}");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -298,24 +299,24 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine($"Not Satellite Assembly : {assemblyFile.Name}");
|
||||
Debug.WriteLine($"Oqtane Error: Cannot Get Satellite Assembly Name For {assemblyFile.Name}");
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Assembly assembly = AssemblyLoadContext.Default.LoadFromStream(new MemoryStream(File.ReadAllBytes(assemblyFile.FullName)));
|
||||
Console.WriteLine($"Loaded : {assemblyName}");
|
||||
Debug.WriteLine($"Oqtane Info: Loaded Assembly {assemblyName}");
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Failed : {assemblyName}\n{e}");
|
||||
Debug.WriteLine($"Oqtane Error: Unable To Load Assembly {assemblyName} - {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"The satellite assemblies folder named '{culture}' is not found.");
|
||||
Debug.WriteLine($"Oqtane Error: The Satellite Assembly Folder For {culture} Does Not Exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
|
@ -57,7 +58,7 @@ namespace Oqtane.Infrastructure
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error modifying app settings {0}", ex);
|
||||
Debug.WriteLine($"Oqtane Error: Error Updating App Setting {key} - {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +79,7 @@ namespace Oqtane.Infrastructure
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error modifying app settings {0}", ex);
|
||||
Debug.WriteLine($"Oqtane Error: Error Removing App Setting {key} - {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -483,11 +483,17 @@ namespace Oqtane.Infrastructure
|
|||
{
|
||||
tenantManager.SetTenant(tenant.TenantId);
|
||||
var moduleObject = ActivatorUtilities.CreateInstance(scope.ServiceProvider, moduleType) as IInstallable;
|
||||
moduleObject?.Install(tenant, versions[i]);
|
||||
if (moduleObject == null || !moduleObject.Install(tenant, versions[i]))
|
||||
{
|
||||
result.Message = "An Error Occurred Executing IInstallable Interface For " + moduleDefinition.ServerManagerType;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.ExecuteScript(tenant, moduleType.Assembly, Utilities.GetTypeName(moduleDefinition.ModuleDefinitionName) + "." + versions[i] + ".sql");
|
||||
if (!sql.ExecuteScript(tenant, moduleType.Assembly, Utilities.GetTypeName(moduleDefinition.ModuleDefinitionName) + "." + versions[i] + ".sql"))
|
||||
{
|
||||
result.Message = "An Error Occurred Executing Database Script " + Utilities.GetTypeName(moduleDefinition.ModuleDefinitionName) + "." + versions[i] + ".sql";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
|
@ -109,6 +110,16 @@ namespace Oqtane.Migrations.EntityBuilders
|
|||
_migrationBuilder.AlterColumn<string>(RewriteName(name), RewriteName(EntityTableName), maxLength: length, nullable: nullable, unicode: unicode);
|
||||
}
|
||||
|
||||
public void AddDecimalColumn(string name, int precision, int scale, bool nullable = false)
|
||||
{
|
||||
_migrationBuilder.AddColumn<decimal>(RewriteName(name), RewriteName(EntityTableName), nullable: nullable, precision: precision, scale: scale);
|
||||
}
|
||||
|
||||
protected OperationBuilder<AddColumnOperation> AddDecimalColumn(ColumnsBuilder table, string name, int precision, int scale, bool nullable = false)
|
||||
{
|
||||
return table.Column<decimal>(name: RewriteName(name), nullable: nullable, precision: precision, scale: scale);
|
||||
}
|
||||
|
||||
public void DropColumn(string name)
|
||||
{
|
||||
_migrationBuilder.DropColumn(RewriteName(name), RewriteName(EntityTableName));
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Oqtane.Enums;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Repository;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Modules
|
||||
{
|
||||
|
@ -28,9 +28,9 @@ namespace Oqtane.Modules
|
|||
migrator.Migrate();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
Debug.WriteLine($"Oqtane Error: Error Executing Migration - {ex}");
|
||||
result = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Oqtane.Infrastructure;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Oqtane.Server
|
||||
{
|
||||
|
@ -15,7 +16,11 @@ namespace Oqtane.Server
|
|||
using (var serviceScope = host.Services.GetRequiredService<IServiceScopeFactory>().CreateScope())
|
||||
{
|
||||
var databaseManager = serviceScope.ServiceProvider.GetService<IDatabaseManager>();
|
||||
databaseManager.Install();
|
||||
var install = databaseManager.Install();
|
||||
if (!string.IsNullOrEmpty(install.Message))
|
||||
{
|
||||
Debug.WriteLine($"Oqtane Error: {install.Message}");
|
||||
}
|
||||
}
|
||||
host.Run();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
@ -264,7 +265,7 @@ namespace Oqtane.Repository
|
|||
}.EncodePermissions();
|
||||
}
|
||||
|
||||
Console.WriteLine($"Registering module: {moduledefinition.ModuleDefinitionName}");
|
||||
Debug.WriteLine($"Oqtane Info: Registering Module {moduledefinition.ModuleDefinitionName}");
|
||||
moduledefinitions.Add(moduledefinition);
|
||||
index = moduledefinitions.FindIndex(item => item.ModuleDefinitionName == qualifiedModuleType);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
@ -104,6 +105,8 @@ namespace Oqtane.Repository
|
|||
{
|
||||
theme.PackageName = Utilities.GetTypeName(theme.ThemeName);
|
||||
}
|
||||
|
||||
Debug.WriteLine($"Oqtane Info: Registering Theme {theme.ThemeName}");
|
||||
themes.Add(theme);
|
||||
index = themes.FindIndex(item => item.ThemeName == qualifiedThemeType);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Loader;
|
||||
|
@ -100,7 +101,7 @@ namespace System.Reflection
|
|||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine($"Not Assembly : {dll.Name}");
|
||||
Debug.WriteLine($"Oqtane Error: Cannot Get Assembly Name For {dll.Name}");
|
||||
}
|
||||
|
||||
loadContext.LoadOqtaneAssembly(dll, assemblyName);
|
||||
|
@ -122,11 +123,11 @@ namespace System.Reflection
|
|||
{
|
||||
assembly = loadContext.LoadFromStream(new MemoryStream(File.ReadAllBytes(dll.FullName)));
|
||||
}
|
||||
Console.WriteLine($"Loaded : {assemblyName}");
|
||||
Debug.WriteLine($"Oqtane Info: Loaded Assembly {assemblyName}");
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Failed : {assemblyName}\n{e}");
|
||||
Debug.WriteLine($"Oqtane Error: Unable To Load Assembly {assemblyName} - {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user