ComplianceServer/code/Hg.Core.WebApi/Workers/SsoWorker.cs

32 lines
983 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Hg.Core.Domain;
using Hg.Core.Domain.Impl;
namespace Hg.Core.WebApi.Workers
{
public class SsoWorker : BackgroundService
{
private readonly IServiceProvider _serviceProvider;
public SsoWorker(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
try
{
var scope = _serviceProvider.CreateScope();
var inneruserDomain = scope.ServiceProvider.GetRequiredService<IInneruserDomain>();
while (!stoppingToken.IsCancellationRequested)
{
await inneruserDomain.SyncSsoOrganization();
await Task.Delay(60 * 60 * 1000);
}
}
catch (Exception ex)
{
Log.Error(ex, $"SsoWorker服务报错");
}
}
}
}