set SiteState in HostedServiceBase for scheduled jobs

This commit is contained in:
Shaun Walker
2021-01-18 08:59:07 -05:00
parent a2029a3ca3
commit 8be9fd6eb2
2 changed files with 83 additions and 89 deletions

View File

@ -91,7 +91,15 @@ namespace Oqtane.Infrastructure
// execute the job
try
{
log.Notes = ExecuteJob(scope.ServiceProvider);
var notes = "";
var tenants = scope.ServiceProvider.GetRequiredService<ITenantRepository>();
var siteState = scope.ServiceProvider.GetRequiredService<SiteState>();
foreach (var tenant in tenants.GetTenants())
{
siteState.Alias = new Alias { TenantId = tenant.TenantId };
notes += ExecuteJob(scope.ServiceProvider);
}
log.Notes = notes;
log.Succeeded = true;
}
catch (Exception ex)