private bool IsFuturePatchFile(LatestFile latestFile) { if (latestFile.GameVersion.Count() + latestFile.SortableGameVersion.Count() == 0) { return(false); } foreach (var gameVersion in latestFile.GameVersion) { var version = new FileVersion(gameVersion); if (version <= WowVersion) { return(false); } } foreach (var gameVersion in latestFile.SortableGameVersion) { var version = new FileVersion(gameVersion.GameVersion); if (version <= WowVersion) { return(false); } } return(true); }
private void Window_Initialized(object sender, EventArgs e) { ferma_forms = new List <Windows.Ferma.Ferma_form>(); ferma_form = new Windows.Ferma.Ferma_form(); ferma_forms.Add(ferma_form); sqlite_main = new SQLiteMain("Data/main.db"); LatestFile model = new LatestFile(); latest_files = new List <LatestFile>(); latest_files = model.getLatestFiles(sqlite_main.Connection()); files_start_index = project_menu.Items.Count; if (latest_files.Capacity > 0) { project_menu.Items.Add(new Separator()); files_start_index = project_menu.Items.Count; foreach (var file in latest_files) { MenuItem menu_item = new MenuItem(); menu_item.Header = file.filepath; menu_item.Click += new RoutedEventHandler(OpenFermaWithFile); project_menu.Items.Add(menu_item); } } }
public void WorkWithLatestFiles(string filename) { var file = new LatestFile(); file.filepath = filename; if (latest_files.Capacity > 0) { var check = sqlite_main.Connection().Query <LatestFile>( "select * from latest_files where filepath = ?", filename ); if (check.Count > 0) { for (short i = 0; i < latest_files.Count; i++) { if (latest_files[i].filepath == filename) { latest_files.RemoveAt(i); latest_files.Insert(0, file); MainMenuRedraw(filename); var check_2 = sqlite_main.Connection().Query <LatestFile>( "delete from latest_files where filepath = ?", filename ); var check_3 = sqlite_main.Connection().Insert(file); } } } else { latest_files.Insert(0, file); MainMenuRedraw(filename); var check_3 = sqlite_main.Connection().Insert(file); } } else { project_menu.Items.Add(new Separator()); files_start_index = project_menu.Items.Count; latest_files.Insert(0, file); MainMenuRedraw(filename); var check_3 = sqlite_main.Connection().Insert(file); } }
private LatestFile GetHighestUsableLatestFile(List <LatestFile> latestFiles) { LatestFile bestMatch = null; DateTime bestMatchDate = new DateTime(); foreach (var latestFile in latestFiles) { if (latestFile.GameVersionFlavor.Equals("wow_retail") && latestFile.ReleaseType == 1 && latestFile.IsAlternate == false && !IsFuturePatchFile(latestFile)) { var date = DateTime.Parse(latestFile.FileDate); if (date > bestMatchDate) { bestMatch = latestFile; bestMatchDate = date; } } } return(bestMatch); }
private HashSet <AddonViewModel> GetCurseForgeData(HashSet <string> addonDirectories) { HashSet <AddonViewModel> data = new HashSet <AddonViewModel>(); try { using (HttpClient restAPI = new HttpClient()) { restAPI.BaseAddress = new Uri(BaseAddress); restAPI.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); const uint pageSize = 10000; uint startIndex = 0; while (true) { string request = "api/v2/addon/search?gameId=1&pageSize=" + pageSize + "&index=" + startIndex; HttpResponseMessage response = restAPI.GetAsync(request).Result; if (!response.IsSuccessStatusCode) { break; } string json = response.Content.ReadAsStringAsync().Result; List <AddonData> addons = JsonConvert.DeserializeObject <List <AddonData> >(json); foreach (var addonData in addons) { LatestFile latestFile = GetHighestUsableLatestFile(addonData.LatestFiles); if (!addonData.IsExperimental && latestFile != null && latestFile.Modules.Count() > 0) { bool AllType3FoldersExist = true; bool HasType3Folders = false; foreach (var module in latestFile.Modules) { if (module.Type == 3) { HasType3Folders = true; AllType3FoldersExist &= addonDirectories.Contains(module.Foldername); } } if (HasType3Folders && AllType3FoldersExist) { data.Add(new AddonViewModel() { CurseID = addonData.Id, Name = addonData.Name, Icon = GetIcon(addonData), AvailableVersionDate = DateTime.Parse(latestFile.FileDate), DownloadUrl = latestFile.DownloadUrl, Blacklisted = false }); } } } startIndex += pageSize; } } } catch (Exception exception) { Logger.Exception(exception); } return(data); }