Performance improvements, refactoring of multi-tenant support, split Alias and Tenant entities for cleaner separation of concerns, create an additional site during installation for demonstratng multitenancy

This commit is contained in:
Shaun Walker
2019-05-24 13:33:19 -04:00
parent 0067521cd5
commit 8deb119f36
57 changed files with 880 additions and 309 deletions

View File

@ -13,48 +13,49 @@ namespace Oqtane.Services
public class ThemeService : ServiceBase, IThemeService
{
private readonly HttpClient http;
private readonly string apiurl;
private readonly SiteState sitestate;
private List<Theme> themes;
public ThemeService(HttpClient http, IUriHelper urihelper)
public ThemeService(HttpClient http, SiteState sitestate)
{
this.http = http;
apiurl = CreateApiUrl(urihelper.GetAbsoluteUri(), "Theme");
this.sitestate = sitestate;
}
//TODO: Implement Caching or otherwise on this, and other calls within this class
private string apiurl
{
get { return CreateApiUrl(sitestate.Alias, "Theme"); }
}
public async Task<List<Theme>> GetThemesAsync()
{
if (themes == null)
List<Theme> themes = await http.GetJsonAsync<List<Theme>>(apiurl);
// get list of loaded assemblies
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Theme theme in themes)
{
themes = await http.GetJsonAsync<List<Theme>>(apiurl);
// get list of loaded assemblies
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Theme theme in themes)
if (theme.Dependencies != "")
{
if (theme.Dependencies != "")
foreach (string dependency in theme.Dependencies.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
foreach (string dependency in theme.Dependencies.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
string assemblyname = dependency.Replace(".dll", "");
if (assemblies.Where(item => item.FullName.StartsWith(assemblyname + ",")).FirstOrDefault() == null)
{
string assemblyname = dependency.Replace(".dll", "");
if (assemblies.Where(item => item.FullName.StartsWith(assemblyname + ",")).FirstOrDefault() == null)
{
// download assembly from server and load
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + assemblyname + ".dll");
Assembly.Load(bytes);
}
// download assembly from server and load
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + assemblyname + ".dll");
Assembly.Load(bytes);
}
}
if (assemblies.Where(item => item.FullName.StartsWith(theme.AssemblyName + ",")).FirstOrDefault() == null)
{
// download assembly from server and load
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + theme.AssemblyName + ".dll");
Assembly.Load(bytes);
}
}
if (assemblies.Where(item => item.FullName.StartsWith(theme.AssemblyName + ",")).FirstOrDefault() == null)
{
// download assembly from server and load
var bytes = await http.GetByteArrayAsync("_framework/_bin/" + theme.AssemblyName + ".dll");
Assembly.Load(bytes);
}
}
return themes.OrderBy(item => item.Name).ToList();
}