performance optimizations in site router and remove dependency between page and module in route specification

This commit is contained in:
Shaun Walker
2019-10-18 12:23:36 -04:00
parent 73feb1f93f
commit 1cc58ea150
22 changed files with 172 additions and 175 deletions

View File

@ -33,17 +33,20 @@ namespace Oqtane.Services
return await http.GetJsonAsync<List<string>>(apiurl + "?folder=" + Folder);
}
public async Task<bool> UploadFilesAsync(string Folder, string[] Files, string FileUploadName)
public async Task<string> UploadFilesAsync(string Folder, string[] Files, string FileUploadName)
{
bool success = false;
string result = "";
var interop = new Interop(jsRuntime);
await interop.UploadFiles(apiurl + "/upload", Folder, FileUploadName);
// uploading files is asynchronous so we need to wait for the upload to complete
bool success = false;
int attempts = 0;
while (attempts < 5 && success == false)
{
Thread.Sleep(2000); // wait 2 seconds
result = "";
List<string> files = await GetFilesAsync(Folder);
if (files.Count > 0)
@ -54,13 +57,18 @@ namespace Oqtane.Services
if (!files.Contains(file))
{
success = false;
result += file + ",";
}
}
}
attempts += 1;
}
if (!success)
{
result = result.Substring(0, result.Length - 1);
}
return success;
return result;
}
public async Task DeleteFileAsync(string Folder, string File)

View File

@ -7,7 +7,7 @@ namespace Oqtane.Services
public interface IFileService
{
Task<List<string>> GetFilesAsync(string Folder);
Task<bool> UploadFilesAsync(string Folder, string[] Files, string FileUploadName);
Task<string> UploadFilesAsync(string Folder, string[] Files, string FileUploadName);
Task DeleteFileAsync(string Folder, string File);
}
}

View File

@ -6,8 +6,7 @@ namespace Oqtane.Services
{
public interface IModuleService
{
Task<List<Module>> GetModulesAsync(int PageId);
Task<List<Module>> GetModulesAsync(int SiteId, string ModuleDefinitionName);
Task<List<Module>> GetModulesAsync(int SiteId);
Task<Module> GetModuleAsync(int ModuleId);
Task<Module> AddModuleAsync(Module Module);
Task<Module> UpdateModuleAsync(Module Module);

View File

@ -26,21 +26,15 @@ namespace Oqtane.Services
get { return CreateApiUrl(sitestate.Alias, NavigationManager.Uri, "Module"); }
}
public async Task<List<Module>> GetModulesAsync(int PageId)
public async Task<List<Module>> GetModulesAsync(int SiteId)
{
List<Module> modules = await http.GetJsonAsync<List<Module>>(apiurl + "?pageid=" + PageId.ToString());
List<Module> modules = await http.GetJsonAsync<List<Module>>(apiurl + "?siteid=" + SiteId.ToString());
modules = modules
.OrderBy(item => item.Order)
.ToList();
return modules;
}
public async Task<List<Module>> GetModulesAsync(int SiteId, string ModuleDefinitionName)
{
List<Module> modules = await http.GetJsonAsync<List<Module>>(apiurl + "?siteid=" + SiteId.ToString() + "&moduledefinitionname=" + ModuleDefinitionName);
return modules.ToList();
}
public async Task<Module> GetModuleAsync(int ModuleId)
{
return await http.GetJsonAsync<Module>(apiurl + "/" + ModuleId.ToString());