@page "/" @using Microsoft.EntityFrameworkCore @inject IDbContextFactory DbFactory @inject ExportOrchestrationService ExportService Dashboard Dashboard Alle exportieren Nächster automatischer Lauf: @nextRunText Land TSC Schema Server Letzter Status Row Count Letzter Lauf Dauer Aktion @context.Land @context.TSC @context.Schema @context.HanaServer?.Name @GetStatusIcon(context.Id) @GetRows(context.Id) @GetLastRun(context.Id) @GetDuration(context.Id) @if (runningSiteIds.Contains(context.Id)) { } else { Einzeln exportieren } @code { private List sites = []; private Dictionary latestLogs = new(); private HashSet runningSiteIds = []; private bool isRunningAll; private string nextRunText = "-"; protected override async Task OnInitializedAsync() { await LoadAsync(); } private async Task LoadAsync() { await using var db = await DbFactory.CreateDbContextAsync(); sites = await db.Sites .Include(x => x.HanaServer) .Where(x => x.IsActive) .OrderBy(x => x.Land) .ToListAsync(); latestLogs = await ExportService.GetLatestLogsPerSiteAsync(); var nextRun = await ExportService.GetNextRunAsync(); nextRunText = nextRun.HasValue ? nextRun.Value.ToString("dd.MM.yyyy HH:mm") : "Deaktiviert"; } private async Task ExportAllAsync() { isRunningAll = true; foreach (var site in sites) { runningSiteIds.Add(site.Id); } StateHasChanged(); await ExportService.ExportAllActiveSitesAsync(); runningSiteIds.Clear(); isRunningAll = false; await LoadAsync(); } private async Task ExportSingleAsync(int siteId) { runningSiteIds.Add(siteId); StateHasChanged(); await ExportService.ExportSiteAsync(siteId); runningSiteIds.Remove(siteId); await LoadAsync(); } private string GetStatusIcon(int siteId) { if (!latestLogs.TryGetValue(siteId, out var log) || log is null) { return "-"; } return log.Status == "OK" ? "✅" : "❌"; } private string GetRows(int siteId) => latestLogs.TryGetValue(siteId, out var log) && log is not null ? log.RowCount.ToString() : "-"; private string GetLastRun(int siteId) => latestLogs.TryGetValue(siteId, out var log) && log is not null ? log.Timestamp.ToLocalTime().ToString("dd.MM.yyyy HH:mm:ss") : "-"; private string GetDuration(int siteId) => latestLogs.TryGetValue(siteId, out var log) && log is not null ? $"{log.DurationSeconds:F1}s" : "-"; }