コード例 #1
0
        void recsWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                AnimeSeriesVM ser = e.Argument as AnimeSeriesVM;

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

                List<JMMServerBinary.Contract_AniDB_Anime_Similar> links = JMMServerVM.Instance.clientBinaryHTTP.GetSimilarAnimeLinks(ser.AniDB_ID,
                        JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                List<AniDB_Anime_SimilarVM> tempList = new List<AniDB_Anime_SimilarVM>();
                foreach (JMMServerBinary.Contract_AniDB_Anime_Similar link in links)
                {
                    AniDB_Anime_SimilarVM sim = new AniDB_Anime_SimilarVM();
                    sim.Populate(link);
                    tempList.Add(sim);
                }

                List<SortPropOrFieldAndDirection> sortCriteria = new List<SortPropOrFieldAndDirection>();
                sortCriteria.Add(new SortPropOrFieldAndDirection("ApprovalPercentage", true, SortType.eDoubleOrFloat));
                tempList = Sorting.MultiSort<AniDB_Anime_SimilarVM>(tempList, sortCriteria);

                foreach (AniDB_Anime_SimilarVM sim in tempList)
                {
                    if (sim.AnimeInfoNotExists)
                    {
                        string result = JMMServerVM.Instance.clientBinaryHTTP.UpdateAnimeData(sim.SimilarAnimeID);
                        if (string.IsNullOrEmpty(result))
                        {
                            JMMServerBinary.Contract_AniDBAnime animeContract = JMMServerVM.Instance.clientBinaryHTTP.GetAnime(sim.SimilarAnimeID);
                            sim.PopulateAnime(animeContract);
                        }
                    }

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate ()
                    {
                        Recommendations.Add(new RecommendationTile()
                        {
                            Details = "",
                            AnimeName = sim.DisplayName,
                            Picture = sim.PosterPath,
                            AnimeSeries = sim.AnimeSeries,
                            TileSize = "Large",
                            Height = 100,
                            Source = "AniDB",
                            AnimeID = sim.AnimeID,
                            URL = sim.AniDB_SiteURL,
                            SimilarAnimeID = sim.SimilarAnimeID,
                            HasSeries = sim.LocalSeriesExists
                        });
                    });
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
        }
コード例 #2
0
		public void RefreshData()
		{
			try
			{
				AniDB_AnimeVM anime = null;

				AnimeSeriesVM animeSeries = (AnimeSeriesVM)this.DataContext;
				if (animeSeries == null)
				{
					SimilarAnimeLinks.Clear();
					return;
				}
				SimilarAnimeLinks.Clear();
				anime = animeSeries.AniDB_Anime;

				if (anime == null) return;


				List<JMMServerBinary.Contract_AniDB_Anime_Similar> links = JMMServerVM.Instance.clientBinaryHTTP.GetSimilarAnimeLinks(anime.AnimeID,
					JMMServerVM.Instance.CurrentUser.JMMUserID.Value);


				List<AniDB_Anime_SimilarVM> tempList = new List<AniDB_Anime_SimilarVM>();
				foreach (JMMServerBinary.Contract_AniDB_Anime_Similar link in links)
				{
					AniDB_Anime_SimilarVM sim = new AniDB_Anime_SimilarVM();
					sim.Populate(link);
					tempList.Add(sim);
				}

				List<SortPropOrFieldAndDirection> sortCriteria = new List<SortPropOrFieldAndDirection>();
				sortCriteria.Add(new SortPropOrFieldAndDirection("ApprovalPercentage", true, SortType.eDoubleOrFloat));
				tempList = Sorting.MultiSort<AniDB_Anime_SimilarVM>(tempList, sortCriteria);

				foreach (AniDB_Anime_SimilarVM sim in tempList)
					SimilarAnimeLinks.Add(sim);

				if (SimilarAnimeLinks.Count == 0)
				{
					DataExists = false;
					DataMissing = true;
				}
				else
				{
					DataExists = true;
					DataMissing = false;
				}
			}
			catch (Exception ex)
			{
				Utils.ShowErrorMessage(ex);
			}
		}