@namespace Oqtane.Modules.Admin.Sql @inherits ModuleBase @inject NavigationManager NavigationManager @inject ITenantService TenantService @inject ISqlService SqlService @if (_tenants == null) {

Loading...

} else {


@if (!string.IsNullOrEmpty(_results)) { @((MarkupString)_results) } } @code { private List _tenants; private string _tenantid = "-1"; private string _sql = string.Empty; private string _results = string.Empty; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; protected override async Task OnInitializedAsync() { _tenants = await TenantService.GetTenantsAsync(); } private async Task Execute() { if (_tenantid != "-1" && !string.IsNullOrEmpty(_sql)) { var sqlquery = new SqlQuery { TenantId = int.Parse(_tenantid), Query = _sql }; sqlquery = await SqlService.ExecuteQueryAsync(sqlquery); _results = DisplayResults(sqlquery.Results); } else { AddModuleMessage("You Must Select A Tenant And Provide A SQL Query", MessageType.Warning); } } private string DisplayResults(List> results) { var table = string.Empty; foreach (Dictionary item in results) { if (table == string.Empty) { table = "
"; table += ""; foreach (KeyValuePair kvp in item) { table += ""; } table += ""; } table += ""; foreach (KeyValuePair kvp in item) { table += ""; } table += ""; } if (table != string.Empty) { table += "
" + kvp.Key + "
" + kvp.Value + "
"; } else { table = "No Results Returned"; } return table; } }