Esempio n. 1
0
        public List<Contract_AniDBAnime> GetAnimeForMonth(int jmmuserID, int month, int year)
        {
            AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
            JMMUserRepository repUsers = new JMMUserRepository();

            // get all the series
            List<Contract_AniDBAnime> animeList = new List<Contract_AniDBAnime>();

            try
            {
                JMMUser user = repUsers.GetByID(jmmuserID);
                if (user == null) return animeList;

                DateTime startDate = new DateTime(year, month, 1, 0, 0, 0);
                DateTime endDate = startDate.AddMonths(1);
                endDate = endDate.AddMinutes(-10);

                List<AniDB_Anime> animes = repAnime.GetForDate(startDate, endDate);
                foreach (AniDB_Anime anime in animes)
                {
                    bool useAnime = true;

                    string[] cats = user.HideCategories.ToLower().Split(',');
                    string[] animeCats = anime.AllCategories.ToLower().Split('|');
                    foreach (string cat in cats)
                    {
                        if (!string.IsNullOrEmpty(cat) && animeCats.Contains(cat))
                        {
                            useAnime = false;
                            break;
                        }
                    }

                    if (useAnime)
                        animeList.Add(anime.ToContract());
                }

            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
            return animeList;
        }
Esempio n. 2
0
        public List<Contract_AniDBAnime> GetMiniCalendar(int jmmuserID, int numberOfDays)
        {
            AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
            JMMUserRepository repUsers = new JMMUserRepository();

            // get all the series
            List<Contract_AniDBAnime> animeList = new List<Contract_AniDBAnime>();

            try
            {
                JMMUser user = repUsers.GetByID(jmmuserID);
                if (user == null) return animeList;

                List<AniDB_Anime> animes = repAnime.GetForDate(DateTime.Today.AddDays(0 - numberOfDays), DateTime.Today.AddDays(numberOfDays));
                foreach (AniDB_Anime anime in animes)
                {
                    bool useAnime = true;

                    string[] cats = user.HideCategories.ToLower().Split(',');
                    string[] animeCats = anime.AllCategories.ToLower().Split('|');
                    foreach (string cat in cats)
                    {
                        if (!string.IsNullOrEmpty(cat) && animeCats.Contains(cat))
                        {
                            useAnime = false;
                            break;
                        }
                    }

                    if (useAnime)
                        animeList.Add(anime.ToContract());
                }

            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
            return animeList;
        }
		public List<MetroContract_Anime_Summary> GetAnimeCalendar(int jmmuserID, int startDateSecs, int endDateSecs, int maxRecords)
		{
			List<MetroContract_Anime_Summary> retAnime = new List<MetroContract_Anime_Summary>();
			try
			{
				using (var session = JMMService.SessionFactory.OpenSession())
				{
					AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
					JMMUserRepository repUsers = new JMMUserRepository();
					AnimeSeriesRepository repSeries = new AnimeSeriesRepository();


					JMMUser user = repUsers.GetByID(session, jmmuserID);
					if (user == null) return retAnime;

					DateTime? startDate = Utils.GetAniDBDateAsDate(startDateSecs);
					DateTime? endDate = Utils.GetAniDBDateAsDate(endDateSecs);

					List<AniDB_Anime> animes = repAnime.GetForDate(session, startDate.Value, endDate.Value);
					foreach (AniDB_Anime anidb_anime in animes)
					{

						if (!user.AllowedAnime(anidb_anime)) continue;

						AnimeSeries ser = repSeries.GetByAnimeID(anidb_anime.AnimeID);

						MetroContract_Anime_Summary summ = new MetroContract_Anime_Summary();

						summ.AirDateAsSeconds = anidb_anime.AirDateAsSeconds;
						summ.AnimeID = anidb_anime.AnimeID;
						if (ser != null)
						{
							summ.AnimeName = ser.GetSeriesName(session);
							summ.AnimeSeriesID = ser.AnimeSeriesID;
						}
						else
						{
							summ.AnimeName = anidb_anime.MainTitle;
							summ.AnimeSeriesID = 0;
						}
						summ.BeginYear = anidb_anime.BeginYear;
						summ.EndYear = anidb_anime.EndYear;
						summ.PosterName = anidb_anime.GetDefaultPosterPathNoBlanks(session);

						ImageDetails imgDet = anidb_anime.GetDefaultPosterDetailsNoBlanks(session);
						summ.ImageType = (int)imgDet.ImageType;
						summ.ImageID = imgDet.ImageID;

						retAnime.Add(summ);
						if (retAnime.Count == maxRecords) break;
					}
				}
			}
			catch (Exception ex)
			{
				logger.ErrorException(ex.ToString(), ex);
			}

			return retAnime;
		}