void LoadMissions() { if (!Directory.Exists(Locations.ArtemisMissionPath)) { System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ReLoadMissions)); } else { MissionList.Clear(); DirectoryInfo missionDir = new DirectoryInfo(Locations.ArtemisMissionPath); foreach (FileInfo f in missionDir.GetFiles("MISS_*.xml", SearchOption.AllDirectories)) { big_message m = new big_message(f.FullName); if (m != null) { MissionList.Add(m); } } } }
private async Task LoadMissionTask(string uri) { MissionList.Clear(); int o = 0; while (true) { string reqUri = uri + o; string responseString = await SendRequest.GET(reqUri); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(responseString); HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes(@"//form[@name='frm_mis']/tr"); int count = 0; Regex regex = new Regex(@"# \d+"); for (int i = 0; i < nodes.Count; i++) { if (i == 0 || i == nodes.Count - 1) { continue; } string complete = nodes[i].SelectSingleNode(@"./td[1]/table/tr[@class='m2']//a").GetAttributeValue("href", ""); string mark = nodes[i].SelectSingleNode(@"./td[1]/table/tr[2]//a").GetAttributeValue("href", ""); string targetIP = nodes[i].SelectSingleNode(@"./td[2]/table/tr[1]//a/span[@class='green']").InnerText; string type = nodes[i].SelectSingleNode(@"./td[3]/a/span").InnerText; string detail = StringHelper.RemoveSpecial(nodes[i].SelectSingleNode(@"./td[4]//td[@align='justify']").InnerText); string reward = nodes[i].SelectSingleNode(@"./td[5]").InnerText; string fileID = ""; var match = regex.Match(detail); if (match.Success) { fileID = match.Value.Replace("#", "").Trim(); } MissionModel newData = new MissionModel() { Complete = complete, Mark = mark, TargetIP = targetIP, Type = type, Details = detail, Reward = reward, FileID = fileID }; MissionList.Add(newData); count++; } if (count == 0) { break; } o += 50; } }