12345678910111213141516171819202122232425262728293031323334353637 |
- 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;
- }
- /// <summary>
- /// This method is called when the <see cref="T:Microsoft.Extensions.Hosting.IHostedService" /> starts. The implementation should return a task that represents
- /// the lifetime of the long running operation(s) being performed.
- /// </summary>
- /// <param name="stoppingToken">Triggered when <see cref="M:Microsoft.Extensions.Hosting.IHostedService.StopAsync(System.Threading.CancellationToken)" /> is called.</param>
- /// <returns>A <see cref="T:System.Threading.Tasks.Task" /> that represents the long running operations.</returns>
- protected override async Task ExecuteAsync(CancellationToken stoppingToken)
- {
- using var scope = _serviceScopeFactory.CreateScope();
- var cache = scope.ServiceProvider.GetRequiredService<ITableAccessLevelCacheManager>();
- cache.Reload();
- }
- }
- }
|