Beispiel #1
0
        public void Init(object comment)
        {
            try
            {
                if (comment.GetType() == typeof(Trakt_CommentUserVM))
                {
                    Trakt_CommentUserVM trakt = comment as Trakt_CommentUserVM;

                    txtFrom.Text     = "From Trakt";
                    txtUsername.Text = trakt.User.Username;
                    txtDate.Text     = trakt.Comment.CommentDateString;
                    txtComment.Text  = trakt.CommentText;

                    urlWebsite.URL = trakt.Comment.Comment_Url;
                }
                else if (comment.GetType() == typeof(AniDB_RecommendationVM))
                {
                    AniDB_RecommendationVM anidb = comment as AniDB_RecommendationVM;

                    txtFrom.Text     = "From AniDB";
                    txtUsername.Text = anidb.UserID.ToString();
                    txtDate.Text     = anidb.RecommendationTypeText;
                    txtComment.Text  = anidb.Comment;

                    urlWebsite.URL = string.Format("http://anidb.net/perl-bin/animedb.pl?show=threads&do=anime&id={0}", anidb.AnimeID);
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Beispiel #2
0
        private void ProcessImages()
        {
            foreach (object req in imagesToDownload)
            {
                try
                {
                    if (req.GetType() == typeof(Trakt_ShoutUserVM))
                    {
                        Trakt_ShoutUserVM tile = req as Trakt_ShoutUserVM;


                        //user
                        Uri    uriUser      = new Uri(tile.UserOnlineImagePath);
                        string filenameUser = Path.GetFileName(uriUser.LocalPath);
                        string tempNameUser = Path.Combine(Path.GetTempPath(), filenameUser);

                        using (WebClient client = new WebClient())
                        {
                            client.Headers.Add("user-agent", "JMM");


                            if (!File.Exists(tempNameUser))
                            {
                                if (tile.UserOnlineImagePath.Length > 0)
                                {
                                    client.DownloadFile(tile.UserOnlineImagePath, tempNameUser);
                                }
                            }
                            if (File.Exists(tempNameUser))
                            {
                                tile.DelayedUserImage = tempNameUser;
                            }
                        }
                    }

                    if (req.GetType() == typeof(AniDB_RecommendationVM))
                    {
                        AniDB_RecommendationVM tile = req as AniDB_RecommendationVM;

                        // unfortunately AniDB doesn't have any user images yet
                        // we will use a placeholder
                        tile.DelayedUserImage = tile.UserImagePathForDisplay;
                    }


                    imagesToDownload.Remove(req);
                }
                catch (Exception ex)
                {
                    imagesToDownload.Remove(req);
                    logger.ErrorException(ex.ToString(), ex);
                }
            }
        }
Beispiel #3
0
        void shoutsWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            AnimeSeriesVM            ser        = e.Argument as AnimeSeriesVM;
            List <Trakt_ShoutUserVM> tempShouts = new List <Trakt_ShoutUserVM>();

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

                // get shouts from trakt
                List <JMMServerBinary.Contract_Trakt_ShoutUser> rawShouts = JMMServerVM.Instance.clientBinaryHTTP.GetTraktShoutsForAnime(ser.AniDB_ID);
                foreach (JMMServerBinary.Contract_Trakt_ShoutUser contract in rawShouts)
                {
                    Trakt_ShoutUserVM shout = new Trakt_ShoutUserVM(contract);

                    shout.DelayedUserImage = @"/Images/blankposter.png";
                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        Shouts.Add(shout);
                    });

                    imagesToDownload.Add(shout);
                }

                // 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);

                    rec.DelayedUserImage = @"/Images/blankposter.png";
                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        Shouts.Add(rec);
                    });

                    imagesToDownload.Add(rec);
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
        }
        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);
            }
        }
Beispiel #5
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;
        }