예제 #1
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            var animeElements = GetElements("http://myanimelist.net/malappinfo.php?u=CWarlord87&status=all&type=anime");

            txtResults.Text += "START: " + GetTime() + "\n";
            foreach (var anime in animeElements)
            {
                var myanimeObject = new MyAnime();

                var status   = anime.Element("my_status")?.Value;
                var episodes = Convert.ToInt32(anime.Element("my_watched_episodes")?.Value);
                var score    = Convert.ToInt32(anime.Element("my_score")?.Value);
                var animeId  = Convert.ToInt32(anime.Element("series_animedb_id")?.Value);

                AnimeFunction(animeId);

                if (DatabaseControl.AnimeExists(animeId, true))
                {
                    myanimeObject.AnimeID         = animeId;
                    myanimeObject.WatchedEpisodes = episodes;
                    myanimeObject.Score           = score;
                    myanimeObject.Status          = status;
                    DatabaseControl.InsertAnime(myanimeObject);
                }
                else
                {
                    var myanime  = DatabaseControl.GetMyAnimeById(animeId);
                    var myStatus = MyAnime.GetStatus(status);
                    //change to just update specific items
                    if (Convert.ToInt32(myanime.Status) != MyAnime.GetStatus(status) ||
                        score != Convert.ToInt32(myanime.Score) || episodes != Convert.ToInt32(myanime.WatchedEpisodes))
                    {
                        DatabaseControl.UpdateAnime(animeId, score, episodes, myStatus);
                    }
                }
            }

            txtResults.Text += "DONE: " + GetTime() +
                               "\n";
        }
예제 #2
0
        private void MyAnimeFun(IEnumerable <XElement> animeElements)
        {
            var animeDbId = new List <int>();

            txtResults.Text += "START: " + GetTime() + "\n";
            foreach (var anime in animeElements)
            {
                var myanimeObject = new MyAnime();

                var status   = anime.Element("my_status")?.Value;
                var episodes = Convert.ToInt32(anime.Element("my_watched_episodes")?.Value);
                var score    = Convert.ToInt32(anime.Element("my_score")?.Value);
                var animeId  = Convert.ToInt32(anime.Element("series_animedb_id")?.Value);
                animeDbId.Add(animeId);

                if (DatabaseControl.AnimeExists(animeId, true))
                {
                    myanimeObject.AnimeID         = animeId;
                    myanimeObject.WatchedEpisodes = episodes;
                    myanimeObject.Score           = score;
                    myanimeObject.Status          = status;
                    DatabaseControl.InsertAnime(myanimeObject);
                }
                else
                {
                    var myanime  = DatabaseControl.GetMyAnimeById(animeId);
                    var myStatus = MyAnime.GetStatus(status);
                    //change to just update specific items
                    if (Convert.ToInt32(myanime.Status) != MyAnime.GetStatus(status) ||
                        score != Convert.ToInt32(myanime.Score) || episodes != Convert.ToInt32(myanime.WatchedEpisodes))
                    {
                        DatabaseControl.UpdateAnime(animeId, score, episodes, myStatus);
                    }
                }
            }

            txtResults.Text += "DONE: " + GetTime() + "\n";
        }
예제 #3
0
 public static void InsertAnime(MyAnime myAnime) => Connection.Execute("InsertMyAnime", myAnime, commandType: CommandType.StoredProcedure);