[#43] App: Use FileSystemWatcher to renew contexts on demand
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user