public MetroContract_AniDB_Character ToContractMetro(ISession session, AniDB_Anime_Character charRel)
        {
            MetroContract_AniDB_Character contract = new MetroContract_AniDB_Character();

            contract.AniDB_CharacterID = this.AniDB_CharacterID;
            contract.CharID            = this.CharID;
            contract.CharName          = this.CharName;
            contract.CharKanjiName     = this.CharKanjiName;
            contract.CharDescription   = this.CharDescription;

            contract.CharType = charRel.CharType;

            contract.ImageType = (int)JMMImageType.AniDB_Character;
            contract.ImageID   = this.AniDB_CharacterID;

            AniDB_Seiyuu seiyuu = this.GetSeiyuu(session);

            if (seiyuu != null)
            {
                contract.SeiyuuID        = seiyuu.AniDB_SeiyuuID;
                contract.SeiyuuName      = seiyuu.SeiyuuName;
                contract.SeiyuuImageType = (int)JMMImageType.AniDB_Creator;
                contract.SeiyuuImageID   = seiyuu.AniDB_SeiyuuID;
            }

            return(contract);
        }
		public void Save(AniDB_Seiyuu obj)
		{
			using (var session = JMMService.SessionFactory.OpenSession())
			{
				// populate the database
				using (var transaction = session.BeginTransaction())
				{
					session.SaveOrUpdate(obj);
					transaction.Commit();
				}
			}
		}
Exemple #3
0
        public Contract_AniDB_Character ToContract(string charType, AniDB_Seiyuu seiyuu)
        {
            var contract = new Contract_AniDB_Character
            {
                AniDB_CharacterID = AniDB_CharacterID,
                CharID            = CharID,
                PicName           = PicName,
                CreatorListRaw    = CreatorListRaw,
                CharName          = CharName,
                CharKanjiName     = CharKanjiName,
                CharDescription   = CharDescription,
                CharType          = charType
            };

            if (seiyuu != null)
            {
                contract.Seiyuu = seiyuu.ToContract();
            }

            return(contract);
        }
        public JMMServer.Providers.Azure.AnimeCharacter ToContractAzure(AniDB_Anime_Character charRel)
        {
            JMMServer.Providers.Azure.AnimeCharacter contract = new JMMServer.Providers.Azure.AnimeCharacter();

            contract.CharID          = this.CharID;
            contract.CharName        = this.CharName;
            contract.CharKanjiName   = this.CharKanjiName;
            contract.CharDescription = this.CharDescription;
            contract.CharType        = charRel.CharType;
            contract.CharImageURL    = string.Format(Constants.URLS.AniDB_Images, PicName);

            AniDB_Seiyuu seiyuu = this.GetSeiyuu();

            if (seiyuu != null)
            {
                contract.SeiyuuID       = seiyuu.AniDB_SeiyuuID;
                contract.SeiyuuName     = seiyuu.SeiyuuName;
                contract.SeiyuuImageURL = string.Format(Constants.URLS.AniDB_Images, seiyuu.PicName);
            }

            return(contract);
        }
        public Contract_AniDB_Character ToContract(AniDB_Anime_Character charRel)
        {
            Contract_AniDB_Character contract = new Contract_AniDB_Character();

            contract.AniDB_CharacterID = this.AniDB_CharacterID;
            contract.CharID            = this.CharID;
            contract.PicName           = this.PicName;
            contract.CreatorListRaw    = this.CreatorListRaw;
            contract.CharName          = this.CharName;
            contract.CharKanjiName     = this.CharKanjiName;
            contract.CharDescription   = this.CharDescription;

            contract.CharType = charRel.CharType;

            contract.Seiyuu = null;
            AniDB_Seiyuu seiyuu = this.GetSeiyuu();

            if (seiyuu != null)
            {
                contract.Seiyuu = seiyuu.ToContract();
            }

            return(contract);
        }
Exemple #6
0
        public Contract_AniDB_Character ToContract(string charType)
        {
            AniDB_Seiyuu seiyuu = GetSeiyuu();

            return(ToContract(charType, seiyuu));
        }
Exemple #7
0
        private void CreateCharacters(ISession session, List<Raw_AniDB_Character> chars)
        {
            if (chars == null) return;

            AniDB_CharacterRepository repChars = new AniDB_CharacterRepository();
            AniDB_Anime_CharacterRepository repAnimeChars = new AniDB_Anime_CharacterRepository();
            AniDB_Character_SeiyuuRepository repCharSeiyuu = new AniDB_Character_SeiyuuRepository();
            AniDB_SeiyuuRepository repSeiyuu = new AniDB_SeiyuuRepository();

            // delete all the existing cross references just in case one has been removed
            List<AniDB_Anime_Character> animeChars = repAnimeChars.GetByAnimeID(session, AnimeID);

            using (var transaction = session.BeginTransaction())
            {
                foreach (AniDB_Anime_Character xref in animeChars)
                    session.Delete(xref);

                transaction.Commit();
            }

            List<AniDB_Character> chrsToSave = new List<AniDB_Character>();
            List<AniDB_Anime_Character> xrefsToSave = new List<AniDB_Anime_Character>();

            Dictionary<int, AniDB_Seiyuu> seiyuuToSave = new Dictionary<int, AniDB_Seiyuu>();
            List<AniDB_Character_Seiyuu> seiyuuXrefToSave = new List<AniDB_Character_Seiyuu>();

            // delete existing relationships to seiyuu's
            List<AniDB_Character_Seiyuu> charSeiyuusToDelete = new List<AniDB_Character_Seiyuu>();
            foreach (Raw_AniDB_Character rawchar in chars)
            {
                // delete existing relationships to seiyuu's
                List<AniDB_Character_Seiyuu> allCharSei = repCharSeiyuu.GetByCharID(session, rawchar.CharID);
                foreach (AniDB_Character_Seiyuu xref in allCharSei)
                    charSeiyuusToDelete.Add(xref);
            }
            using (var transaction = session.BeginTransaction())
            {
                foreach (AniDB_Character_Seiyuu xref in charSeiyuusToDelete)
                    session.Delete(xref);

                transaction.Commit();
            }

            foreach (Raw_AniDB_Character rawchar in chars)
            {
                AniDB_Character chr = repChars.GetByCharID(session, rawchar.CharID);
                if (chr == null)
                    chr = new AniDB_Character();

                chr.PopulateFromHTTP(rawchar);
                chrsToSave.Add(chr);

                // create cross ref's between anime and character, but don't actually download anything
                AniDB_Anime_Character anime_char = new AniDB_Anime_Character();
                anime_char.Populate(rawchar);
                xrefsToSave.Add(anime_char);

                foreach (Raw_AniDB_Seiyuu rawSeiyuu in rawchar.Seiyuus)
                {
                    // save the link between character and seiyuu
                    AniDB_Character_Seiyuu acc = repCharSeiyuu.GetByCharIDAndSeiyuuID(session, rawchar.CharID, rawSeiyuu.SeiyuuID);
                    if (acc == null)
                    {
                        acc = new AniDB_Character_Seiyuu();
                        acc.CharID = chr.CharID;
                        acc.SeiyuuID = rawSeiyuu.SeiyuuID;
                        seiyuuXrefToSave.Add(acc);
                    }

                    // save the seiyuu
                    AniDB_Seiyuu seiyuu = repSeiyuu.GetBySeiyuuID(session, rawSeiyuu.SeiyuuID);
                    if (seiyuu == null) seiyuu = new AniDB_Seiyuu();
                    seiyuu.PicName = rawSeiyuu.PicName;
                    seiyuu.SeiyuuID = rawSeiyuu.SeiyuuID;
                    seiyuu.SeiyuuName = rawSeiyuu.SeiyuuName;
                    seiyuuToSave[seiyuu.SeiyuuID] = seiyuu;
                }
            }

            using (var transaction = session.BeginTransaction())
            {
                foreach (AniDB_Character chr in chrsToSave)
                    session.SaveOrUpdate(chr);

                foreach (AniDB_Anime_Character xref in xrefsToSave)
                    session.SaveOrUpdate(xref);

                foreach (AniDB_Seiyuu seiyuu in seiyuuToSave.Values)
                    session.SaveOrUpdate(seiyuu);

                foreach (AniDB_Character_Seiyuu xrefSeiyuu in seiyuuXrefToSave)
                    session.SaveOrUpdate(xrefSeiyuu);

                transaction.Commit();
            }
        }
        private void CreateCharacters(ISession session, List<Raw_AniDB_Character> chars)
        {
            if (chars == null) return;

            ISessionWrapper sessionWrapper = session.Wrap();

            // delete all the existing cross references just in case one has been removed
            List<AniDB_Anime_Character> animeChars = RepoFactory.AniDB_Anime_Character.GetByAnimeID(sessionWrapper, AnimeID);

            RepoFactory.AniDB_Anime_Character.Delete(animeChars);

            List<AniDB_Character> chrsToSave = new List<AniDB_Character>();
            List<AniDB_Anime_Character> xrefsToSave = new List<AniDB_Anime_Character>();

            Dictionary<int, AniDB_Seiyuu> seiyuuToSave = new Dictionary<int, AniDB_Seiyuu>();
            List<AniDB_Character_Seiyuu> seiyuuXrefToSave = new List<AniDB_Character_Seiyuu>();

            // delete existing relationships to seiyuu's
            List<AniDB_Character_Seiyuu> charSeiyuusToDelete = new List<AniDB_Character_Seiyuu>();
            foreach (Raw_AniDB_Character rawchar in chars)
            {
                // delete existing relationships to seiyuu's
                List<AniDB_Character_Seiyuu> allCharSei = RepoFactory.AniDB_Character_Seiyuu.GetByCharID(session, rawchar.CharID);
                foreach (AniDB_Character_Seiyuu xref in allCharSei)
                    charSeiyuusToDelete.Add(xref);
            }
            RepoFactory.AniDB_Character_Seiyuu.Delete(charSeiyuusToDelete);

            foreach (Raw_AniDB_Character rawchar in chars)
            {
                AniDB_Character chr = RepoFactory.AniDB_Character.GetByCharID(sessionWrapper, rawchar.CharID);
                if (chr == null)
                    chr = new AniDB_Character();

                chr.PopulateFromHTTP(rawchar);
                chrsToSave.Add(chr);

                // create cross ref's between anime and character, but don't actually download anything
                AniDB_Anime_Character anime_char = new AniDB_Anime_Character();
                anime_char.Populate(rawchar);
                xrefsToSave.Add(anime_char);

                foreach (Raw_AniDB_Seiyuu rawSeiyuu in rawchar.Seiyuus)
                {
                    // save the link between character and seiyuu
                    AniDB_Character_Seiyuu acc = RepoFactory.AniDB_Character_Seiyuu.GetByCharIDAndSeiyuuID(session, rawchar.CharID,
                        rawSeiyuu.SeiyuuID);
                    if (acc == null)
                    {
                        acc = new AniDB_Character_Seiyuu();
                        acc.CharID = chr.CharID;
                        acc.SeiyuuID = rawSeiyuu.SeiyuuID;
                        seiyuuXrefToSave.Add(acc);
                    }

                    // save the seiyuu
                    AniDB_Seiyuu seiyuu = RepoFactory.AniDB_Seiyuu.GetBySeiyuuID(session, rawSeiyuu.SeiyuuID);
                    if (seiyuu == null) seiyuu = new AniDB_Seiyuu();
                    seiyuu.PicName = rawSeiyuu.PicName;
                    seiyuu.SeiyuuID = rawSeiyuu.SeiyuuID;
                    seiyuu.SeiyuuName = rawSeiyuu.SeiyuuName;
                    seiyuuToSave[seiyuu.SeiyuuID] = seiyuu;
                }
            }
            RepoFactory.AniDB_Character.Save(chrsToSave);
            RepoFactory.AniDB_Anime_Character.Save(xrefsToSave);
            RepoFactory.AniDB_Seiyuu.Save(seiyuuToSave.Values.ToList());
            RepoFactory.AniDB_Character_Seiyuu.Save(seiyuuXrefToSave);
        }
        public Contract_AniDB_Character ToContract(string charType, AniDB_Seiyuu seiyuu)
        {
            var contract = new Contract_AniDB_Character
                {
                    AniDB_CharacterID = AniDB_CharacterID,
                    CharID = CharID,
                    PicName = PicName,
                    CreatorListRaw = CreatorListRaw,
                    CharName = CharName,
                    CharKanjiName = CharKanjiName,
                    CharDescription = CharDescription,
                    CharType = charType
                };

            if (seiyuu != null)
            {
                contract.Seiyuu = seiyuu.ToContract();
            }

            return contract;
        }