added logging for startup issues
This commit is contained in:
@ -14,10 +14,10 @@ using Microsoft.Extensions.Caching.Memory;
|
||||
using System.Net;
|
||||
using Oqtane.Repository;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -31,8 +31,9 @@ namespace Oqtane.Controllers
|
||||
private readonly IMemoryCache _cache;
|
||||
private readonly IHttpContextAccessor _accessor;
|
||||
private readonly IAliasRepository _aliases;
|
||||
private readonly ILogger<InstallationController> _filelogger;
|
||||
|
||||
public InstallationController(IConfigManager configManager, IInstallationManager installationManager, IDatabaseManager databaseManager, ILocalizationManager localizationManager, IMemoryCache cache, IHttpContextAccessor accessor, IAliasRepository aliases)
|
||||
public InstallationController(IConfigManager configManager, IInstallationManager installationManager, IDatabaseManager databaseManager, ILocalizationManager localizationManager, IMemoryCache cache, IHttpContextAccessor accessor, IAliasRepository aliases, ILogger<InstallationController> filelogger)
|
||||
{
|
||||
_configManager = configManager;
|
||||
_installationManager = installationManager;
|
||||
@ -41,6 +42,7 @@ namespace Oqtane.Controllers
|
||||
_cache = cache;
|
||||
_accessor = accessor;
|
||||
_aliases = aliases;
|
||||
_filelogger = filelogger;
|
||||
}
|
||||
|
||||
// POST api/<controller>
|
||||
@ -138,7 +140,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine($"Oqtane Error: The Satellite Assembly Folder For {culture} Does Not Exist");
|
||||
_filelogger.LogError(Utilities.LogMessage(this, $"The Satellite Assembly Folder For {culture} Does Not Exist"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,7 +158,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine($"Oqtane Error: Module {instance.ModuleDefinition.ModuleDefinitionName} Dependency {name}.dll Does Not Exist");
|
||||
_filelogger.LogError(Utilities.LogMessage(this, $"Module {instance.ModuleDefinition.ModuleDefinitionName} Dependency {name}.dll Does Not Exist"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -171,7 +173,7 @@ namespace Oqtane.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine($"Oqtane Error: Theme {instance.Theme.ThemeName} Dependency {name}.dll Does Not Exist");
|
||||
_filelogger.LogError(Utilities.LogMessage(this, $"Theme {instance.Theme.ThemeName} Dependency {name}.dll Does Not Exist"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,6 +194,14 @@ namespace Oqtane.Controllers
|
||||
if (module != null && module.SiteId == _alias.SiteId && _userPermissions.IsAuthorized(User, EntityNames.Module, module.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
content = _modules.ExportModule(moduleid);
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Read, "Module Content Exported {ModuleId}", moduleid);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Warning, this, LogFunction.Read, "No Module Content Exported {ModuleId}", moduleid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -213,6 +221,14 @@ namespace Oqtane.Controllers
|
||||
if (ModelState.IsValid && module != null && module.SiteId == _alias.SiteId && _userPermissions.IsAuthorized(User, EntityNames.Module, module.ModuleId, PermissionNames.Edit))
|
||||
{
|
||||
success = _modules.ImportModule(moduleid, content);
|
||||
if (success)
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "Module Content Imported {ModuleId}", moduleid);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Warning, this, LogFunction.Update, "Module Content Import Failed {ModuleId}", moduleid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -58,6 +58,7 @@ namespace Oqtane.Controllers
|
||||
{
|
||||
if (_userPermissions.IsAuthorized(User, PermissionNames.Utilize, moduledefinition.Permissions))
|
||||
{
|
||||
if (string.IsNullOrEmpty(moduledefinition.Version)) moduledefinition.Version = new Version(1, 0, 0).ToString();
|
||||
moduledefinitions.Add(moduledefinition);
|
||||
}
|
||||
}
|
||||
@ -81,6 +82,7 @@ namespace Oqtane.Controllers
|
||||
ModuleDefinition moduledefinition = _moduleDefinitions.GetModuleDefinition(id, SiteId);
|
||||
if (_userPermissions.IsAuthorized(User, PermissionNames.Utilize, moduledefinition.Permissions))
|
||||
{
|
||||
if (string.IsNullOrEmpty(moduledefinition.Version)) moduledefinition.Version = new Version(1, 0, 0).ToString();
|
||||
return moduledefinition;
|
||||
}
|
||||
else
|
||||
@ -164,25 +166,38 @@ namespace Oqtane.Controllers
|
||||
if (!string.IsNullOrEmpty(moduledefinition.ServerManagerType))
|
||||
{
|
||||
Type moduletype = Type.GetType(moduledefinition.ServerManagerType);
|
||||
foreach (Tenant tenant in _tenants.GetTenants())
|
||||
if (moduletype != null)
|
||||
{
|
||||
try
|
||||
var alias = _tenantManager.GetAlias(); // save current
|
||||
string result = string.Empty;
|
||||
foreach (Tenant tenant in _tenants.GetTenants())
|
||||
{
|
||||
if (moduletype.GetInterface("IInstallable") != null)
|
||||
try
|
||||
{
|
||||
_tenantManager.SetTenant(tenant.TenantId);
|
||||
var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype);
|
||||
((IInstallable)moduleobject).Uninstall(tenant);
|
||||
if (moduletype.GetInterface("IInstallable") != null)
|
||||
{
|
||||
_tenantManager.SetTenant(tenant.TenantId);
|
||||
var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype);
|
||||
((IInstallable)moduleobject).Uninstall(tenant);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sql.ExecuteScript(tenant, moduletype.Assembly, Utilities.GetTypeName(moduledefinition.ModuleDefinitionName) + ".Uninstall.sql");
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
_sql.ExecuteScript(tenant, moduletype.Assembly, Utilities.GetTypeName(moduledefinition.ModuleDefinitionName) + ".Uninstall.sql");
|
||||
result = "For " + tenant.Name + " " + ex.Message;
|
||||
}
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "{ModuleDefinitionName} Uninstalled For Tenant {Tenant}", moduledefinition.ModuleDefinitionName, tenant.Name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
_tenantManager.SetAlias(alias); // restore current
|
||||
if (string.IsNullOrEmpty(result))
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Delete, "Error Uninstalling {ModuleDefinitionName} For Tenant {Tenant} {Error}", moduledefinition.ModuleDefinitionName, tenant.Name, ex.Message);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "{ModuleDefinitionName} Uninstalled For All Tenants", moduledefinition.ModuleDefinitionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, this, LogFunction.Delete, "Error Uninstalling {ModuleDefinitionName} {Error}", moduledefinition.ModuleDefinitionName, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user