private void List_Core() { var packageDbConn = new InstalledDatabase(); packageDbConn.Open(); OnBPMInstanceEvent_Message(BPMInstanceMethod.List, "Querying installed table...");//todo: i18n List_Export = (from item in packageDbConn.CoreDbContext.installed select item.name).ToList(); packageDbConn.Close(); }
private void Search_Core(bool omitVersion, string packageName) { //query var packageDbConn = new PackageDatabase(); packageDbConn.Open(); OnBPMInstanceEvent_Message(BPMInstanceMethod.Search, "Searching package table...");//todo: i18n //query package table first var packageTableReader = from item in packageDbConn.CoreDbContext.package where EF.Functions.Like(item.name, $"%{packageName}%") || EF.Functions.Like(item.desc, $"%{packageName}%") || EF.Functions.Like(item.aka, $"%{packageName}%") select item; //write into export value List <string> exportCache = new List <string>(); foreach (var item in packageTableReader) { exportCache.Add(item.name); } OnBPMInstanceEvent_Message(BPMInstanceMethod.Search, "Searching version table...");//todo: i18n //query version table if (!omitVersion) { var versionTableReader = from item in packageDbConn.CoreDbContext.version where EF.Functions.Like(item.name, $"%{packageName}%") || EF.Functions.Like(item.additional_desc, $"%{packageName}%") group item by item.parent; foreach (var item in versionTableReader) { if (!exportCache.Contains(item.Key)) { exportCache.Add(item.Key); } } } OnBPMInstanceEvent_Message(BPMInstanceMethod.Search, "Collecting data...");//todo: i18n //query info var infomationReader = from item in packageDbConn.CoreDbContext.package where exportCache.Contains(item.name) select item; OnBPMInstanceEvent_Message(BPMInstanceMethod.Search, "Querying install status...");//todo: i18n //query install package var packageDbConn2 = new InstalledDatabase(); packageDbConn2.Open(); var installedReader = (from item in packageDbConn2.CoreDbContext.installed where exportCache.Contains(item.name.Split('@')[0]) select item.name.Split('@')[0]).ToList(); OnBPMInstanceEvent_Message(BPMInstanceMethod.Search, "Building query result...");//todo: i18n //construct export data Search_Export = new List <Search_ExportItem>(); foreach (var item in infomationReader) { Search_Export.Add(new Search_ExportItem() { Name = item.name, Description = item.desc, Aka = item.aka, IsInstalled = installedReader.Contains(item.name) }); } packageDbConn.Close(); packageDbConn2.Close(); }