コード例 #1
0
        void commentsWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            AnimeSeriesVM ser = e.Argument as AnimeSeriesVM;
            List<Trakt_CommentUserVM> tempComments = new List<Trakt_CommentUserVM>();

            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate ()
                {
                    Comments.Clear();
                });

                // get comments from trakt
                List<JMMServerBinary.Contract_Trakt_CommentUser> rawComments = JMMServerVM.Instance.clientBinaryHTTP.GetTraktCommentsForAnime(ser.AniDB_ID);
                foreach (JMMServerBinary.Contract_Trakt_CommentUser contract in rawComments)
                {
                    Trakt_CommentUserVM comment = new Trakt_CommentUserVM(contract);

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate ()
                    {
                        Comments.Add(comment);
                    });

                }

                // get recommendations from AniDB
                List<JMMServerBinary.Contract_AniDB_Recommendation> rawRecs = JMMServerVM.Instance.clientBinaryHTTP.GetAniDBRecommendations(ser.AniDB_ID);
                foreach (JMMServerBinary.Contract_AniDB_Recommendation contract in rawRecs)
                {
                    AniDB_RecommendationVM rec = new AniDB_RecommendationVM(contract);

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate ()
                    {
                        Comments.Add(rec);
                    });
                }

            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
        }
コード例 #2
0
        void refreshDataWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List<object> tempComments = new List<object>();

            try
            {
                AnimeSeriesVM animeSeries = (AnimeSeriesVM)e.Argument;
                if (animeSeries == null) return;

                // get comments from Trakt
                List<JMMServerBinary.Contract_Trakt_CommentUser> rawComments = JMMServerVM.Instance.clientBinaryHTTP.GetTraktCommentsForAnime(animeSeries.AniDB_ID);
                foreach (JMMServerBinary.Contract_Trakt_CommentUser contract in rawComments)
                {
                    Trakt_CommentUserVM traktComment = new Trakt_CommentUserVM(contract);
                    tempComments.Add(traktComment);
                }

                // get comments from AniDB
                // get recommendations from AniDB
                List<JMMServerBinary.Contract_AniDB_Recommendation> rawRecs = JMMServerVM.Instance.clientBinaryHTTP.GetAniDBRecommendations(animeSeries.AniDB_ID);
                foreach (JMMServerBinary.Contract_AniDB_Recommendation contract in rawRecs)
                {
                    AniDB_RecommendationVM rec = new AniDB_RecommendationVM(contract);
                    tempComments.Add(rec);
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }

            e.Result = tempComments;
        }