public void Save(CrossRef_Languages_AniDB_File obj)
		{
			using (var session = JMMService.SessionFactory.OpenSession())
			{
				// populate the database
				using (var transaction = session.BeginTransaction())
				{
					session.SaveOrUpdate(obj);
					transaction.Commit();
				}
			}
		}
Ejemplo n.º 2
0
		public void CreateLanguages()
		{
			char apostrophe = ("'").ToCharArray()[0];

			LanguageRepository repLanguages = new LanguageRepository();

			if (languagesRAW != null) //Only create relations if the origin of the data if from Raw (WebService/AniDB)
			{
				if (languagesRAW.Trim().Length == 0) return;
				// Delete old if changed

				CrossRef_Languages_AniDB_FileRepository repFileLanguages = new CrossRef_Languages_AniDB_FileRepository();
				

				List<CrossRef_Languages_AniDB_File> fileLanguages = repFileLanguages.GetByFileID(this.FileID);
				foreach (CrossRef_Languages_AniDB_File fLan in fileLanguages)
				{
					repFileLanguages.Delete(fLan.CrossRef_Languages_AniDB_FileID);
				}
	

				string[] langs = languagesRAW.Split(apostrophe);
				foreach (string language in langs)
				{
					string rlan = language.Trim().ToLower();
					if (rlan.Length > 0)
					{
						Language lan = repLanguages.GetByLanguageName(rlan);
						if (lan == null)
						{
							lan = new Language();
							lan.LanguageName = rlan;
							repLanguages.Save(lan);
						}
						CrossRef_Languages_AniDB_File cross = new CrossRef_Languages_AniDB_File();
						cross.LanguageID = lan.LanguageID;
						cross.FileID = FileID;
						repFileLanguages.Save(cross);
					}
				}
			}

			if (subtitlesRAW != null)
			{
				if (subtitlesRAW.Trim().Length == 0) return;

				// Delete old if changed
				CrossRef_Subtitles_AniDB_FileRepository repFileSubtitles = new CrossRef_Subtitles_AniDB_FileRepository();
				List<CrossRef_Subtitles_AniDB_File> fileSubtitles = repFileSubtitles.GetByFileID(this.FileID);

				foreach (CrossRef_Subtitles_AniDB_File fSub in fileSubtitles)
				{
					repFileSubtitles.Delete(fSub.CrossRef_Subtitles_AniDB_FileID);
				}

				string[] subs = subtitlesRAW.Split(apostrophe);
				foreach (string language in subs)
				{
					string rlan = language.Trim().ToLower();
					if (rlan.Length > 0)
					{
						Language lan = repLanguages.GetByLanguageName(rlan);
						if (lan == null)
						{
							lan = new Language();
							lan.LanguageName = rlan;
							repLanguages.Save(lan);
						}
						CrossRef_Subtitles_AniDB_File cross = new CrossRef_Subtitles_AniDB_File();
						cross.LanguageID = lan.LanguageID;
						cross.FileID = FileID;
						repFileSubtitles.Save(cross);
					}
				}
			}
		}
Ejemplo n.º 3
0
        public void CreateLanguages()
        {
            char apostrophe = "'".ToCharArray()[0];

            if (languagesRAW != null) //Only create relations if the origin of the data if from Raw (WebService/AniDB)
            {
                if (languagesRAW.Trim().Length == 0)
                {
                    return;
                }
                // Delete old if changed

                List <CrossRef_Languages_AniDB_File> fileLanguages = RepoFactory.CrossRef_Languages_AniDB_File.GetByFileID(this.FileID);
                foreach (CrossRef_Languages_AniDB_File fLan in fileLanguages)
                {
                    RepoFactory.CrossRef_Languages_AniDB_File.Delete(fLan.CrossRef_Languages_AniDB_FileID);
                }


                string[] langs = languagesRAW.Split(apostrophe);
                foreach (string language in langs)
                {
                    string rlan = language.Trim().ToLower();
                    if (rlan.Length > 0)
                    {
                        Language lan = RepoFactory.Language.GetByLanguageName(rlan);
                        if (lan == null)
                        {
                            lan = new Language();
                            lan.LanguageName = rlan;
                            RepoFactory.Language.Save(lan);
                        }
                        CrossRef_Languages_AniDB_File cross = new CrossRef_Languages_AniDB_File();
                        cross.LanguageID = lan.LanguageID;
                        cross.FileID     = FileID;
                        RepoFactory.CrossRef_Languages_AniDB_File.Save(cross);
                    }
                }
            }

            if (subtitlesRAW != null)
            {
                if (subtitlesRAW.Trim().Length == 0)
                {
                    return;
                }

                // Delete old if changed
                List <CrossRef_Subtitles_AniDB_File> fileSubtitles = RepoFactory.CrossRef_Subtitles_AniDB_File.GetByFileID(this.FileID);

                foreach (CrossRef_Subtitles_AniDB_File fSub in fileSubtitles)
                {
                    RepoFactory.CrossRef_Subtitles_AniDB_File.Delete(fSub.CrossRef_Subtitles_AniDB_FileID);
                }

                string[] subs = subtitlesRAW.Split(apostrophe);
                foreach (string language in subs)
                {
                    string rlan = language.Trim().ToLower();
                    if (rlan.Length > 0)
                    {
                        Language lan = RepoFactory.Language.GetByLanguageName(rlan);
                        if (lan == null)
                        {
                            lan = new Language();
                            lan.LanguageName = rlan;
                            RepoFactory.Language.Save(lan);
                        }
                        CrossRef_Subtitles_AniDB_File cross = new CrossRef_Subtitles_AniDB_File();
                        cross.LanguageID = lan.LanguageID;
                        cross.FileID     = FileID;
                        RepoFactory.CrossRef_Subtitles_AniDB_File.Save(cross);
                    }
                }
            }
        }