added uninstall support for modules
This commit is contained in:
		| @ -5,6 +5,7 @@ namespace Oqtane.Repository | ||||
| { | ||||
|     public interface ISqlRepository | ||||
|     { | ||||
|         void ExecuteScript(Tenant tenant, string script); | ||||
|         int ExecuteNonQuery(Tenant tenant, string query); | ||||
|         SqlDataReader ExecuteReader(Tenant tenant, string query); | ||||
|     } | ||||
|  | ||||
| @ -15,6 +15,7 @@ namespace Oqtane.Repository | ||||
|         private MasterDBContext _db; | ||||
|         private readonly IMemoryCache _cache; | ||||
|         private readonly IPermissionRepository _permissions; | ||||
|         private List<ModuleDefinition> _moduleDefinitions; // lazy load | ||||
|  | ||||
|         public ModuleDefinitionRepository(MasterDBContext context, IMemoryCache cache, IPermissionRepository permissions) | ||||
|         { | ||||
| @ -61,12 +62,12 @@ namespace Oqtane.Repository | ||||
|  | ||||
|         private List<ModuleDefinition> LoadSiteModuleDefinitions(int siteId) | ||||
|         { | ||||
|             // get module assemblies  | ||||
|             List<ModuleDefinition> moduleDefinitions = _cache.GetOrCreate("moduledefinitions", entry => | ||||
|             if (_moduleDefinitions == null) | ||||
|             { | ||||
|                 entry.SlidingExpiration = TimeSpan.FromMinutes(30); | ||||
|                 return LoadModuleDefinitionsFromAssemblies(); | ||||
|             }); | ||||
|                 // get module assemblies  | ||||
|                 _moduleDefinitions = LoadModuleDefinitionsFromAssemblies(); | ||||
|             } | ||||
|             List<ModuleDefinition> moduleDefinitions = _moduleDefinitions; | ||||
|  | ||||
|             // get module definition permissions for site | ||||
|             List<Permission> permissions = _permissions.GetPermissions(siteId, EntityNames.ModuleDefinition).ToList(); | ||||
| @ -210,14 +211,5 @@ namespace Oqtane.Repository | ||||
|             return moduledefinitions; | ||||
|         } | ||||
|  | ||||
|         private string GetProperty(Dictionary<string, string> properties, string key) | ||||
|         { | ||||
|             string value = ""; | ||||
|             if (properties.ContainsKey(key)) | ||||
|             { | ||||
|                 value = properties[key]; | ||||
|             } | ||||
|             return value; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -8,6 +8,15 @@ namespace Oqtane.Repository | ||||
|     public class SqlRepository : ISqlRepository | ||||
|     { | ||||
|  | ||||
|         public void ExecuteScript(Tenant tenant, string script) | ||||
|         { | ||||
|             // execute script in curent tenant | ||||
|             foreach (string query in script.Split("GO", StringSplitOptions.RemoveEmptyEntries)) | ||||
|             { | ||||
|                 ExecuteNonQuery(tenant, query); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public int ExecuteNonQuery(Tenant tenant, string query) | ||||
|         { | ||||
|             SqlConnection conn = new SqlConnection(FormatConnectionString(tenant.DBConnectionString)); | ||||
|  | ||||
| @ -9,7 +9,24 @@ namespace Oqtane.Repository | ||||
| { | ||||
|     public class ThemeRepository : IThemeRepository | ||||
|     { | ||||
|         private List<Theme> _themes; // lazy load | ||||
|  | ||||
|         public IEnumerable<Theme> GetThemes() | ||||
|         { | ||||
|             return LoadThemes(); | ||||
|         } | ||||
|  | ||||
|         private List<Theme> LoadThemes() | ||||
|         { | ||||
|             if (_themes == null) | ||||
|             { | ||||
|                 // get themes | ||||
|                 _themes = LoadThemesFromAssemblies(); | ||||
|             } | ||||
|             return _themes; | ||||
|         } | ||||
|  | ||||
|         private List<Theme> LoadThemesFromAssemblies() | ||||
|         { | ||||
|             List<Theme> themes = new List<Theme>(); | ||||
|  | ||||
| @ -103,20 +120,5 @@ namespace Oqtane.Repository | ||||
|             } | ||||
|             return themes; | ||||
|         } | ||||
|  | ||||
|         private string GetProperty(Dictionary<string, string> properties, string key) | ||||
|         { | ||||
|             string value = ""; | ||||
|             if (properties.ContainsKey(key)) | ||||
|             { | ||||
|                 value = properties[key]; | ||||
|             } | ||||
|             return value; | ||||
|         } | ||||
|  | ||||
|         public IEnumerable<Theme> GetThemes() | ||||
|         { | ||||
|             return LoadThemes(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker