private static void ReloadImportant() { List <Important> importantApps; using (var db = Database.Get()) { importantApps = db.Query <Important>("SELECT `AppID` as `ID`, `Channel` FROM `ImportantApps`").ToList(); ImportantSubs = db.Query <Important>("SELECT `SubID` as `ID` FROM `ImportantSubs`").ToDictionary(x => x.ID, _ => (byte)1); } lock (ImportantApps) { ImportantApps.Clear(); foreach (var app in importantApps) { if (ImportantApps.ContainsKey(app.ID)) { ImportantApps[app.ID].Add(app.Channel); } else { ImportantApps.Add(app.ID, new List <string> { app.Channel }); } } } Log.WriteInfo("Application", "Loaded {0} important apps and {1} packages", ImportantApps.Count, ImportantSubs.Count); }
private static async Task ReloadImportant() { await using var db = await Database.GetConnectionAsync(); var importantApps = (await db.QueryAsync <Important>("SELECT `AppID` as `ID`, `Channel` FROM `ImportantApps`")).ToList(); ImportantSubs = (await db.QueryAsync <Important>("SELECT `SubID` as `ID` FROM `ImportantSubs`")).ToDictionary(x => x.ID, _ => (byte)1); lock (ImportantApps) { ImportantApps.Clear(); foreach (var app in importantApps) { if (ImportantApps.ContainsKey(app.ID)) { ImportantApps[app.ID].Add(app.Channel); } else { ImportantApps.Add(app.ID, new List <string> { app.Channel }); } } } Log.WriteInfo(nameof(Application), $"Loaded {ImportantApps.Count} important apps and {ImportantSubs.Count} packages"); }