private async void Load()
        {
            var html = await GetPage(@"http://nnmclub.to/forum/portal.php?c=1&start=" + 20 *currentPage);

            var refs = html.DocumentNode.SelectNodes("//table[contains(@class, \"pline\")]//td[contains(@class, \"pcatHead\")]//a[contains(concat(\" \", normalize-space(@class), \" \"), \" pgenmed \")]");

            items.Clear();
            using (var db = new LiteDatabase(@"C:\Users\User\YandexDisk\anime-list.litedb"))
            {
                var col = db.GetCollection <AnimeInfo>("anime");
                foreach (var rf in refs)
                {
                    if (!rf.InnerText.Equals("Популярные раздачи"))
                    {
                        var dbref = col.FindOne(x => x.Topic == rf.InnerText);
                        if (dbref != null)
                        {
                            items.Add(dbref);
                        }
                        else
                        {
                            var item = new AnimeInfo {
                                Topic = rf.InnerText
                            };
                            col.Insert(item);
                            items.Add(item);
                        }
                    }
                }
            }
            return;
        }
Beispiel #2
0
        private void TopicGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            AnimeInfo anime = (AnimeInfo)e.Row.Item;

            Console.WriteLine(anime.Episodes);
            Console.WriteLine(e.Column.Header);
            TextBox text = (TextBox)e.EditingElement;

            Console.WriteLine(text.Text);
            if (String.Equals(e.Column.Header, "EngTitle"))
            {
                anime.EngTitle = text.Text;
            }
            if (String.Equals(e.Column.Header, "RusTitle"))
            {
                anime.RusTitle = text.Text;
            }
            if (String.Equals(e.Column.Header, "Year"))
            {
                anime.Year = int.Parse(text.Text);
            }
            if (String.Equals(e.Column.Header, "Episodes"))
            {
                anime.Episodes = int.Parse(text.Text);
            }
            if (String.Equals(e.Column.Header, "Topic"))
            {
                return;
            }
            if (String.Equals(e.Column.Header, "ID"))
            {
                return;
            }
            using (var db = new LiteDatabase(@"C:\Users\User\YandexDisk\anime-list.litedb"))
            {
                var col = db.GetCollection <AnimeInfo>("anime");
                col.Update(anime);
            }
        }