• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Repositories.AnimeSeriesRepository类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中JMMServer.Repositories.AnimeSeriesRepository的典型用法代码示例。如果您正苦于以下问题:C# AnimeSeriesRepository类的具体用法?C# AnimeSeriesRepository怎么用?C# AnimeSeriesRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AnimeSeriesRepository类属于JMMServer.Repositories命名空间,在下文中一共展示了AnimeSeriesRepository类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetPosterFilenames

		private List<string> GetPosterFilenames(ISession session)
		{
			List<string> allPosters = new List<string>();

			// check if user has specied a fanart to always be used
			if (DefaultAnimeSeriesID.HasValue)
			{
				AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
				AnimeSeries defaultSeries = repSeries.GetByID(session, DefaultAnimeSeriesID.Value);
				if (defaultSeries != null)
				{
					AniDB_Anime anime = defaultSeries.GetAnime(session);
					string defPosterPathNoBlanks = anime.GetDefaultPosterPathNoBlanks(session);

					if (!string.IsNullOrEmpty(defPosterPathNoBlanks) && File.Exists(defPosterPathNoBlanks))
					{
						allPosters.Add(defPosterPathNoBlanks);
						return allPosters;
					}
				}
			}

			foreach (AnimeSeries ser in GetAllSeries(session))
			{
				AniDB_Anime anime = ser.GetAnime(session);
				string defPosterPathNoBlanks = anime.GetDefaultPosterPathNoBlanks(session);

				if (!string.IsNullOrEmpty(defPosterPathNoBlanks) && File.Exists(defPosterPathNoBlanks))
					allPosters.Add(defPosterPathNoBlanks);
			}

			return allPosters;
		}
开发者ID:dizzydezz,项目名称:jmm,代码行数:33,代码来源:AnimeGroup.cs


示例2: ProcessCommand

 public override void ProcessCommand()
 {
     AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
     AnimeSeries ser = repSeries.GetByAnimeID(AnimeID);
     if (ser!=null)
         ser.UpdateStats(true, true, true);
 }
开发者ID:maz0r,项目名称:jmmserver,代码行数:7,代码来源:CommandRequest_RefreshAnime.cs


示例3: ProcessCommand

		public override void ProcessCommand()
		{
			logger.Info("Processing CommandRequest_MALUpdatedWatchedStatus: {0}", AnimeID);

			try
			{
				// find the latest eps to update
				AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
				AniDB_Anime anime = repAnime.GetByAnimeID(AnimeID);
				if (anime == null) return;

				List<CrossRef_AniDB_MAL> crossRefs = anime.GetCrossRefMAL();
				if (crossRefs == null || crossRefs.Count == 0)
					return;

				AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
				AnimeSeries ser = repSeries.GetByAnimeID(AnimeID);
				if (ser == null) return;

				MALHelper.UpdateMALSeries(ser);

			}
			catch (Exception ex)
			{
				logger.Error("Error processing CommandRequest_MALUpdatedWatchedStatus: {0} - {1}", AnimeID, ex.ToString());
				return;
			}
		}
开发者ID:maz0r,项目名称:jmmserver,代码行数:28,代码来源:CommandRequest_MALUpdatedWatchedStatus.cs


示例4: ProcessCommand

		public override void ProcessCommand()
		{
            logger.Info("Get AniDB episode info: {0}", EpisodeID);

			
			try
			{
                // we don't use this command to update episode info
                // we actually use it to update the cross ref info instead
                // and we only use it for the "Other Episodes" section of the FILE command
                // because that field doesn't tell you what anime it belongs to

                CrossRef_File_EpisodeRepository repCrossRefs = new CrossRef_File_EpisodeRepository();
                List<CrossRef_File_Episode> xrefs = repCrossRefs.GetByEpisodeID(EpisodeID);
                if (xrefs.Count == 0) return;

                Raw_AniDB_Episode epInfo = JMMService.AnidbProcessor.GetEpisodeInfo(EpisodeID);
                if (epInfo != null)
				{
                    AnimeSeriesRepository repSeries = new AnimeSeriesRepository();

                    foreach (CrossRef_File_Episode xref in xrefs)
                    {
                        int oldAnimeID = xref.AnimeID;
                        xref.AnimeID = epInfo.AnimeID;
                        repCrossRefs.Save(xref);


                        AnimeSeries ser = repSeries.GetByAnimeID(oldAnimeID);
                        if (ser != null)
                            ser.UpdateStats(true, true, true);
                        StatsCache.Instance.UpdateUsingAnime(oldAnimeID);

                        ser = repSeries.GetByAnimeID(epInfo.AnimeID);
                        if (ser != null)
                            ser.UpdateStats(true, true, true);
                        StatsCache.Instance.UpdateUsingAnime(epInfo.AnimeID);
                    }
				}
				
			}
			catch (Exception ex)
			{
                logger.Error("Error processing CommandRequest_GetEpisode: {0} - {1}", EpisodeID, ex.ToString());
				return;
			}
		}
