Release v1.0.0 #16

Merged
Wesser merged 492 commits from release/v1.0.0 into master 2025-02-12 09:19:32 +03:00
302 changed files with 16135 additions and 99 deletions
Showing only changes of commit b40e394bcf - Show all commits

View File

@ -2,6 +2,7 @@
using Cronos; using Cronos;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@ -191,15 +192,20 @@ public class ScheduleController(ILogger<ScheduleController> logger, IOptionsSnap
filePaths.Add((filePath, defaultCampus[i])); filePaths.Add((filePath, defaultCampus[i]));
} }
var sync = (ScheduleSynchronizer)ActivatorUtilities.GetServiceOrCreateInstance(provider, typeof(ScheduleSynchronizer));
if (force) if (force)
{ {
dbContext.Lessons.RemoveRange(dbContext.Lessons.ToList()); dbContext.Lessons.RemoveRange(await dbContext.Lessons.ToListAsync());
await dbContext.SaveChangesAsync(); await dbContext.SaveChangesAsync();
} }
_ = sync.StartSync(filePaths, CancellationToken.None); var scopeFactory = provider.GetRequiredService<IServiceScopeFactory>();
_ = Task.Run(async () =>
{
using var scope = scopeFactory.CreateScope();
var sync = scope.ServiceProvider.GetRequiredService<ScheduleSynchronizer>();
await sync.StartSync(filePaths, CancellationToken.None);
}, CancellationToken.None);
return Ok(); return Ok();
} }