Automate overdue homework and show outstanding work in teaching mode
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
admin committed 2026-09-25 22:02:00 +02:00
1 parent f3e23ad207
commit 4b73d2bea2
10 files changed
+314 -2

No files matched your search

+28
View File
@@ -28,6 +28,7 @@ public class App : Application
private static bool _exitHandlerAttached;
private static Task _initialPolls = Task.CompletedTask;
private static readonly CancellationTokenSource StartupCancellation = new();
private static DispatcherTimer? _homeworkOverdueTimer;
public override void Initialize() => AvaloniaXamlLoader.Load(this);
@@ -100,6 +101,7 @@ public class App : Application
splash?.SetProgress(60, "Papierkorb aufräumen …");
await Task.Run(() => Services.GetRequiredService<ITrashRepository>()
.PurgeOlderThan(DateTime.UtcNow.AddDays(-30)));
await AdvanceHomeworkAsync();
if (!_exitHandlerAttached)
{
@@ -126,6 +128,7 @@ public class App : Application
main.EnableFinalSync(syncEngine);
desktop.MainWindow = main;
main.Show();
StartHomeworkOverdueTimer();
splash?.SetProgress(100, "Bereit");
windowToClose?.Close();
AppBootstrapper.Logger.Info($"Start: Hauptfenster nach {timer.ElapsedMilliseconds} ms geöffnet.");
@@ -152,6 +155,30 @@ public class App : Application
});
}
private static async Task AdvanceHomeworkAsync()
{
try
{
var changed = await Task.Run(() => Services.GetRequiredService<HomeworkOverdueService>()
.Advance(DateOnly.FromDateTime(DateTime.Today)));
if (changed > 0) AppBootstrapper.Logger.Info($"{changed} offene Hausaufgaben als nicht nachgereicht markiert.");
}
catch (Exception ex) { AppBootstrapper.Logger.Error("Hausaufgaben-Fristprüfung fehlgeschlagen.", ex); }
}
private static void StartHomeworkOverdueTimer()
{
var timer = new DispatcherTimer { Interval = TimeSpan.FromHours(1) };
timer.Tick += async (_, _) =>
{
timer.Stop();
await AdvanceHomeworkAsync();
if (_serviceProvider is not null) timer.Start();
};
_homeworkOverdueTimer = timer;
timer.Start();
}
/// <summary>Wechselt die Darstellung sofort, ohne Neustart (12.4) — Avalonia stylt den
/// gesamten sichtbaren Baum automatisch neu, sobald sich <see cref="ThemeVariant"/>
/// ändert.</summary>
@@ -165,6 +192,7 @@ public class App : Application
private static void DisposeServices()
{
_homeworkOverdueTimer?.Stop();
var serviceProvider = Interlocked.Exchange(ref _serviceProvider, null);
if (serviceProvider is null) return;