[#43] App: Use FileSystemWatcher to renew contexts on demand

This commit is contained in:
2024-03-19 13:17:06 +01:00
parent 98688168b8
commit 1806b02039
13 changed files with 51 additions and 66 deletions

View File

@ -20,31 +20,29 @@ namespace Elwig.Windows {
DeactivateKgButton.IsEnabled = false;
}
protected override async Task OnRenewContext() {
using (var ctx = new AppDbContext()) {
var origins = (await ctx.WineOrigins
.Include("Gems.AtGem.Kgs.WbKg.Gl")
.AsSplitQuery()
.ToListAsync())
.OrderByDescending(o => o.SortKey)
.ThenBy(o => o.HkId);
ControlUtils.RenewItemsSource(WineOrigins, origins, WineOrigins_SelectionChanged);
if (WineOrigins.SelectedItem == null) {
var hkid = await ctx.WbKgs
.GroupBy(k => k.AtKg.Gem.WbGem!.HkId)
.Where(g => g.Count() > 0)
.OrderByDescending(g => g.Count())
.Select(g => g.Key)
.FirstOrDefaultAsync();
ControlUtils.SelectItemWithPk(WineOrigins, hkid);
}
var gls = await ctx.WbGls
.OrderBy(g => g.GlNr)
.Include("Kgs.Rds")
protected override async Task OnRenewContext(AppDbContext ctx) {
var origins = (await ctx.WineOrigins
.Include("Gems.AtGem.Kgs.WbKg.Gl")
.AsSplitQuery()
.ToListAsync();
ControlUtils.RenewItemsSource(WbGls, gls, WbGls_SelectionChanged, ControlUtils.RenewSourceDefault.First);
.ToListAsync())
.OrderByDescending(o => o.SortKey)
.ThenBy(o => o.HkId);
ControlUtils.RenewItemsSource(WineOrigins, origins, WineOrigins_SelectionChanged);
if (WineOrigins.SelectedItem == null) {
var hkid = await ctx.WbKgs
.GroupBy(k => k.AtKg.Gem.WbGem!.HkId)
.Where(g => g.Count() > 0)
.OrderByDescending(g => g.Count())
.Select(g => g.Key)
.FirstOrDefaultAsync();
ControlUtils.SelectItemWithPk(WineOrigins, hkid);
}
var gls = await ctx.WbGls
.OrderBy(g => g.GlNr)
.Include("Kgs.Rds")
.AsSplitQuery()
.ToListAsync();
ControlUtils.RenewItemsSource(WbGls, gls, WbGls_SelectionChanged, ControlUtils.RenewSourceDefault.First);
UpdateWbGems();
UpdateWbKgs();
UpdateWbGlKgs();