开发者ID:dizzydezz,项目名称:jmm,代码行数:47,代码来源:CommandRequest_GetEpisode.cs


示例5: ProcessCommand

		public override void ProcessCommand()
		{
			logger.Info("Processing CommandRequest_TraktSyncCollectionSeries");

			try
			{
				AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
				AnimeSeries series = repSeries.GetByID(AnimeSeriesID);
				if (series == null)
				{
					logger.Error("Could not find anime series: {0}", AnimeSeriesID);
					return;
				}

				TraktTVHelper.SyncCollectionToTrakt_Series(series);
			}
			catch (Exception ex)
			{
				logger.Error("Error processing CommandRequest_TraktSyncCollectionSeries: {0}", ex.ToString());
				return;
			}
		}
开发者ID:dizzydezz,项目名称:jmm,代码行数:22,代码来源:CommandRequest_TraktSyncCollectionSeries.cs


示例6: SyncCollectionToTrakt

        public static void SyncCollectionToTrakt()
        {
            try
            {
                if (!ServerSettings.Trakt_IsEnabled || string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken)) return;

                // check that we have at least one user nominated for Trakt
                JMMUserRepository repUsers = new JMMUserRepository();
                List<JMMUser> traktUsers = repUsers.GetTraktUsers();
                if (traktUsers.Count == 0) return;

                AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
                List<AnimeSeries> allSeries = repSeries.GetAll();

                // now get the full users collection from Trakt
                List<TraktV2ShowCollectedResult> collected = new List<TraktV2ShowCollectedResult>();
                List<TraktV2ShowWatchedResult> watched = new List<TraktV2ShowWatchedResult>();

                if (!GetTraktCollectionInfo(ref collected, ref watched)) return;

                TraktV2SyncCollectionEpisodesByNumber syncCollectionAdd = new TraktV2SyncCollectionEpisodesByNumber();
                TraktV2SyncCollectionEpisodesByNumber syncCollectionRemove = new TraktV2SyncCollectionEpisodesByNumber();
                TraktV2SyncWatchedEpisodesByNumber syncHistoryAdd = new TraktV2SyncWatchedEpisodesByNumber();
                TraktV2SyncWatchedEpisodesByNumber syncHistoryRemove = new TraktV2SyncWatchedEpisodesByNumber();

                #region Local Collection Sync

                ///////////////////////////////////////////////////////////////////////////////////////
                // First take a look at our local collection and update on Trakt
                ///////////////////////////////////////////////////////////////////////////////////////

                AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
                int counter = 0;
                foreach (AnimeSeries series in allSeries)
                {
                    counter++;
                    logger.Trace("Syncing check -  local collection: {0} / {1} - {2}", counter, allSeries.Count, series.GetSeriesName());

                    AniDB_Anime anime = repAnime.GetByAnimeID(series.AniDB_ID);
                    if (anime == null) continue;

                    //if (anime.AnimeID != 3427) continue;

                    TraktSummaryContainer traktSummary = new TraktSummaryContainer();
                    traktSummary.Populate(series.AniDB_ID);
                    if (traktSummary.CrossRefTraktV2 == null || traktSummary.CrossRefTraktV2.Count == 0) continue;

                    // get the current watched records for this series on Trakt

                    foreach (AnimeEpisode ep in series.GetAnimeEpisodes())
                    {
                        if (ep.EpisodeTypeEnum == enEpisodeType.Episode || ep.EpisodeTypeEnum == enEpisodeType.Special)
                        {
                            EpisodeSyncDetails epsync = ReconSyncTraktEpisode(series, ep, traktSummary, traktUsers, collected, watched, false);
                            if (epsync != null)
                            {
                                switch (epsync.SyncType)
                                {
                                    case TraktSyncType.CollectionAdd:
                                        syncCollectionAdd.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break;
                                    case TraktSyncType.CollectionRemove:
                                        syncCollectionRemove.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break;
                                    case TraktSyncType.HistoryAdd:
                                        syncHistoryAdd.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break;
                                    case TraktSyncType.HistoryRemove:
                                        syncHistoryRemove.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break;
                                }
                            }
                        }
                    }
                }
                #endregion

                // refresh online info, just in case it was chnaged by the last operations
                if (!GetTraktCollectionInfo(ref collected, ref watched)) return;

                #region Online Collection Sync
                ///////////////////////////////////////////////////////////////////////////////////////
                // Now look at the collection according to Trakt, and remove it if we don't have it locally
                ///////////////////////////////////////////////////////////////////////////////////////

                CrossRef_AniDB_TraktV2Repository repCrossRef = new CrossRef_AniDB_TraktV2Repository();

                counter = 0;
                foreach (TraktV2ShowCollectedResult col in collected)
                {
                    counter++;
                    logger.Trace("Syncing check - Online collection: {0} / {1} - {2}", counter, collected.Count, col.show.Title);
                    //continue;

                    // check if we have this series locally
                    List<CrossRef_AniDB_TraktV2> xrefs = repCrossRef.GetByTraktID(col.show.ids.slug);

                    if (xrefs.Count > 0)
                    {
                        foreach (CrossRef_AniDB_TraktV2 xref in xrefs)
                        {
                            AnimeSeries locSeries = repSeries.GetByAnimeID(xref.AnimeID);
                            if (locSeries == null) continue;

//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


示例7: IncrementalTvDBUpdate

		/// <summary>
		/// Used to get a list of TvDB Series ID's that require updating
		/// </summary>
		/// <param name="tvDBIDs">The list Of Series ID's that need to be updated. Pass in an empty list</param>
		/// <returns>The current server time before the update started</returns>
		public string IncrementalTvDBUpdate(ref List<int> tvDBIDs, ref bool tvDBOnline)
		{
			// check if we have record of doing an automated update for the TvDB previously
			// if we have then we have kept a record of the server time and can do a delta update
			// otherwise we need to do a full update and keep a record of the time

			List<int> allTvDBIDs = new List<int>();
			tvDBIDs = new List<int>();
			tvDBOnline = true;

			try
			{
				CrossRef_AniDB_TvDBRepository repCrossRef = new CrossRef_AniDB_TvDBRepository();
				AnimeSeriesRepository repSeries = new AnimeSeriesRepository();

				// record the tvdb server time when we started
				// we record the time now instead of after we finish, to include any possible misses
				string currentTvDBServerTime = CurrentServerTime;
				if (currentTvDBServerTime.Length == 0)
				{
					tvDBOnline = false;
					return currentTvDBServerTime;
				}

				foreach (AnimeSeries ser in repSeries.GetAll())
				{
					List<CrossRef_AniDB_TvDBV2> xrefs = ser.GetCrossRefTvDBV2();
					if (xrefs == null) continue;

					foreach (CrossRef_AniDB_TvDBV2 xref in xrefs)
					{
						if (!allTvDBIDs.Contains(xref.TvDBID)) allTvDBIDs.Add(xref.TvDBID);
					}
				}

				// get the time we last did a TvDB update
				// if this is the first time it will be null
				// update the anidb info ever 24 hours
				ScheduledUpdateRepository repSched = new ScheduledUpdateRepository();
				ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.TvDBInfo);

				string lastServerTime = "";
				if (sched != null)
				{
					TimeSpan ts = DateTime.Now - sched.LastUpdate;
					logger.Trace("Last tvdb info update was {0} hours ago", ts.TotalHours.ToString());
					if (!string.IsNullOrEmpty(sched.UpdateDetails))
						lastServerTime = sched.UpdateDetails;

					// the UpdateDetails field for this type will actually contain the last server time from
					// TheTvDB that a full update was performed
				}


				// get a list of updates from TvDB since that time
				if (lastServerTime.Length > 0)
				{
					List<int> seriesList = GetUpdatedSeriesList(lastServerTime);
					logger.Trace("{0} series have been updated since last download", seriesList.Count.ToString());
					logger.Trace("{0} TvDB series locally", allTvDBIDs.Count.ToString());

					foreach (int id in seriesList)
					{
						if (allTvDBIDs.Contains(id)) tvDBIDs.Add(id);
					}
					logger.Trace("{0} TvDB local series have been updated since last download", tvDBIDs.Count.ToString());
				}
				else
				{
					// use the full list
					tvDBIDs = allTvDBIDs;
				}

				return currentTvDBServerTime;
			}
			catch (Exception ex)
			{
				logger.ErrorException("IncrementalTvDBUpdate: "+ ex.ToString(), ex);
				return "";
			}
		}
开发者ID:maz0r,项目名称:jmmserver,代码行数:86,代码来源:TvDBHelper.cs


示例8: workerMyAnime2_DoWork

		void workerMyAnime2_DoWork(object sender, DoWorkEventArgs e)
		{
			MA2Progress ma2Progress = new MA2Progress();
			ma2Progress.CurrentFile = 0;
			ma2Progress.ErrorMessage = "";
			ma2Progress.MigratedFiles = 0;
			ma2Progress.TotalFiles = 0;

			try
			{
				string databasePath = e.Argument as string;

				string connString = string.Format(@"data source={0};useutf16encoding=True", databasePath);
				SQLiteConnection myConn = new SQLiteConnection(connString);
				myConn.Open();

				// get a list of unlinked files
				VideoLocalRepository repVids = new VideoLocalRepository();
				AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository();
				AniDB_AnimeRepository repAniAnime = new AniDB_AnimeRepository();
				AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
				AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();

				List<VideoLocal> vids = repVids.GetVideosWithoutEpisode();
				ma2Progress.TotalFiles = vids.Count;

				foreach (VideoLocal vid in vids)
				{
					ma2Progress.CurrentFile = ma2Progress.CurrentFile + 1;
					workerMyAnime2.ReportProgress(0, ma2Progress);

					// search for this file in the XrossRef table in MA2
					string sql = string.Format("SELECT AniDB_EpisodeID from CrossRef_Episode_FileHash WHERE Hash = '{0}' AND FileSize = {1}", vid.ED2KHash, vid.FileSize);
					SQLiteCommand sqCommand = new SQLiteCommand(sql);
					sqCommand.Connection = myConn;

					SQLiteDataReader myReader = sqCommand.ExecuteReader();
					while (myReader.Read())
					{
						int episodeID = 0;
						if (!int.TryParse(myReader.GetValue(0).ToString(), out episodeID)) continue;
						if (episodeID <= 0) continue;

						sql = string.Format("SELECT AnimeID from AniDB_Episode WHERE EpisodeID = {0}", episodeID);
						sqCommand = new SQLiteCommand(sql);
						sqCommand.Connection = myConn;

						SQLiteDataReader myReader2 = sqCommand.ExecuteReader();
						while (myReader2.Read())
						{
							int animeID = myReader2.GetInt32(0);

							// so now we have all the needed details we can link the file to the episode
							// as long as wehave the details in JMM
							AniDB_Anime anime = null;
							AniDB_Episode ep = repAniEps.GetByEpisodeID(episodeID);
							if (ep == null)
							{
								logger.Debug("Getting Anime record from AniDB....");
								anime = JMMService.AnidbProcessor.GetAnimeInfoHTTP(animeID, true, ServerSettings.AutoGroupSeries);
							}
							else
								anime = repAniAnime.GetByAnimeID(animeID);

							// create the group/series/episode records if needed
							AnimeSeries ser = null;
							if (anime == null) continue;

							logger.Debug("Creating groups, series and episodes....");
							// check if there is an AnimeSeries Record associated with this AnimeID
							ser = repSeries.GetByAnimeID(animeID);
							if (ser == null)
							{
								// create a new AnimeSeries record
								ser = anime.CreateAnimeSeriesAndGroup();
							}


							ser.CreateAnimeEpisodes();

							// check if we have any group status data for this associated anime
							// if not we will download it now
							AniDB_GroupStatusRepository repStatus = new AniDB_GroupStatusRepository();
							if (repStatus.GetByAnimeID(anime.AnimeID).Count == 0)
							{
								CommandRequest_GetReleaseGroupStatus cmdStatus = new CommandRequest_GetReleaseGroupStatus(anime.AnimeID, false);
								cmdStatus.Save();
							}

							// update stats
							ser.EpisodeAddedDate = DateTime.Now;
							repSeries.Save(ser);

							AnimeGroupRepository repGroups = new AnimeGroupRepository();
							foreach (AnimeGroup grp in ser.AllGroupsAbove)
							{
								grp.EpisodeAddedDate = DateTime.Now;
								repGroups.Save(grp);
							}

//.........这里部分代码省略.........
开发者ID:dizzydezz,项目名称:jmm,代码行数:101,代码来源:MainWindow.xaml.cs


示例9: ProcessCommand

		public override void ProcessCommand()
		{
			logger.Info("Processing CommandRequest_GetReleaseGroupStatus: {0}", AnimeID);

			try
			{
				// only get group status if we have an associated series
				AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
				AnimeSeries series = repSeries.GetByAnimeID(AnimeID);
				if (series == null) return;

				AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
				AniDB_Anime anime = repAnime.GetByAnimeID(AnimeID);
				if (anime == null) return;

				// don't get group status if the anime has already ended more than 50 days ago
				bool skip = false;
				if (!ForceRefresh)
				{
					if (anime.EndDate.HasValue)
					{
						if (anime.EndDate.Value < DateTime.Now)
						{
							TimeSpan ts = DateTime.Now - anime.EndDate.Value;
							if (ts.TotalDays > 50)
							{
								// don't skip if we have never downloaded this info before
								AniDB_GroupStatusRepository repGrpStatus = new AniDB_GroupStatusRepository();
								List<AniDB_GroupStatus> grpStatuses = repGrpStatus.GetByAnimeID(AnimeID);
								if (grpStatuses != null && grpStatuses.Count > 0)
								{
									skip = true;
								}
							}
						}
					}
				}

				if (skip)
				{
					logger.Info("Skipping group status command because anime has already ended: {0}", anime.ToString());
					return;
				}

				GroupStatusCollection grpCol = JMMService.AnidbProcessor.GetReleaseGroupStatusUDP(AnimeID);

				if (ServerSettings.AniDB_DownloadReleaseGroups)
				{
					// save in bulk to improve performance
					using (var session = JMMService.SessionFactory.OpenSession())
					{
						using (var transaction = session.BeginTransaction())
						{
							foreach (Raw_AniDB_GroupStatus grpStatus in grpCol.Groups)
							{
								CommandRequest_GetReleaseGroup cmdRelgrp = new CommandRequest_GetReleaseGroup(grpStatus.GroupID, false);
								session.SaveOrUpdate(cmdRelgrp);
							}

							transaction.Commit();
						}
					}

					
				}

				//}

			}
			catch (Exception ex)
			{
				logger.Error("Error processing CommandRequest_GetReleaseGroupStatus: {0} - {1}", AnimeID, ex.ToString());
				return;
			}
		}
开发者ID:dizzydezz,项目名称:jmm,代码行数:75,代码来源:CommandRequest_GetReleaseGroupStatus.cs


示例10: SetDefaultSeriesForGroup

        public void SetDefaultSeriesForGroup(int animeGroupID, int animeSeriesID)
        {
            try
            {
                AnimeGroupRepository repGroups = new AnimeGroupRepository();
                AnimeSeriesRepository repSeries = new AnimeSeriesRepository();

                AnimeGroup grp = repGroups.GetByID(animeGroupID);
                if (grp == null) return;

                AnimeSeries ser = repSeries.GetByID(animeSeriesID);
                if (ser == null) return;

                grp.DefaultAnimeSeriesID = animeSeriesID;
                repGroups.Save(grp);

            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
        }
开发者ID:,项目名称:,代码行数:22,代码来源:


示例11: DeleteAnimeSeries

        /// <summary>
        /// Delete a series, and everything underneath it (episodes, files)
        /// </summary>
        /// <param name="animeSeriesID"></param>
        /// <param name="deleteFiles">also delete the physical files</param>
        /// <returns></returns>
        public string DeleteAnimeSeries(int animeSeriesID, bool deleteFiles, bool deleteParentGroup)
        {
            try
            {
                AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
                AnimeSeriesRepository repAnimeSer = new AnimeSeriesRepository();
                VideoLocalRepository repVids = new VideoLocalRepository();
                AnimeGroupRepository repGroups = new AnimeGroupRepository();

                AnimeSeries ser = repAnimeSer.GetByID(animeSeriesID);
                if (ser == null) return "Series does not exist";

                int animeGroupID = ser.AnimeGroupID;

                foreach (AnimeEpisode ep in ser.GetAnimeEpisodes())
                {
                    foreach (VideoLocal vid in ep.GetVideoLocals())
                    {
                        if (deleteFiles)
                        {
                            logger.Info("Deleting video local record and file: {0}", vid.FullServerPath);
                            if (!File.Exists(vid.FullServerPath)) return "File could not be found";
                            File.Delete(vid.FullServerPath);
                        }
                        CommandRequest_DeleteFileFromMyList cmdDel = new CommandRequest_DeleteFileFromMyList(vid.Hash, vid.FileSize);
                        cmdDel.Save();

                        repVids.Delete(vid.VideoLocalID);
                    }

                    repEps.Delete(ep.AnimeEpisodeID);
                }
                repAnimeSer.Delete(ser.AnimeSeriesID);

                // finally update stats
                AnimeGroup grp = repGroups.GetByID(animeGroupID);
                if (grp != null)
                {
                    if (grp.GetAllSeries().Count == 0)
                    {
                        DeleteAnimeGroup(grp.AnimeGroupID, false);
                    }
                    else
                    {
                        grp.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
                        StatsCache.Instance.UpdateUsingGroup(grp.TopLevelAnimeGroup.AnimeGroupID);
                    }
                }

                return "";

            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return ex.Message;
            }
        }
开发者ID:,项目名称:,代码行数:64,代码来源:


示例12: GetTopLevelGroupForSeries

        public Contract_AnimeGroup GetTopLevelGroupForSeries(int animeSeriesID, int userID)
        {
            try
            {
                AnimeGroupRepository repGroups = new AnimeGroupRepository();
                AnimeSeriesRepository repSeries = new AnimeSeriesRepository();

                AnimeSeries ser = repSeries.GetByID(animeSeriesID);
                if (ser == null) return null;

                AnimeGroup grp = ser.TopLevelAnimeGroup;
                if (grp == null) return null;

                return grp.ToContract(grp.GetUserRecord(userID));

            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }

            return null;
        }
开发者ID:,项目名称:,代码行数:23,代码来源:


示例13: GetSimilarAnimeLinks

        public List<Contract_AniDB_Anime_Similar> GetSimilarAnimeLinks(int animeID, int userID)
        {
            List<Contract_AniDB_Anime_Similar> links = new List<Contract_AniDB_Anime_Similar>();
            try
            {
                AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
                AniDB_Anime anime = repAnime.GetByAnimeID(animeID);
                if (anime == null) return links;

                JMMUserRepository repUsers = new JMMUserRepository();
                JMMUser juser = repUsers.GetByID(userID);
                if (juser == null) return links;

                AnimeSeriesRepository repSeries = new AnimeSeriesRepository();

                foreach (AniDB_Anime_Similar link in anime.GetSimilarAnime())
                {
                    AniDB_Anime animeLink = repAnime.GetByAnimeID(link.SimilarAnimeID);
                    if (animeLink != null)
                    {
                        if (!juser.AllowedAnime(animeLink)) continue;
                    }

                    // check if this anime has a series
                    AnimeSeries ser = repSeries.GetByAnimeID(link.SimilarAnimeID);

                    links.Add(link.ToContract(animeLink, ser, userID));
                }

                return links;
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return links;
            }
        }
开发者ID:,项目名称:,代码行数:37,代码来源:


示例14: GetSeriesWithoutAnyFiles

        public List<Contract_AnimeSeries> GetSeriesWithoutAnyFiles(int userID)
        {
            List<Contract_AnimeSeries> contracts = new List<Contract_AnimeSeries>();

            VideoLocalRepository repVids = new VideoLocalRepository();
            AnimeSeriesRepository repSeries = new AnimeSeriesRepository();

            try
            {
                foreach (AnimeSeries ser in repSeries.GetAll())
                {
                    if (repVids.GetByAniDBAnimeID(ser.AniDB_ID).Count == 0)
                    {
                        contracts.Add(ser.ToContract(ser.GetUserRecord(userID)));
                    }
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
            return contracts;
        }
开发者ID:,项目名称:,代码行数:23,代码来源:


示例15: DeleteAnimeGroup

        public string DeleteAnimeGroup(int animeGroupID, bool deleteFiles)
        {
            try
            {
                AnimeSeriesRepository repAnimeSer = new AnimeSeriesRepository();
                AnimeGroupRepository repGroups = new AnimeGroupRepository();

                AnimeGroup grp = repGroups.GetByID(animeGroupID);
                if (grp == null) return "Group does not exist";

                int? parentGroupID = grp.AnimeGroupParentID;

                foreach (AnimeSeries ser in grp.GetAllSeries())
                {
                    DeleteAnimeSeries(ser.AnimeSeriesID, deleteFiles, false);
                }

                // delete all sub groups
                foreach (AnimeGroup subGroup in grp.GetAllChildGroups())
                {
                    DeleteAnimeGroup(subGroup.AnimeGroupID, deleteFiles);
                }

                GroupFilterConditionRepository repConditions = new GroupFilterConditionRepository();
                // delete any group filter conditions which reference these groups
                foreach (GroupFilterCondition gfc in repConditions.GetByConditionType(GroupFilterConditionType.AnimeGroup))
                {
                    int thisGrpID = 0;
                    int.TryParse(gfc.ConditionParameter, out thisGrpID);
                    if (thisGrpID == animeGroupID)
                        repConditions.Delete(gfc.GroupFilterConditionID);
                }

                repGroups.Delete(grp.AnimeGroupID);

                // finally update stats

                if (parentGroupID.HasValue)
                {
                    AnimeGroup grpParent = repGroups.GetByID(parentGroupID.Value);

                    if (grpParent != null)
                    {
                        grpParent.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
                        StatsCache.Instance.UpdateUsingGroup(grpParent.TopLevelAnimeGroup.AnimeGroupID);
                    }
                }

                return "";

            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return ex.Message;
            }
        }
开发者ID:,项目名称:,代码行数:57,代码来源:


示例16: SaveSeries

        public Contract_AnimeSeries_SaveResponse SaveSeries(Contract_AnimeSeries_Save contract, int userID)
        {
            Contract_AnimeSeries_SaveResponse contractout = new Contract_AnimeSeries_SaveResponse();
            contractout.ErrorMessage = "";
            contractout.AnimeSeries = null;
            try
            {
                AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
                AnimeSeries ser = null;

                int? oldGroupID = null;
                if (contract.AnimeSeriesID.HasValue)
                {
                    ser = repSeries.GetByID(contract.AnimeSeriesID.Value);
                    if (ser == null)
                    {
                        contractout.ErrorMessage = "Could not find existing series with ID: " + contract.AnimeSeriesID.Value.ToString();
                        return contractout;
                    }

                    // check if we are moving a series
                    oldGroupID = ser.AnimeGroupID;
                }
                else
                {
                    ser = new AnimeSeries();
                    ser.DateTimeCreated = DateTime.Now;
                    ser.DefaultAudioLanguage = "";
                    ser.DefaultSubtitleLanguage = "";
                    ser.MissingEpisodeCount = 0;
                    ser.MissingEpisodeCountGroups = 0;
                    ser.LatestLocalEpisodeNumber = 0;
                    ser.SeriesNameOverride = "";
                }

                ser.AnimeGroupID = contract.AnimeGroupID;
                ser.AniDB_ID = contract.AniDB_ID;
                ser.DefaultAudioLanguage = contract.DefaultAudioLanguage;
                ser.DefaultSubtitleLanguage = contract.DefaultSubtitleLanguage;
                ser.DateTimeUpdated = DateTime.Now;
                ser.SeriesNameOverride = contract.SeriesNameOverride;
                ser.DefaultFolder = contract.DefaultFolder;

                AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
                AniDB_Anime anime = repAnime.GetByAnimeID(ser.AniDB_ID);
                if (anime == null)
                {
                    contractout.ErrorMessage = string.Format("Could not find anime record with ID: {0}", ser.AniDB_ID);
                    return contractout;
                }

                repSeries.Save(ser);

                // update stats for groups
                //ser.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true ,true, true);
                ser.QueueUpdateStats();

                if (oldGroupID.HasValue)
                {
                    AnimeGroupRepository repGroups = new AnimeGroupRepository();
                    AnimeGroup grp = repGroups.GetByID(oldGroupID.Value);
                    if (grp != null)
                    {
                        grp.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
                    }
                }
                List<CrossRef_AniDB_TvDBV2> xrefs = ser.GetCrossRefTvDBV2();
                List<CrossRef_AniDB_MAL> xrefMAL = ser.CrossRefMAL;

                List<TvDB_Series> sers = new List<TvDB_Series>();
                foreach (CrossRef_AniDB_TvDBV2 xref in xrefs)
                    sers.Add(xref.GetTvDBSeries());
                CrossRef_AniDB_Other xrefMovie = ser.CrossRefMovieDB;
                MovieDB_Movie movie = null;
                if (xrefMovie != null)
                    movie = xrefMovie.GetMovieDB_Movie();
                contractout.AnimeSeries = ser.ToContract(anime, xrefs, ser.CrossRefMovieDB, ser.GetUserRecord(userID),
                    sers, xrefMAL, false, null, null, null, null,movie);

                return contractout;
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                contractout.ErrorMessage = ex.Message;
                return contractout;
            }
        }
开发者ID:,项目名称:,代码行数:88,代码来源:


示例17: SaveUser

        public string SaveUser(Contract_JMMUser user)
        {
            JMMUserRepository repUsers = new JMMUserRepository();

            try
            {
                bool existingUser = false;
                bool updateStats = false;
                JMMUser jmmUser = null;
                if (user.JMMUserID.HasValue)
                {
                    jmmUser = repUsers.GetByID(user.JMMUserID.Value);
                    if (jmmUser == null) return "User not found";
                    existingUser = true;
                }
                else
                {
                    jmmUser = new JMMUser();
                    updateStats = true;
                }

                if (existingUser && jmmUser.IsAniDBUser != user.IsAniDBUser)
                    updateStats = true;

                jmmUser.HideCategories = user.HideCategories;
                jmmUser.IsAniDBUser = user.IsAniDBUser;
                jmmUser.IsTraktUser = user.IsTraktUser;
                jmmUser.IsAdmin = user.IsAdmin;
                jmmUser.Username = user.Username;
                jmmUser.CanEditServerSettings = user.CanEditServerSettings;
                jmmUser.PlexUsers = user.PlexUsers;
                if (string.IsNullOrEmpty(user.Password))
                    jmmUser.Password = "";

                // make sure that at least one user is an admin
                if (jmmUser.IsAdmin == 0)
                {
                    bool adminExists = false;
                    List<JMMUser> users = repUsers.GetAll();
                    foreach (JMMUser userOld in users)
                    {
                        if (userOld.IsAdmin == 1)
                        {
                            if (existingUser)
                            {
                                if (userOld.JMMUserID != jmmUser.JMMUserID) adminExists = true;
                            }
                            else
                                adminExists = true;

                        }
                    }

                    if (!adminExists) return "At least one user must be an administrator";
                }

                repUsers.Save(jmmUser);

                // update stats
                if (updateStats)
                {
                    AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
                    foreach (AnimeSeries ser in repSeries.GetAll())
                        ser.QueueUpdateStats();
                }

            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return ex.Message;
            }

            return "";
        }
开发者ID:,项目名称:,代码行数:75,代码来源:


示例18: MoveSeries

        public Contract_AnimeSeries_SaveResponse MoveSeries(int animeSeriesID, int newAnimeGroupID, int userID)
        {
            Contract_AnimeSeries_SaveResponse contractout = new Contract_AnimeSeries_SaveResponse();
            contractout.ErrorMessage = "";
            contractout.AnimeSeries = null;
            try
            {

                AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
                AnimeSeries ser = null;

                ser = repSeries.GetByID(animeSeriesID);
                if (ser == null)
                {
                    contractout.ErrorMessage = "Could not find existing series with ID: " + animeSeriesID.ToString();
                    return contractout;
                }

                // make sure the group exists
                AnimeGroupRepository repGroups = new AnimeGroupRepository();
                AnimeGroup grpTemp = repGroups.GetByID(newAnimeGroupID);
                if (grpTemp == null)
                {
                    contractout.ErrorMessage = "Could not find existing group with ID: " + newAnimeGroupID.ToString();
                    return contractout;
                }

                int oldGroupID = ser.AnimeGroupID;
                ser.AnimeGroupID = newAnimeGroupID;
                ser.DateTimeUpdated = DateTime.Now;

                repSeries.Save(ser);

                // update stats for new groups
                //ser.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
                ser.QueueUpdateStats();

                // update stats for old groups
                AnimeGroup grp = repGroups.GetByID(oldGroupID);
                if (grp != null)
                {
                    grp.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
                }

                AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
                AniDB_Anime anime = repAnime.GetByAnimeID(ser.AniDB_ID);
                if (anime == null)
                {
                    contractout.ErrorMessage = string.Format("Could not find anime record with ID: {0}", ser.AniDB_ID);
                    return contractout;
                }
                List<CrossRef_AniDB_TvDBV2> xrefs = ser.GetCrossRefTvDBV2();
                List<CrossRef_AniDB_MAL> xrefMAL = ser.CrossRefMAL;

                List<TvDB_Series> sers = new List<TvDB_Series>();
                foreach (CrossRef_AniDB_TvDBV2 xref in xrefs)
                    sers.Add(xref.GetTvDBSeries());
                CrossRef_AniDB_Other xrefMovie = ser.CrossRefMovieDB;
                MovieDB_Movie movie=null;
                if (xrefMovie != null)
                    movie = xrefMovie.GetMovieDB_Movie();
                contractout.AnimeSeries = ser.ToContract(anime, xrefs, xrefMovie,
                ser.GetUserRecord(userID), sers, xrefMAL, false, null, null, null, null,movie);

                return contractout;
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                contractout.ErrorMessage = ex.Message;
                return contractout;
            }
        }
开发者ID:,项目名称:,代码行数:73,代码来源:


示例19: SyncTraktSeries

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Repositories.VideoLocalRepository类代码示例发布时间:2022-05-26
下一篇:
C# Repositories.AniDB_AnimeRepository类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap