当前位置: 首页>>代码示例>>C#>>正文


C# AniDB_AnimeRepository.Save方法代码示例

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


在下文中一共展示了AniDB_AnimeRepository.Save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessCommand

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

            try
            {
                // we will always assume that an anime was downloaded via http first
                ScheduledUpdateRepository repSched = new ScheduledUpdateRepository();
                AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();

                ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.AniDBCalendar);
                if (sched == null)
                {
                    sched = new ScheduledUpdate();
                    sched.UpdateType = (int)ScheduledUpdateType.AniDBCalendar;
                    sched.UpdateDetails = "";
                }
                else
                {
                    int freqHours = Utils.GetScheduledHours(ServerSettings.AniDB_Calendar_UpdateFrequency);

                    // if we have run this in the last 12 hours and are not forcing it, then exit
                    TimeSpan tsLastRun = DateTime.Now - sched.LastUpdate;
                    if (tsLastRun.TotalHours < freqHours)
                    {
                        if (!ForceRefresh) return;
                    }
                }

                sched.LastUpdate = DateTime.Now;
                repSched.Save(sched);

                CalendarCollection colCalendars = JMMService.AnidbProcessor.GetCalendarUDP();
                if (colCalendars == null || colCalendars.Calendars == null)
                {
                    logger.Error("Could not get calendar from AniDB");
                    return;
                }
                foreach (AniDBAPI.Calendar cal in colCalendars.Calendars)
                {
                    AniDB_Anime anime = repAnime.GetByAnimeID(cal.AnimeID);
                    if (anime != null)
                    {
                        // don't update if the local data is less 2 days old
                        TimeSpan ts = DateTime.Now - anime.DateTimeUpdated;
                        if (ts.TotalDays >= 2)
                        {
                            CommandRequest_GetAnimeHTTP cmdAnime = new CommandRequest_GetAnimeHTTP(cal.AnimeID, true, false);
                            cmdAnime.Save();
                        }
                        else
                        {
                            // update the release date even if we don't update the anime record
                            anime.AirDate = cal.ReleaseDate;
                            repAnime.Save(anime);

                        }
                    }
                    else
                    {
                        CommandRequest_GetAnimeHTTP cmdAnime = new CommandRequest_GetAnimeHTTP(cal.AnimeID, true, false);
                        cmdAnime.Save();
                    }
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error processing CommandRequest_GetCalendar: " + ex.ToString(), ex);
                return;
            }
        }
开发者ID:,项目名称:,代码行数:71,代码来源:

示例2: UpdateAnimeDisableExternalLinksFlag

        public void UpdateAnimeDisableExternalLinksFlag(int animeID, int flags)
        {
            try
            {
                AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
                AniDB_Anime anime = repAnime.GetByAnimeID(animeID);
                if (anime == null) return;

                anime.DisableExternalLinksFlag = flags;
                repAnime.Save(anime);
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
            }
        }
开发者ID:,项目名称:,代码行数:16,代码来源:

