using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hotline.Caching.Interfaces;
using Hotline.CallCenter.BlackLists;
using Hotline.Settings;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using XF.Domain.Cache;
namespace Hotline.Application.Systems
{
public class TableAccessLevelInitialService : BackgroundService
{
private readonly IServiceScopeFactory _serviceScopeFactory;
public TableAccessLevelInitialService(IServiceScopeFactory serviceScopeFactory)
{
_serviceScopeFactory = serviceScopeFactory;
}
///
/// This method is called when the starts. The implementation should return a task that represents
/// the lifetime of the long running operation(s) being performed.
///
/// Triggered when is called.
/// A that represents the long running operations.
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
using var scope = _serviceScopeFactory.CreateScope();
var cache = scope.ServiceProvider.GetRequiredService();
cache.Reload();
}
}
}