Esempio n. 1
0
        public void Delete(int id)
        {
            int oldGroupID = 0;

            using (var session = JMMService.SessionFactory.OpenSession())
            {
                // populate the database
                using (var transaction = session.BeginTransaction())
                {
                    AnimeSeries cr = GetByID(id);
                    if (cr != null)
                    {
                        Cache.Remove(cr);
                        // delete user records
                        AnimeSeries_UserRepository repUsers = new AnimeSeries_UserRepository();
                        foreach (AnimeSeries_User grpUser in repUsers.GetBySeriesID(id))
                        {
                            repUsers.Delete(grpUser.AnimeSeries_UserID);
                        }
                        Changes.Remove(cr.AnimeSeriesID);
                        oldGroupID = cr.AnimeGroupID;
                        session.Delete(cr);
                        transaction.Commit();
                        cr.DeleteFromFilters();
                    }
                }
            }
            if (oldGroupID > 0)
            {
                logger.Trace("Updating group stats by group from AnimeSeriesRepository.Delete: {0}", oldGroupID);
                AnimeGroupRepository repGroups = new AnimeGroupRepository();
                AnimeGroup           oldGroup  = repGroups.GetByID(oldGroupID);
                if (oldGroup != null)
                {
                    repGroups.Save(oldGroup, true, true);
                }
            }
        }
Esempio n. 2
0
        public string DeleteUser(int userID)
        {
            JMMUserRepository repUsers = new JMMUserRepository();

            try
            {
                JMMUser jmmUser = repUsers.GetByID(userID);
                if (jmmUser == null) return "User not found";

                // make sure that at least one user is an admin
                if (jmmUser.IsAdmin == 1)
                {
                    bool adminExists = false;
                    List<JMMUser> users = repUsers.GetAll();
                    foreach (JMMUser userOld in users)
                    {
                        if (userOld.IsAdmin == 1)
                        {
                            if (userOld.JMMUserID != jmmUser.JMMUserID) adminExists = true;
                        }
                    }

                    if (!adminExists) return "At least one user must be an administrator";
                }

                repUsers.Delete(userID);

                // delete all user records
                AnimeSeries_UserRepository repSeries = new AnimeSeries_UserRepository();
                foreach (AnimeSeries_User ser in repSeries.GetByUserID(userID))
                    repSeries.Delete(ser.AnimeSeries_UserID);

                AnimeGroup_UserRepository repGroup = new AnimeGroup_UserRepository();
                foreach (AnimeGroup_User grp in repGroup.GetByUserID(userID))
                    repGroup.Delete(grp.AnimeGroup_UserID);

                AnimeEpisode_UserRepository repEpisode = new AnimeEpisode_UserRepository();
                foreach (AnimeEpisode_User ep in repEpisode.GetByUserID(userID))
                    repEpisode.Delete(ep.AnimeEpisode_UserID);

                VideoLocal_UserRepository repVids = new VideoLocal_UserRepository();
                foreach (VideoLocal_User vid in repVids.GetByUserID(userID))
                    repVids.Delete(vid.VideoLocal_UserID);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return ex.Message;
            }

            return "";
        }