示例3: EnableDisableImage

        public string EnableDisableImage(bool enabled, int imageID, int imageType)
        {
            try
            {
                JMMImageType imgType = (JMMImageType)imageType;

                switch (imgType)
                {
                    case JMMImageType.AniDB_Cover:

                        AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
                        AniDB_Anime anime = repAnime.GetByAnimeID(imageID);
                        if (anime == null) return "Could not find anime";

                        anime.ImageEnabled = enabled ? 1 : 0;
                        repAnime.Save(anime);

                        break;

                    case JMMImageType.TvDB_Banner:

                        TvDB_ImageWideBannerRepository repBanners = new TvDB_ImageWideBannerRepository();
                        TvDB_ImageWideBanner banner = repBanners.GetByID(imageID);

                        if (banner == null) return "Could not find image";

                        banner.Enabled = enabled ? 1 : 0;
                        repBanners.Save(banner);

                        break;

                    case JMMImageType.TvDB_Cover:

                        TvDB_ImagePosterRepository repPosters = new TvDB_ImagePosterRepository();
                        TvDB_ImagePoster poster = repPosters.GetByID(imageID);

                        if (poster == null) return "Could not find image";

                        poster.Enabled = enabled ? 1 : 0;
                        repPosters.Save(poster);

                        break;

                    case JMMImageType.TvDB_FanArt:

                        TvDB_ImageFanartRepository repFanart = new TvDB_ImageFanartRepository();
                        TvDB_ImageFanart fanart = repFanart.GetByID(imageID);

                        if (fanart == null) return "Could not find image";

                        fanart.Enabled = enabled ? 1 : 0;
                        repFanart.Save(fanart);

                        break;

                    case JMMImageType.MovieDB_Poster:

                        MovieDB_PosterRepository repMoviePosters = new MovieDB_PosterRepository();
                        MovieDB_Poster moviePoster = repMoviePosters.GetByID(imageID);

                        if (moviePoster == null) return "Could not find image";

                        moviePoster.Enabled = enabled ? 1 : 0;
                        repMoviePosters.Save(moviePoster);

                        break;

                    case JMMImageType.MovieDB_FanArt:

                        MovieDB_FanartRepository repMovieFanart = new MovieDB_FanartRepository();
                        MovieDB_Fanart movieFanart = repMovieFanart.GetByID(imageID);

                        if (movieFanart == null) return "Could not find image";

                        movieFanart.Enabled = enabled ? 1 : 0;
                        repMovieFanart.Save(movieFanart);

                        break;

                    case JMMImageType.Trakt_Poster:

                        Trakt_ImagePosterRepository repTraktPosters = new Trakt_ImagePosterRepository();
                        Trakt_ImagePoster traktPoster = repTraktPosters.GetByID(imageID);

                        if (traktPoster == null) return "Could not find image";

                        traktPoster.Enabled = enabled ? 1 : 0;
                        repTraktPosters.Save(traktPoster);

                        break;

                    case JMMImageType.Trakt_Fanart:

                        Trakt_ImageFanartRepository repTraktFanart = new Trakt_ImageFanartRepository();
                        Trakt_ImageFanart traktFanart = repTraktFanart.GetByID(imageID);

                        if (traktFanart == null) return "Could not find image";

                        traktFanart.Enabled = enabled ? 1 : 0;
                        repTraktFanart.Save(traktFanart);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: PopulateAndSaveFromUDP

        /// <summary>
        /// we are depending on the HTTP api call to get most of the info
        /// we only use UDP to get mssing information
        /// </summary>
        /// <param name="animeInfo"></param>
        public void PopulateAndSaveFromUDP(Raw_AniDB_Anime animeInfo)
        {
            // raw fields
            this.reviewIDListRAW = animeInfo.ReviewIDListRAW;

            // save now for FK purposes
            AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
            repAnime.Save(this);

            CreateAnimeReviews();
        }
开发者ID:,项目名称:,代码行数:16,代码来源:

示例5: PopulateAndSaveFromHTTP

        public void PopulateAndSaveFromHTTP(ISession session, Raw_AniDB_Anime animeInfo, List<Raw_AniDB_Episode> eps, List<Raw_AniDB_Anime_Title> titles,
            List<Raw_AniDB_Category> cats, List<Raw_AniDB_Tag> tags, List<Raw_AniDB_Character> chars, List<Raw_AniDB_RelatedAnime> rels, List<Raw_AniDB_SimilarAnime> sims,
            List<Raw_AniDB_Recommendation> recs, bool downloadRelations)
        {
            logger.Trace("------------------------------------------------");
            logger.Trace(string.Format("PopulateAndSaveFromHTTP: for {0} - {1}", animeInfo.AnimeID, animeInfo.MainTitle));
            logger.Trace("------------------------------------------------");

            DateTime start0 = DateTime.Now;

            Populate(animeInfo);

            // save now for FK purposes
            AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
            repAnime.Save(session, this);

            DateTime start = DateTime.Now;

            CreateEpisodes(session, eps);
            TimeSpan ts = DateTime.Now - start; logger.Trace(string.Format("CreateEpisodes in : {0}", ts.TotalMilliseconds)); start = DateTime.Now;

            CreateTitles(session, titles);
            ts = DateTime.Now - start; logger.Trace(string.Format("CreateTitles in : {0}", ts.TotalMilliseconds)); start = DateTime.Now;

            CreateTags(session, tags);
            ts = DateTime.Now - start; logger.Trace(string.Format("CreateTags in : {0}", ts.TotalMilliseconds)); start = DateTime.Now;

            CreateCharacters(session, chars);
            ts = DateTime.Now - start; logger.Trace(string.Format("CreateCharacters in : {0}", ts.TotalMilliseconds)); start = DateTime.Now;

            CreateRelations(session, rels, downloadRelations);
            ts = DateTime.Now - start; logger.Trace(string.Format("CreateRelations in : {0}", ts.TotalMilliseconds)); start = DateTime.Now;

            CreateSimilarAnime(session, sims);
            ts = DateTime.Now - start; logger.Trace(string.Format("CreateSimilarAnime in : {0}", ts.TotalMilliseconds)); start = DateTime.Now;

            CreateRecommendations(session, recs);
            ts = DateTime.Now - start; logger.Trace(string.Format("CreateRecommendations in : {0}", ts.TotalMilliseconds)); start = DateTime.Now;

            repAnime.Save(this);
            ts = DateTime.Now - start0; logger.Trace(string.Format("TOTAL TIME in : {0}", ts.TotalMilliseconds));
            logger.Trace("------------------------------------------------");
        }
开发者ID:,项目名称:,代码行数:43,代码来源:

示例6: GetReleaseGroupStatusUDP

		public GroupStatusCollection GetReleaseGroupStatusUDP(int animeID)
		{
			if (!Login()) return null;

			enHelperActivityType ev = enHelperActivityType.NoSuchCreator;
			AniDBCommand_GetGroupStatus getCmd = null;
			lock (lockAniDBConnections)
			{
				Pause();

				getCmd = new AniDBCommand_GetGroupStatus();
				getCmd.Init(animeID);
				SetWaitingOnResponse(true);
				ev = getCmd.Process(ref soUdp, ref remoteIpEndPoint, curSessionID, new UnicodeEncoding(true, false));
				SetWaitingOnResponse(false);
			}

			if (ev == enHelperActivityType.GotGroupStatus && getCmd.GrpStatusCollection != null)
			{
				// delete existing records
				AniDB_GroupStatusRepository repGrpStat = new AniDB_GroupStatusRepository();
				AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
				AniDB_EpisodeRepository repAniEp = new AniDB_EpisodeRepository();
				AnimeSeriesRepository repSeries = new AnimeSeriesRepository();

				repGrpStat.DeleteForAnime(animeID);

				// save the records
				foreach (Raw_AniDB_GroupStatus raw in getCmd.GrpStatusCollection.Groups)
				{
					AniDB_GroupStatus grpstat = new AniDB_GroupStatus(raw);
					repGrpStat.Save(grpstat);
				}

				// updated cached stats
				// we don't do it in the save method as it would be too many unecessary updates
				logger.Trace("Updating group stats by anime from GetReleaseGroupStatusUDP: {0}", animeID);
				StatsCache.Instance.UpdateUsingAnime(animeID);
				
				if (getCmd.GrpStatusCollection.LatestEpisodeNumber > 0)
				{
					// update the anime with a record of the latest subbed episode
					AniDB_Anime anime = repAnime.GetByAnimeID(animeID);
					if (anime != null)
					{
						anime.LatestEpisodeNumber = getCmd.GrpStatusCollection.LatestEpisodeNumber;
						repAnime.Save(anime);

						// check if we have this episode in the database
						// if not get it now by updating the anime record
						List<AniDB_Episode> eps = repAniEp.GetByAnimeIDAndEpisodeNumber(animeID, getCmd.GrpStatusCollection.LatestEpisodeNumber);
						if (eps.Count == 0)
						{
							CommandRequest_GetAnimeHTTP cr_anime = new CommandRequest_GetAnimeHTTP(animeID, true, false);
							cr_anime.Save();
						}

						// update the missing episode stats on groups and children
						AnimeSeries series = repSeries.GetByAnimeID(animeID);
						if (series != null)
						{
                            series.QueueUpdateStats();
							//series.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
						}

					}
				}
			}

			return getCmd.GrpStatusCollection;
		}
开发者ID:maz0r,项目名称:jmmserver,代码行数:71,代码来源:AniDBHelper.cs


注:本文中的JMMServer.Repositories.AniDB_AnimeRepository.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。