Exemplo n.º 1
0
        private void SetRec(RecommendationVM rec)
        {
            if (rec == null) return;

            clearGUIProperty("Recommendations.Rec.Title");
            clearGUIProperty("Recommendations.Rec.Description");
            clearGUIProperty("Recommendations.Rec.ApprovalRating");

            clearGUIProperty("Recommendations.BasedOn.Title");
            clearGUIProperty("Recommendations.BasedOn.VoteValue");

            setGUIProperty("Recommendations.Rec.Title", rec.Recommended_DisplayName);
            setGUIProperty("Recommendations.Rec.Description", rec.Recommended_Description);
            setGUIProperty("Recommendations.Rec.ApprovalRating", rec.Recommended_ApprovalRating);
            setGUIProperty("Recommendations.Rec.Image", rec.Recommended_PosterPath);

            try
            {
                if (rec.Recommended_AniDB_Anime != null)
                    setGUIProperty("Recommendations.Rec.AniDBRating", rec.Recommended_AniDB_Anime.AniDBRatingFormatted);
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write(ex.ToString());
            }

            setGUIProperty("Recommendations.BasedOn.Title", rec.BasedOn_DisplayName);
            setGUIProperty("Recommendations.BasedOn.VoteValue", rec.BasedOn_VoteValueFormatted);
            setGUIProperty("Recommendations.BasedOn.Image", rec.BasedOn_PosterPath);
        }
Exemplo n.º 2
0
        void getDataWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List<RecommendationVM> tempRecs = new List<RecommendationVM>();

            int recType = 1;
            if (dummyModeDownload != null && dummyModeDownload.Visible)
                recType = 2;

            List<JMMServerBinary.Contract_Recommendation> contracts =
                    JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(20, JMMServerVM.Instance.CurrentUser.JMMUserID, recType);

            foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
            {
                RecommendationVM rec = new RecommendationVM();
                rec.Populate(contract);
                tempRecs.Add(rec);
            }

            e.Result = tempRecs;
        }
        private void SetRec(RecommendationVM rec)
        {
            if (rec == null) return;
            SetGUIProperty(GuiProperty.Recommendations_Rec_Title, rec.Recommended_DisplayName);
            SetGUIProperty(GuiProperty.Recommendations_Rec_Description, rec.Recommended_Description);
            SetGUIProperty(GuiProperty.Recommendations_Rec_ApprovalRating, rec.Recommended_ApprovalRating);
            SetGUIProperty(GuiProperty.Recommendations_Rec_Image, rec.Recommended_PosterPath);

            try
            {
                if (rec.Recommended_AniDB_Anime != null)
                    SetGUIProperty(GuiProperty.Recommendations_Rec_AniDBRating, rec.Recommended_AniDB_Anime.AniDBRatingFormatted);
                else
                    ClearGUIProperty(GuiProperty.Recommendations_Rec_AniDBRating);
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write(ex.ToString());
            }

            SetGUIProperty(GuiProperty.Recommendations_BasedOn_Title, rec.BasedOn_DisplayName);
            SetGUIProperty(GuiProperty.Recommendations_BasedOn_VoteValue, rec.BasedOn_VoteValueFormatted);
            SetGUIProperty(GuiProperty.Recommendations_BasedOn_Image, rec.BasedOn_PosterPath);
        }
Exemplo n.º 4
0
        void downloadRecommendedAnimeWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <JMMServerBinary.Contract_Recommendation> contracts =
                JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(20, JMMServerVM.Instance.CurrentUser.JMMUserID, 2);                         // downloads only


            foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
            {
                RecommendationVM rec = new RecommendationVM();
                rec.Populate(contract);

                if (rec.Recommended_AniDB_Anime == null)
                {
                    BaseConfig.MyAnimeLog.Write("Updating data for anime: " + rec.RecommendedAnimeID.ToString());
                    JMMServerVM.Instance.clientBinaryHTTP.UpdateAnimeData(rec.RecommendedAnimeID);
                }
            }

            // refresh the data
            List <RecommendationVM> tempRecs = new List <RecommendationVM>();

            contracts = JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(20, JMMServerVM.Instance.CurrentUser.JMMUserID, 2);             // downloads only
            foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
            {
                RecommendationVM rec = new RecommendationVM();
                rec.Populate(contract);
                if (rec.Recommended_AniDB_Anime == null)
                {
                    tempRecs.Add(rec);
                }
            }

            // lets try and download the images
            DateTime start           = DateTime.Now;
            bool     imagesAvailable = false;
            bool     timeOut         = false;

            while (!imagesAvailable && !timeOut)
            {
                BaseConfig.MyAnimeLog.Write("Checking for images...");
                bool foundAllImages = true;
                foreach (RecommendationVM rec in tempRecs)
                {
                    if (!File.Exists(rec.Recommended_AniDB_Anime.PosterPathNoDefault))
                    {
                        BaseConfig.MyAnimeLog.Write("Downloading image for : " + rec.Recommended_AniDB_Anime.AnimeID.ToString());
                        MainWindow.imageHelper.DownloadAniDBCover(rec.Recommended_AniDB_Anime, false);
                        foundAllImages = false;
                    }
                }
                TimeSpan ts = DateTime.Now - start;
                if (ts.TotalSeconds > 15)
                {
                    timeOut = true;
                }
                imagesAvailable = foundAllImages;

                Thread.Sleep(2000);
            }


            OnGotRecommendedAnimeEvent(new GotAnimeForRecommendedEventArgs());
        }
Exemplo n.º 5
0
        void downloadRecommendedAnimeWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List<JMMServerBinary.Contract_Recommendation> contracts =
                    JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(20, JMMServerVM.Instance.CurrentUser.JMMUserID, 2); // downloads only

            foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
            {
                RecommendationVM rec = new RecommendationVM();
                rec.Populate(contract);

                if (rec.Recommended_AniDB_Anime == null)
                {
                    BaseConfig.MyAnimeLog.Write("Updating data for anime: " + rec.RecommendedAnimeID.ToString());
                    JMMServerVM.Instance.clientBinaryHTTP.UpdateAnimeData(rec.RecommendedAnimeID);
                }
            }

            // refresh the data
            List<RecommendationVM> tempRecs = new List<RecommendationVM>();
            contracts = JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(20, JMMServerVM.Instance.CurrentUser.JMMUserID, 2); // downloads only
            foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
            {
                RecommendationVM rec = new RecommendationVM();
                rec.Populate(contract);
                if (rec.Recommended_AniDB_Anime == null) tempRecs.Add(rec);
            }

            // lets try and download the images
            DateTime start = DateTime.Now;
            bool imagesAvailable = false;
            bool timeOut = false;

            while (!imagesAvailable && !timeOut)
            {
                BaseConfig.MyAnimeLog.Write("Checking for images...");
                bool foundAllImages = true;
                foreach (RecommendationVM rec in tempRecs)
                {
                    if (!File.Exists(rec.Recommended_AniDB_Anime.PosterPathNoDefault))
                    {
                        BaseConfig.MyAnimeLog.Write("Downloading image for : " + rec.Recommended_AniDB_Anime.AnimeID.ToString());
                        MainWindow.imageHelper.DownloadAniDBCover(rec.Recommended_AniDB_Anime, false);
                        foundAllImages = false;
                    }
                }
                TimeSpan ts = DateTime.Now - start;
                if (ts.TotalSeconds > 15) timeOut = true;
                imagesAvailable = foundAllImages;

                Thread.Sleep(2000);
            }

            OnGotRecommendedAnimeEvent(new GotAnimeForRecommendedEventArgs());
        }