Esempio n. 3
0
        public void IncrementEpisodeStats(int animeEpisodeID, int userID, int statCountType)
        {
            try
            {
                AnimeEpisodeRepository repEpisodes = new AnimeEpisodeRepository();
                AnimeEpisode ep = repEpisodes.GetByID(animeEpisodeID);
                if (ep == null) return;

                AnimeEpisode_UserRepository repEpisodeUsers = new AnimeEpisode_UserRepository();
                AnimeEpisode_User epUserRecord = ep.GetUserRecord(userID);

                if (epUserRecord == null)
                {
                    epUserRecord = new AnimeEpisode_User();
                    epUserRecord.PlayedCount = 0;
                    epUserRecord.StoppedCount = 0;
                    epUserRecord.WatchedCount = 0;
                }
                epUserRecord.AnimeEpisodeID = ep.AnimeEpisodeID;
                epUserRecord.AnimeSeriesID = ep.AnimeSeriesID;
                epUserRecord.JMMUserID = userID;
                //epUserRecord.WatchedDate = DateTime.Now;

                switch ((StatCountType)statCountType)
                {
                    case StatCountType.Played: epUserRecord.PlayedCount++; break;
                    case StatCountType.Stopped: epUserRecord.StoppedCount++; break;
                    case StatCountType.Watched: epUserRecord.WatchedCount++; break;
                }

                repEpisodeUsers.Save(epUserRecord);

                AnimeSeries ser = ep.GetAnimeSeries();
                if (ser == null) return;

                AnimeSeries_UserRepository repSeriesUser = new AnimeSeries_UserRepository();
                AnimeSeries_User userRecord = ser.GetUserRecord(userID);
                if (userRecord == null)
                    userRecord = new AnimeSeries_User(userID, ser.AnimeSeriesID);

                switch ((StatCountType)statCountType)
                {
                    case StatCountType.Played: userRecord.PlayedCount++; break;
                    case StatCountType.Stopped: userRecord.StoppedCount++; break;
                    case StatCountType.Watched: userRecord.WatchedCount++; break;
                }

                repSeriesUser.Save(userRecord);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
        }
Esempio n. 4
0
        public List<Contract_AnimeSeries> GetSeriesWithMissingEpisodes(int maxRecords, int jmmuserID)
        {
            DateTime start = DateTime.Now;
            AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
            AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
            JMMUserRepository repUsers = new JMMUserRepository();

            // get all the series
            List<Contract_AnimeSeries> seriesContractList = new List<Contract_AnimeSeries>();

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

                List<AnimeSeries> series = repSeries.GetWithMissingEpisodes();

                List<AniDB_Anime> animes = repAnime.GetAll();
                Dictionary<int, AniDB_Anime> dictAnimes = new Dictionary<int, AniDB_Anime>();
                foreach (AniDB_Anime anime in animes)
                    dictAnimes[anime.AnimeID] = anime;

                // tvdb
                CrossRef_AniDB_TvDBV2Repository repCrossRef = new CrossRef_AniDB_TvDBV2Repository();
                List<CrossRef_AniDB_TvDBV2> allCrossRefs = repCrossRef.GetAll();
                Dictionary<int, List<CrossRef_AniDB_TvDBV2>> dictCrossRefsV2 = new Dictionary<int, List<CrossRef_AniDB_TvDBV2>>();
                foreach (CrossRef_AniDB_TvDBV2 xref in allCrossRefs)
                {
                    if (!dictCrossRefsV2.ContainsKey(xref.AnimeID))
                        dictCrossRefsV2[xref.AnimeID] = new List<CrossRef_AniDB_TvDBV2>();
                    dictCrossRefsV2[xref.AnimeID].Add(xref);
                }

                // moviedb
                CrossRef_AniDB_OtherRepository repOtherCrossRef = new CrossRef_AniDB_OtherRepository();
                List<CrossRef_AniDB_Other> allOtherCrossRefs = repOtherCrossRef.GetAll();
                Dictionary<int, CrossRef_AniDB_Other> dictMovieCrossRefs = new Dictionary<int, CrossRef_AniDB_Other>();
                foreach (CrossRef_AniDB_Other xref in allOtherCrossRefs)
                {
                    if (xref.CrossRefType == (int)CrossRefType.MovieDB)
                        dictMovieCrossRefs[xref.AnimeID] = xref;
                }

                // MAL
                CrossRef_AniDB_MALRepository repMALCrossRef = new CrossRef_AniDB_MALRepository();
                List<CrossRef_AniDB_MAL> allMALCrossRefs = repMALCrossRef.GetAll();
                Dictionary<int, List<CrossRef_AniDB_MAL>> dictMALCrossRefs = new Dictionary<int, List<CrossRef_AniDB_MAL>>();
                foreach (CrossRef_AniDB_MAL xref in allMALCrossRefs)
                {
                    if (!dictMALCrossRefs.ContainsKey(xref.AnimeID))
                        dictMALCrossRefs[xref.AnimeID] = new List<CrossRef_AniDB_MAL>();
                    dictMALCrossRefs[xref.AnimeID].Add(xref);
                }

                // user records
                AnimeSeries_UserRepository repSeriesUser = new AnimeSeries_UserRepository();
                List<AnimeSeries_User> userRecordList = repSeriesUser.GetByUserID(jmmuserID);
                Dictionary<int, AnimeSeries_User> dictUserRecords = new Dictionary<int, AnimeSeries_User>();
                foreach (AnimeSeries_User serUser in userRecordList)
                    dictUserRecords[serUser.AnimeSeriesID] = serUser;

                int i = 1;
                foreach (AnimeSeries aser in series)
                {
                    if (!dictAnimes.ContainsKey(aser.AniDB_ID)) continue;

                    AniDB_Anime anime = dictAnimes[aser.AniDB_ID];
                    if (!user.AllowedAnime(anime)) continue;

                    List<CrossRef_AniDB_TvDBV2> xrefs = new List<CrossRef_AniDB_TvDBV2>();
                    if (dictCrossRefsV2.ContainsKey(aser.AniDB_ID)) xrefs = dictCrossRefsV2[aser.AniDB_ID];

                    CrossRef_AniDB_Other xrefMovie = null;
                    if (dictMovieCrossRefs.ContainsKey(aser.AniDB_ID)) xrefMovie = dictMovieCrossRefs[aser.AniDB_ID];

                    AnimeSeries_User userRec = null;
                    if (dictUserRecords.ContainsKey(aser.AnimeSeriesID))
                        userRec = dictUserRecords[aser.AnimeSeriesID];

                    List<CrossRef_AniDB_MAL> xrefMAL = null;
                    if (dictMALCrossRefs.ContainsKey(aser.AniDB_ID))
                        xrefMAL = dictMALCrossRefs[aser.AniDB_ID];

                    List<TvDB_Series> sers = new List<TvDB_Series>();
                    foreach (CrossRef_AniDB_TvDBV2 xref in xrefs)
                        sers.Add(xref.GetTvDBSeries());
                    MovieDB_Movie movie = null;
                    if (xrefMovie != null)
                        movie = xrefMovie.GetMovieDB_Movie();
                    seriesContractList.Add(aser.ToContract(dictAnimes[aser.AniDB_ID], xrefs, xrefMovie, userRec,
                        sers, xrefMAL, false, null, null, null, null,movie));

                    if (i == maxRecords) break;

                    i++;
                }

                TimeSpan ts = DateTime.Now - start;
                logger.Info("GetSeriesWithMissingEpisodes in {0} ms", ts.TotalMilliseconds);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
            return seriesContractList;
        }
Esempio n. 5
0
        /// <summary>
        /// Gets a list of episodes watched based on the most recently watched series
        /// It will return the next episode to watch in the most recent 10 series
        /// </summary>
        /// <returns></returns>
        public List<Contract_AnimeEpisode> GetEpisodesToWatch_RecentlyWatched(int maxRecords, int jmmuserID)
        {
            List<Contract_AnimeEpisode> retEps = new List<Contract_AnimeEpisode>();
            try
            {
                using (var session = JMMService.SessionFactory.OpenSession())
                {
                    AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
                    AnimeSeriesRepository repAnimeSer = new AnimeSeriesRepository();
                    AnimeSeries_UserRepository repSeriesUser = new AnimeSeries_UserRepository();
                    JMMUserRepository repUsers = new JMMUserRepository();

                    DateTime start = DateTime.Now;

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

                    // get a list of series that is applicable
                    List<AnimeSeries_User> allSeriesUser = repSeriesUser.GetMostRecentlyWatched(session, jmmuserID);

                    TimeSpan ts = DateTime.Now - start;
                    logger.Info(string.Format("GetEpisodesToWatch_RecentlyWatched:Series: {0}", ts.TotalMilliseconds));
                    start = DateTime.Now;

                    foreach (AnimeSeries_User userRecord in allSeriesUser)
                    {
                        AnimeSeries series = repAnimeSer.GetByID(session, userRecord.AnimeSeriesID);
                        if (series == null) continue;

                        if (!user.AllowedSeries(series)) continue;

                        Contract_AnimeEpisode ep = GetNextUnwatchedEpisode(session, userRecord.AnimeSeriesID, jmmuserID);
                        if (ep != null)
                        {
                            retEps.Add(ep);

                            // Lets only return the specified amount
                            if (retEps.Count == maxRecords)
                            {
                                ts = DateTime.Now - start;
                                logger.Info(string.Format("GetEpisodesToWatch_RecentlyWatched:Episodes: {0}", ts.TotalMilliseconds));
                                return retEps;
                            }
                        }
                    }
                    ts = DateTime.Now - start;
                    logger.Info(string.Format("GetEpisodesToWatch_RecentlyWatched:Episodes: {0}", ts.TotalMilliseconds));
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }

            return retEps;
        }
Esempio n. 6
0
        public List<Contract_AnimeSeries> GetAllSeries(int userID)
        {
            AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
            AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
            AniDB_Anime_TitleRepository repTitles = new AniDB_Anime_TitleRepository();

            //TODO: Custom Tags: Do I need to add custom tags for searches

            // get all the series
            List<Contract_AnimeSeries> seriesContractList = new List<Contract_AnimeSeries>();

            try
            {

                DateTime start = DateTime.Now;
                DateTime start2 = DateTime.Now;

                List<AnimeSeries> series = repSeries.GetAll();

                List<AniDB_Anime> animes = repAnime.GetAll();
                Dictionary<int, AniDB_Anime> dictAnimes = new Dictionary<int, AniDB_Anime>();
                foreach (AniDB_Anime anime in animes)
                    dictAnimes[anime.AnimeID] = anime;

                TimeSpan ts2 = DateTime.Now - start2; logger.Info("GetAllSeries:Anime:RawData in {0} ms", ts2.TotalMilliseconds); start2 = DateTime.Now;

                // tvdb - cross refs
                CrossRef_AniDB_TvDBV2Repository repCrossRef = new CrossRef_AniDB_TvDBV2Repository();
                List<CrossRef_AniDB_TvDBV2> allCrossRefs = repCrossRef.GetAll();
                Dictionary<int, List<CrossRef_AniDB_TvDBV2>> dictCrossRefsV2 = new Dictionary<int, List<CrossRef_AniDB_TvDBV2>>();
                foreach (CrossRef_AniDB_TvDBV2 xref in allCrossRefs)
                {
                    if (!dictCrossRefsV2.ContainsKey(xref.AnimeID))
                        dictCrossRefsV2[xref.AnimeID] = new List<CrossRef_AniDB_TvDBV2>();
                    dictCrossRefsV2[xref.AnimeID].Add(xref);
                }

                ts2 = DateTime.Now - start2; logger.Info("GetAllSeries:TvDB CrossRefs:RawData in {0} ms", ts2.TotalMilliseconds); start2 = DateTime.Now;

                // tvdb - series info
                TvDB_SeriesRepository repTvSeries = new TvDB_SeriesRepository();
                List<TvDB_Series> allTvSeries = repTvSeries.GetAll();
                Dictionary<int, TvDB_Series> dictTvSeries = new Dictionary<int, TvDB_Series>();
                foreach (TvDB_Series tvs in allTvSeries)
                    dictTvSeries[tvs.SeriesID] = tvs;

                ts2 = DateTime.Now - start2; logger.Info("GetAllSeries:TvDB:RawData in {0} ms", ts2.TotalMilliseconds); start2 = DateTime.Now;

                // moviedb
                CrossRef_AniDB_OtherRepository repOtherCrossRef = new CrossRef_AniDB_OtherRepository();
                List<CrossRef_AniDB_Other> allOtherCrossRefs = repOtherCrossRef.GetAll();
                Dictionary<int, CrossRef_AniDB_Other> dictMovieCrossRefs = new Dictionary<int, CrossRef_AniDB_Other>();
                foreach (CrossRef_AniDB_Other xref in allOtherCrossRefs)
                {
                    if (xref.CrossRefType == (int)CrossRefType.MovieDB)
                        dictMovieCrossRefs[xref.AnimeID] = xref;
                }
                ts2 = DateTime.Now - start2; logger.Info("GetAllSeries:MovieDB:RawData in {0} ms", ts2.TotalMilliseconds); start2 = DateTime.Now;

                // MAL
                CrossRef_AniDB_MALRepository repMALCrossRef = new CrossRef_AniDB_MALRepository();
                List<CrossRef_AniDB_MAL> allMALCrossRefs = repMALCrossRef.GetAll();
                Dictionary<int, List<CrossRef_AniDB_MAL>> dictMALCrossRefs = new Dictionary<int, List<CrossRef_AniDB_MAL>>();
                foreach (CrossRef_AniDB_MAL xref in allMALCrossRefs)
                {
                    if (!dictMALCrossRefs.ContainsKey(xref.AnimeID))
                        dictMALCrossRefs[xref.AnimeID] = new List<CrossRef_AniDB_MAL>();
                    dictMALCrossRefs[xref.AnimeID].Add(xref);
                }
                ts2 = DateTime.Now - start2; logger.Info("GetAllSeries:MAL:RawData in {0} ms", ts2.TotalMilliseconds); start2 = DateTime.Now;

                // user records
                AnimeSeries_UserRepository repSeriesUser = new AnimeSeries_UserRepository();
                List<AnimeSeries_User> userRecordList = repSeriesUser.GetByUserID(userID);
                Dictionary<int, AnimeSeries_User> dictUserRecords = new Dictionary<int, AnimeSeries_User>();
                foreach (AnimeSeries_User serUser in userRecordList)
                    dictUserRecords[serUser.AnimeSeriesID] = serUser;

                ts2 = DateTime.Now - start2; logger.Info("GetAllSeries:UserRecs:RawData in {0} ms", ts2.TotalMilliseconds); start2 = DateTime.Now;

                // default images
                AniDB_Anime_DefaultImageRepository repDefImages = new AniDB_Anime_DefaultImageRepository();
                List<AniDB_Anime_DefaultImage> allDefaultImages = repDefImages.GetAll();

                ts2 = DateTime.Now - start2; logger.Info("GetAllSeries:DefaultImages:RawData in {0} ms", ts2.TotalMilliseconds); start2 = DateTime.Now;

                // titles
                List<AniDB_Anime_Title> allTitles = repTitles.GetAllForLocalSeries();
                Dictionary<int, List<AniDB_Anime_Title>> dictTitles = new Dictionary<int, List<AniDB_Anime_Title>>();
                foreach (AniDB_Anime_Title atit in allTitles)
                {
                    if (!dictTitles.ContainsKey(atit.AnimeID))
                        dictTitles[atit.AnimeID] = new List<AniDB_Anime_Title>();

                    dictTitles[atit.AnimeID].Add(atit);
                }

                ts2 = DateTime.Now - start2; logger.Info("GetAllSeries:Titles:RawData in {0} ms", ts2.TotalMilliseconds); start2 = DateTime.Now;

                TimeSpan ts = DateTime.Now - start;
                logger.Info("GetAllSeries:RawData in {0} ms", ts.TotalMilliseconds);

                Dictionary<int, AniDB_Anime_DefaultImage> dictDefaultsPosters = new Dictionary<int, AniDB_Anime_DefaultImage>();
                Dictionary<int, AniDB_Anime_DefaultImage> dictDefaultsFanart = new Dictionary<int, AniDB_Anime_DefaultImage>();
                Dictionary<int, AniDB_Anime_DefaultImage> dictDefaultsWideBanner = new Dictionary<int, AniDB_Anime_DefaultImage>();

                start = DateTime.Now;

                foreach (AniDB_Anime_DefaultImage defaultImage in allDefaultImages)
                {
                    ImageSizeType sizeType = (ImageSizeType)defaultImage.ImageType;

                    if (sizeType == ImageSizeType.Fanart)
                        dictDefaultsFanart[defaultImage.AnimeID] = defaultImage;

                    if (sizeType == ImageSizeType.Poster)
                        dictDefaultsPosters[defaultImage.AnimeID] = defaultImage;

                    if (sizeType == ImageSizeType.WideBanner)
                        dictDefaultsWideBanner[defaultImage.AnimeID] = defaultImage;
                }

                foreach (AnimeSeries aser in series)
                {
                    if (!dictAnimes.ContainsKey(aser.AniDB_ID)) continue;

                    List<CrossRef_AniDB_TvDBV2> xrefs = new List<CrossRef_AniDB_TvDBV2>();
                    if (dictCrossRefsV2.ContainsKey(aser.AniDB_ID)) xrefs = dictCrossRefsV2[aser.AniDB_ID];

                    List<TvDB_Series> tvseriesV2 = new List<TvDB_Series>();
                    if (xrefs != null)
                    {
                        foreach (CrossRef_AniDB_TvDBV2 xref in xrefs)
                        {
                            if (dictTvSeries.ContainsKey(xref.TvDBID))
                                tvseriesV2.Add(dictTvSeries[xref.TvDBID]);
                        }
                    }

                    CrossRef_AniDB_Other xrefMovie = null;
                    if (dictMovieCrossRefs.ContainsKey(aser.AniDB_ID)) xrefMovie = dictMovieCrossRefs[aser.AniDB_ID];

                    List<CrossRef_AniDB_MAL> xrefMAL = null;
                    if (dictMALCrossRefs.ContainsKey(aser.AniDB_ID))
                        xrefMAL = dictMALCrossRefs[aser.AniDB_ID];

                    MovieDB_Movie movie = null;
                    if (xrefMovie != null)
                        movie = xrefMovie.GetMovieDB_Movie();

                    AnimeSeries_User userRec = null;
                    if (dictUserRecords.ContainsKey(aser.AnimeSeriesID))
                        userRec = dictUserRecords[aser.AnimeSeriesID];

                    List<AniDB_Anime_Title> titles = null;
                    if (dictTitles.ContainsKey(aser.AniDB_ID))
                        titles = dictTitles[aser.AniDB_ID];

                    AniDB_Anime_DefaultImage defPoster = null;
                    AniDB_Anime_DefaultImage defFanart = null;
                    AniDB_Anime_DefaultImage defWideBanner = null;

                    if (dictDefaultsPosters.ContainsKey(aser.AniDB_ID)) defPoster = dictDefaultsPosters[aser.AniDB_ID];
                    if (dictDefaultsFanart.ContainsKey(aser.AniDB_ID)) defFanart = dictDefaultsFanart[aser.AniDB_ID];
                    if (dictDefaultsWideBanner.ContainsKey(aser.AniDB_ID)) defWideBanner = dictDefaultsWideBanner[aser.AniDB_ID];

                    seriesContractList.Add(aser.ToContract(dictAnimes[aser.AniDB_ID], xrefs, xrefMovie, userRec, tvseriesV2, xrefMAL, true, defPoster, defFanart, defWideBanner, titles, movie));
                }

                ts = DateTime.Now - start;
                logger.Info("GetAllSeries:ProcessedData in {0} ms", ts.TotalMilliseconds);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
            return seriesContractList;
        }
		public List<MetroContract_Anime_Summary> GetAnimeContinueWatching_old(int maxRecords, int jmmuserID)
		{
			List<MetroContract_Anime_Summary> retAnime = new List<MetroContract_Anime_Summary>();
			try
			{
				using (var session = JMMService.SessionFactory.OpenSession())
				{
					AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
					AnimeSeriesRepository repAnimeSer = new AnimeSeriesRepository();
					AnimeSeries_UserRepository repSeriesUser = new AnimeSeries_UserRepository();
					JMMUserRepository repUsers = new JMMUserRepository();

					DateTime start = DateTime.Now;

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

					// get a list of series that is applicable
					List<AnimeSeries_User> allSeriesUser = repSeriesUser.GetMostRecentlyWatched(session, jmmuserID);

					TimeSpan ts = DateTime.Now - start;
					logger.Info(string.Format("GetAnimeContinueWatching:Series: {0}", ts.TotalMilliseconds));
					

					JMMServiceImplementation imp = new JMMServiceImplementation();
					foreach (AnimeSeries_User userRecord in allSeriesUser)
					{
						start = DateTime.Now;

						AnimeSeries series = repAnimeSer.GetByID(session, userRecord.AnimeSeriesID);
						if (series == null) continue;

						if (!user.AllowedSeries(session, series))
						{
							logger.Info(string.Format("GetAnimeContinueWatching:Skipping Anime - not allowed: {0}", series.AniDB_ID));
							continue;
						}

						AnimeSeries_User serUser = series.GetUserRecord(session, jmmuserID);

						Contract_AnimeEpisode ep = imp.GetNextUnwatchedEpisode(session, userRecord.AnimeSeriesID, jmmuserID);
						if (ep != null)
						{
							AniDB_Anime anidb_anime = series.GetAnime(session);

							MetroContract_Anime_Summary summ = new MetroContract_Anime_Summary();
							summ.AnimeID = series.AniDB_ID;
							summ.AnimeName = series.GetSeriesName(session);
							summ.AnimeSeriesID = series.AnimeSeriesID;
							summ.BeginYear = anidb_anime.BeginYear;
							summ.EndYear = anidb_anime.EndYear;
							//summ.PosterName = anidb_anime.GetDefaultPosterPathNoBlanks(session);

							if (serUser != null)
								summ.UnwatchedEpisodeCount = serUser.UnwatchedEpisodeCount;
							else
								summ.UnwatchedEpisodeCount = 0;

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

							retAnime.Add(summ);

							ts = DateTime.Now - start;
							logger.Info(string.Format("GetAnimeContinueWatching:Anime: {0} - {1}", summ.AnimeName, ts.TotalMilliseconds));

							// Lets only return the specified amount
							if (retAnime.Count == maxRecords) return retAnime;
						}
						else
							logger.Info(string.Format("GetAnimeContinueWatching:Skipping Anime - no episodes: {0}", series.AniDB_ID));

						
					}
				}
			}
			catch (Exception ex)
			{
				logger.ErrorException(ex.ToString(), ex);
			}

			return retAnime;
		}