public override void AtHitomi_Click(object sender, RoutedEventArgs e) { //HiyobiLoader hiyobi = new HiyobiLoader(); //hiyobi.Default(); //await hiyobi.Parser(hiyobiList.ToArray()); HitomiLoader hitomi = new HitomiLoader(); hitomi.Default(); hitomi.Parser(new int[] { int.Parse(h.id) }); }
private async void ImportNumber_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "번호 파일|*.json"; if (!ofd.ShowDialog() ?? false) { return; } string s = ofd.FileName; try { MainPanel.Children.Clear(); JArray arr = JArray.Parse(File.ReadAllText(s)); List <string> hiyobiList = new List <string>(); List <int> hitomiList = new List <int>(); foreach (JToken item in arr) { string id = item["id"].ToString(); Hitomi.Type type = (Hitomi.Type) int.Parse(item["type"].ToString()); if (type == Hitomi.Type.Hiyobi) { hiyobiList.Add(id); } else if (type == Hitomi.Type.Hitomi) { hitomiList.Add(int.Parse(id)); } } HiyobiLoader hiyobi = new HiyobiLoader(); hiyobi.Default(); await hiyobi.Parser(hiyobiList.ToArray()); HitomiLoader hitomi = new HitomiLoader(); hitomi.Default(); await hitomi.Parser(hitomiList.ToArray()); } catch { MessageBox.Show("잘못된 형식 입니다."); } }
public void HitomiSearch() { List <int> idlist = new List <int>(); int compcount = 0; if (cache.Keys.Any(x => x.ItemsEqual(tags))) { string[] key = cache.Keys.Where(x => x.ItemsEqual(tags)).First(); this.start(0); idlist = cache[key].ToList(); compcount = tags.Length; } else { List <Task> tasks = new List <Task>(); this.start(tags.Length); Dispatcher dispatcher = Dispatcher.CurrentDispatcher; foreach (string tag in tags) { Hitomi.HTag tag2 = Hitomi.HTag.Parse(tag); string path = Path.Combine(Global.rootDir, "Cache", tag2.type, tag2.tag + ".json"); if (Global.config.cache_search.Get <bool>()) { if (File.Exists(path)) { JArray arr = JArray.Parse(File.ReadAllText(path)); int[] ids = arr.Select(x => int.Parse(x.ToString())).ToArray(); idlist = idlist.Concat(ids).ToList(); compcount++; continue; } } Thread th = new Thread(new ThreadStart(async() => { int[] ids; InternetP parser = new InternetP(); parser.index = index - 1; parser.Count = search_count; if (HiyobiTags.Tags.Select(y => y.full).Contains(tag)) { try { ids = parser.ByteArrayToIntArrayBig(await parser.LoadNozomiTag(tag2.type.ToString(), tag2.tag, range: !Global.config.cache_search.Get <bool>(), start: 0, end: 99)); } catch { ids = new int[0]; } } else { ids = await parser.LoadQuery(tag); } if (Global.config.cache_search.Get <bool>() && !File.Exists(path)) { if (!Directory.Exists(Path.GetDirectoryName(path))) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } File.WriteAllText(path, JArray.FromObject(ids).ToString()); } dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => idlist = idlist.Concat(ids).ToList())); compcount++; dispatcher.Invoke(() => update(compcount, tags.Length)); })); th.Start(); } } int start = (index - 1) * itemCount; int PageCount = start + itemCount; Task.Factory.StartNew(() => { while (compcount != tags.Length) { } if (!cache.Keys.Any(x => x.ItemsEqual(tags))) { cache.Add(tags, idlist.ToArray()); } List <int> new_idlist = new List <int>(); for (int i = 0; i < idlist.Count; i++) { int count = idlist.Count(y => y == idlist[i]); if (count == tags.Length) { new_idlist.Add(idlist[i]); } if (new_idlist.Count >= PageCount) { break; } } new_idlist = new_idlist.Skip(start).ToList(); Global.dispatcher.Invoke(delegate { HitomiLoader hitomi = new HitomiLoader(); hitomi.Default(); LoaderDefaults.Hitomis.Setup(hitomi); hitomi.Parser(new_idlist.ToArray()); }); }); }