Ejemplo n.º 1
0
		public static void CheckForCalendarUpdate(bool forceRefresh)
		{
			if (ServerSettings.AniDB_Calendar_UpdateFrequency == ScheduledUpdateFrequency.Never && !forceRefresh) return;
			int freqHours = Utils.GetScheduledHours(ServerSettings.AniDB_Calendar_UpdateFrequency);

			// update the calendar every 12 hours
			// 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)
			{
				// 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;
				}
			}

			CommandRequest_GetCalendar cmd = new CommandRequest_GetCalendar(forceRefresh);
			cmd.Save();
		}