public void Delete(int id) { int animeID = 0; using (var session = JMMService.SessionFactory.OpenSession()) { // populate the database using (var transaction = session.BeginTransaction()) { AniDB_GroupStatus cr = GetByID(id); if (cr != null) { animeID = cr.AnimeID; session.Delete(cr); transaction.Commit(); } } } if (animeID > 0) { logger.Trace("Updating group stats by anime from AniDB_GroupStatusRepository.Delete: {0}", animeID); StatsCache.Instance.UpdateUsingAnime(animeID); } }
public static void Populate(this AniDB_GroupStatus grpstatus, Raw_AniDB_GroupStatus raw) { grpstatus.AnimeID = raw.AnimeID; grpstatus.GroupID = raw.GroupID; grpstatus.GroupName = raw.GroupName; grpstatus.CompletionState = raw.CompletionState; grpstatus.LastEpisodeNumber = raw.LastEpisodeNumber; grpstatus.Rating = raw.Rating; grpstatus.Votes = raw.Votes; grpstatus.EpisodeRange = raw.EpisodeRange; }
public AniDB_GroupStatus GetByAnimeIDAndGroupID(int animeid, int groupid) { using (var session = JMMService.SessionFactory.OpenSession()) { AniDB_GroupStatus cr = session .CreateCriteria(typeof(AniDB_GroupStatus)) .Add(Restrictions.Eq("AnimeID", animeid)) .Add(Restrictions.Eq("GroupID", groupid)) .UniqueResult <AniDB_GroupStatus>(); return(cr); } }
public void Save(AniDB_GroupStatus obj) { using (var session = JMMService.SessionFactory.OpenSession()) { // populate the database using (var transaction = session.BeginTransaction()) { session.SaveOrUpdate(obj); transaction.Commit(); } } }
public static CL_AniDB_GroupStatus ToClient(this AniDB_GroupStatus g) { return(new CL_AniDB_GroupStatus { AniDB_GroupStatusID = g.AniDB_GroupStatusID, AnimeID = g.AnimeID, GroupID = g.GroupID, GroupName = g.GroupName, CompletionState = g.CompletionState, LastEpisodeNumber = g.LastEpisodeNumber, Rating = g.Rating, Votes = g.Votes, EpisodeRange = g.EpisodeRange }); }
public GroupStatusCollection GetReleaseGroupStatusUDP(int animeID) { if (!Login()) { return(null); } enHelperActivityType ev = enHelperActivityType.NoSuchCreator; AniDBCommand_GetGroupStatus getCmd = null; lock (lockAniDBConnections) { Pause(); getCmd = new AniDBCommand_GetGroupStatus(); getCmd.Init(animeID); SetWaitingOnResponse(true); ev = getCmd.Process(ref soUdp, ref remoteIpEndPoint, curSessionID, new UnicodeEncoding(true, false)); SetWaitingOnResponse(false); } if (ev == enHelperActivityType.GotGroupStatus && getCmd.GrpStatusCollection != null) { // delete existing records AniDB_GroupStatusRepository repGrpStat = new AniDB_GroupStatusRepository(); AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_EpisodeRepository repAniEp = new AniDB_EpisodeRepository(); AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); repGrpStat.DeleteForAnime(animeID); // save the records foreach (Raw_AniDB_GroupStatus raw in getCmd.GrpStatusCollection.Groups) { AniDB_GroupStatus grpstat = new AniDB_GroupStatus(raw); repGrpStat.Save(grpstat); } // updated cached stats // we don't do it in the save method as it would be too many unecessary updates logger.Trace("Updating group stats by anime from GetReleaseGroupStatusUDP: {0}", animeID); StatsCache.Instance.UpdateUsingAnime(animeID); if (getCmd.GrpStatusCollection.LatestEpisodeNumber > 0) { // update the anime with a record of the latest subbed episode AniDB_Anime anime = repAnime.GetByAnimeID(animeID); if (anime != null) { anime.LatestEpisodeNumber = getCmd.GrpStatusCollection.LatestEpisodeNumber; repAnime.Save(anime); // check if we have this episode in the database // if not get it now by updating the anime record List <AniDB_Episode> eps = repAniEp.GetByAnimeIDAndEpisodeNumber(animeID, getCmd.GrpStatusCollection.LatestEpisodeNumber); if (eps.Count == 0) { CommandRequest_GetAnimeHTTP cr_anime = new CommandRequest_GetAnimeHTTP(animeID, true, false); cr_anime.Save(); } // update the missing episode stats on groups and children AnimeSeries series = repSeries.GetByAnimeID(animeID); if (series != null) { series.UpdateStats(true, true, true); //series.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true); } } } } return(getCmd.GrpStatusCollection); }