SyncService: Add distinction main/non-main device
Test / Run tests (push) Successful in 2m26s

This commit is contained in:
2026-08-17 23:29:31 +02:00
parent fc5ad82686
commit eaddf0c3cb
3 changed files with 35 additions and 6 deletions
+11 -2
View File
@@ -214,7 +214,7 @@ namespace Elwig.Services {
];
}
public static async Task Download(string url, string username, string password) {
public static async Task Download(string url, string username, string password, bool confirmImports) {
try {
var import = await GetFilesToImport(url, username, password);
var paths = new List<string>();
@@ -226,7 +226,7 @@ namespace Elwig.Services {
paths.Add(filename);
}
}
await ElwigData.Import(paths, ElwigData.ImportMode.FromBranches);
await ElwigData.Import(paths, confirmImports ? ElwigData.ImportMode.Interactively : ElwigData.ImportMode.FromBranches);
} catch (HttpRequestException exc) {
InteractionService.ShowException("Daten herunterladen", "Eventuell Internetverbindung prüfen!", exc);
} catch (TaskCanceledException exc) {
@@ -264,5 +264,14 @@ namespace Elwig.Services {
return false;
}
}
public static async Task<bool> ChangesAvailable(AppDbContext ctx, string url, string username, string password, int? year = null) {
try {
year ??= Utils.CurrentLastSeason;
return await ctx.Deliveries.Where(d => d.ZwstId == App.ZwstId && d.Year == year).Where(ChangedDeliveries).AnyAsync() || (Utils.HasInternetConnectivity() && (await GetFilesToImport(url, username, password)).Count > 0);
} catch {
return false;
}
}
}
}