set SiteState in HostedServiceBase for scheduled jobs
This commit is contained in:
parent
a2029a3ca3
commit
8be9fd6eb2
|
@ -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)
|
||||
|
|
|
@ -26,20 +26,7 @@ namespace Oqtane.Infrastructure
|
|||
{
|
||||
string log = "";
|
||||
|
||||
// iterate through tenants in this installation
|
||||
List<int> tenants = new List<int>();
|
||||
var aliasRepository = provider.GetRequiredService<IAliasRepository>();
|
||||
List<Alias> aliases = aliasRepository.GetAliases().ToList();
|
||||
foreach (Alias alias in aliases)
|
||||
{
|
||||
if (tenants.Contains(alias.TenantId)) continue;
|
||||
tenants.Add(alias.TenantId);
|
||||
|
||||
// use the SiteState to set the Alias explicitly so the tenant can be resolved
|
||||
var siteState = provider.GetRequiredService<SiteState>();
|
||||
siteState.Alias = alias;
|
||||
|
||||
// get services which require tenant resolution
|
||||
// get services
|
||||
var siteRepository = provider.GetRequiredService<ISiteRepository>();
|
||||
var settingRepository = provider.GetRequiredService<ISettingRepository>();
|
||||
var notificationRepository = provider.GetRequiredService<INotificationRepository>();
|
||||
|
@ -124,7 +111,6 @@ namespace Oqtane.Infrastructure
|
|||
log += "SMTP Not Configured Properly In Site Settings - Host, Port, SSL, And Sender Are All Required" + "<br />";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return log;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user