public void Save(CrossRef_AniDB_Trakt obj)
		{
			using (var session = JMMService.SessionFactory.OpenSession())
			{
				// populate the database
				using (var transaction = session.BeginTransaction())
				{
					session.SaveOrUpdate(obj);
					transaction.Commit();
				}
			}
		}
		// default constructor
		public AddCrossRef_AniDB_TraktRequest(CrossRef_AniDB_Trakt data, string showName)
		{
			this.AnimeID = data.AnimeID;
			this.TraktID = data.TraktID;
			this.Season = data.TraktSeasonNumber;

			string username = ServerSettings.AniDB_Username;
			if (ServerSettings.WebCache_Anonymous)
				username = Constants.AnonWebCacheUsername;

			this.Username = username;
			this.ShowName = showName;
		}
Exemple #3
0
		public static void Send_CrossRef_AniDB_Trakt(CrossRef_AniDB_Trakt data, string showName)
		{
			if (!ServerSettings.WebCache_XRefFileEpisode_Send) return;


			string uri = string.Format("http://{0}/AddCrossRef_AniDB_Trakt.aspx", ServerSettings.WebCache_Address);
			AddCrossRef_AniDB_TraktRequest fhr = new AddCrossRef_AniDB_TraktRequest(data, showName);
			string xml = fhr.ToXML();

			SendData(uri, xml);
		}
Exemple #4
0
		public static void LinkAniDBTrakt(ISession session, int animeID, string traktID, int seasonNumber, bool fromWebCache)
		{
			CrossRef_AniDB_TraktRepository repCrossRef = new CrossRef_AniDB_TraktRepository();
			CrossRef_AniDB_Trakt xrefTemp = repCrossRef.GetByTraktID(traktID, seasonNumber);
			if (xrefTemp != null)
			{
				string msg = string.Format("Not using Trakt link as one already exists {0} ({1}) - {2}", traktID, seasonNumber, animeID);
				logger.Warn(msg);
				return;
			}

			// check if we have this information locally
			// if not download it now
			Trakt_ShowRepository repShow = new Trakt_ShowRepository();
			Trakt_Show traktShow = repShow.GetByTraktID(traktID);
			if (traktShow == null)
			{
				// we download the series info here
				TraktTVShow tvshow = GetShowInfo(traktID);
				if (tvshow == null) return;
			}

			// download fanart, posters
			DownloadAllImages(traktID);

			CrossRef_AniDB_Trakt xref = repCrossRef.GetByAnimeID(animeID);
			if (xref == null)
				xref = new CrossRef_AniDB_Trakt();

			xref.AnimeID = animeID;
			if (fromWebCache)
				xref.CrossRefSource = (int)CrossRefSource.WebCache;
			else
				xref.CrossRefSource = (int)CrossRefSource.User;

			xref.TraktID = traktID;
			xref.TraktSeasonNumber = seasonNumber;
			repCrossRef.Save(xref);

			StatsCache.Instance.UpdateUsingAnime(session, animeID);

			logger.Trace("Changed trakt association: {0}", animeID);

			CommandRequest_WebCacheSendXRefAniDBTrakt req = new CommandRequest_WebCacheSendXRefAniDBTrakt(xref.CrossRef_AniDB_TraktID);
			req.Save();
		}