Ejemplo n.º 1
0
        private void CreateRelations(ISession session, List<Raw_AniDB_RelatedAnime> rels, bool downloadRelations)
        {
            if (rels == null) return;

            AniDB_Anime_RelationRepository repRels = new AniDB_Anime_RelationRepository();

            List<AniDB_Anime_Relation> relsToSave = new List<AniDB_Anime_Relation>();
            List<CommandRequest_GetAnimeHTTP> cmdsToSave = new List<CommandRequest_GetAnimeHTTP>();

            foreach (Raw_AniDB_RelatedAnime rawrel in rels)
            {
                AniDB_Anime_Relation anime_rel = repRels.GetByAnimeIDAndRelationID(session, rawrel.AnimeID, rawrel.RelatedAnimeID);
                if (anime_rel == null) anime_rel = new AniDB_Anime_Relation();

                anime_rel.Populate(rawrel);
                relsToSave.Add(anime_rel);

                if (downloadRelations && ServerSettings.AutoGroupSeries)
                {
                    logger.Info("Adding command to download related anime for {0} ({1}), related anime ID = {2}",
                        this.MainTitle, this.AnimeID, anime_rel.RelatedAnimeID);

                    // I have disable the downloading of relations here because of banning issues
                    // basically we will download immediate relations, but not relations of relations

                    //CommandRequest_GetAnimeHTTP cr_anime = new CommandRequest_GetAnimeHTTP(rawrel.RelatedAnimeID, false, downloadRelations);
                    CommandRequest_GetAnimeHTTP cr_anime = new CommandRequest_GetAnimeHTTP(anime_rel.RelatedAnimeID, false, false);
                    cmdsToSave.Add(cr_anime);
                }
            }

            using (var transaction = session.BeginTransaction())
            {
                foreach (AniDB_Anime_Relation anime_rel in relsToSave)
                    session.SaveOrUpdate(anime_rel);

                transaction.Commit();
            }

            // this is not part of the session/transaction because it does other operations in the save
            foreach (CommandRequest_GetAnimeHTTP cmd in cmdsToSave)
                cmd.Save();
        }
Ejemplo n.º 2
0
 public List<AniDB_Anime_Relation> GetRelatedAnime(ISession session)
 {
     AniDB_Anime_RelationRepository repRels = new AniDB_Anime_RelationRepository();
     return repRels.GetByAnimeID(session, AnimeID);
 }