Merge branch 'master' into PermissionOptimalization
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
using System.Data.SqlClient;
|
||||
using System.Reflection;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public interface ISqlRepository
|
||||
{
|
||||
bool ExecuteEmbeddedScript(Assembly assembly, string script);
|
||||
void ExecuteScript(Tenant tenant, string script);
|
||||
int ExecuteNonQuery(Tenant tenant, string query);
|
||||
SqlDataReader ExecuteReader(Tenant tenant, string query);
|
||||
|
@ -188,18 +188,15 @@ namespace Oqtane.Repository
|
||||
{
|
||||
Name = moduleType.Substring(moduleType.LastIndexOf(".") + 1),
|
||||
Description = "Manage " + moduleType.Substring(moduleType.LastIndexOf(".") + 1),
|
||||
Categories = ((qualifiedModuleType.StartsWith("Oqtane.Modules.Admin.")) ? "Admin" : ""),
|
||||
Version = "1.0.0"
|
||||
Categories = ((qualifiedModuleType.StartsWith("Oqtane.Modules.Admin.")) ? "Admin" : "")
|
||||
};
|
||||
}
|
||||
// set internal properties
|
||||
moduledefinition.ModuleDefinitionName = qualifiedModuleType;
|
||||
moduledefinition.Version = ""; // will be populated from database
|
||||
moduledefinition.ControlTypeTemplate = moduleType + "." + Constants.ActionToken + ", " + typename[1];
|
||||
moduledefinition.AssemblyName = assembly.GetName().Name;
|
||||
if (assembly.FullName.StartsWith("Oqtane.Client"))
|
||||
{
|
||||
moduledefinition.Version = Constants.Version;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(moduledefinition.Categories))
|
||||
{
|
||||
moduledefinition.Categories = "Common";
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -20,7 +19,6 @@ namespace Oqtane.Repository
|
||||
private readonly IRoleRepository _roleRepository;
|
||||
private readonly IProfileRepository _profileRepository;
|
||||
private readonly IFolderRepository _folderRepository;
|
||||
private readonly IFileRepository _fileRepository;
|
||||
private readonly IPageRepository _pageRepository;
|
||||
private readonly IModuleRepository _moduleRepository;
|
||||
private readonly IPageModuleRepository _pageModuleRepository;
|
||||
@ -30,15 +28,14 @@ namespace Oqtane.Repository
|
||||
|
||||
private readonly IConfigurationRoot _config;
|
||||
|
||||
public SiteRepository(TenantDBContext context, IRoleRepository roleRepository, IProfileRepository profileRepository, IFolderRepository folderRepository, IFileRepository fileRepository, IPageRepository pageRepository,
|
||||
IModuleRepository moduleRepository, IPageModuleRepository pageModuleRepository, IModuleDefinitionRepository moduleDefinitionRepository, IPermissionRepository permissionRepository, IServiceProvider serviceProvider,
|
||||
public SiteRepository(TenantDBContext context, IRoleRepository roleRepository, IProfileRepository profileRepository, IFolderRepository folderRepository, IPageRepository pageRepository,
|
||||
IModuleRepository moduleRepository, IPageModuleRepository pageModuleRepository, IModuleDefinitionRepository moduleDefinitionRepository, IServiceProvider serviceProvider,
|
||||
IConfigurationRoot config)
|
||||
{
|
||||
_db = context;
|
||||
_roleRepository = roleRepository;
|
||||
_profileRepository = profileRepository;
|
||||
_folderRepository = folderRepository;
|
||||
_fileRepository = fileRepository;
|
||||
_pageRepository = pageRepository;
|
||||
_moduleRepository = moduleRepository;
|
||||
_pageModuleRepository = pageModuleRepository;
|
||||
@ -787,7 +784,14 @@ namespace Oqtane.Repository
|
||||
if (moduletype != null && moduletype.GetInterface("IPortable") != null)
|
||||
{
|
||||
var moduleobject = ActivatorUtilities.CreateInstance(_serviceProvider, moduletype);
|
||||
((IPortable) moduleobject).ImportModule(module, pagetemplatemodule.Content, moduledefinition.Version);
|
||||
try
|
||||
{
|
||||
((IPortable)moduleobject).ImportModule(module, pagetemplatemodule.Content, moduledefinition.Version);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// error in module import
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,61 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public class SqlRepository : ISqlRepository
|
||||
{
|
||||
private readonly ITenantRepository _tenants;
|
||||
|
||||
public SqlRepository(ITenantRepository tenants)
|
||||
{
|
||||
_tenants = tenants;
|
||||
}
|
||||
|
||||
public bool ExecuteEmbeddedScript(Assembly assembly, string filename)
|
||||
{
|
||||
// script must be included as an Embedded Resource within an assembly
|
||||
bool success = true;
|
||||
string uninstallScript = "";
|
||||
|
||||
if (assembly != null)
|
||||
{
|
||||
string name = assembly.GetManifestResourceNames().FirstOrDefault(item => item.EndsWith("." + filename));
|
||||
if (name != null)
|
||||
{
|
||||
Stream resourceStream = assembly.GetManifestResourceStream(name);
|
||||
if (resourceStream != null)
|
||||
{
|
||||
using (var reader = new StreamReader(resourceStream))
|
||||
{
|
||||
uninstallScript = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(uninstallScript))
|
||||
{
|
||||
foreach (Tenant tenant in _tenants.GetTenants())
|
||||
{
|
||||
try
|
||||
{
|
||||
ExecuteScript(tenant, uninstallScript);
|
||||
}
|
||||
catch
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
public void ExecuteScript(Tenant tenant, string script)
|
||||
{
|
||||
|
Reference in New Issue
Block a user