Esempio n. 1
0
		public static void CheckForTraktSyncUpdate(bool forceRefresh)
		{

			if (ServerSettings.Trakt_SyncFrequency == ScheduledUpdateFrequency.Never && !forceRefresh) return;
			int freqHours = Utils.GetScheduledHours(ServerSettings.Trakt_SyncFrequency);

			// update the calendar every xxx hours
			ScheduledUpdateRepository repSched = new ScheduledUpdateRepository();

			ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.TraktSync);
			if (sched != null)
			{
				// if we have run this in the last xxx hours and are not forcing it, then exit
				TimeSpan tsLastRun = DateTime.Now - sched.LastUpdate;
				logger.Trace("Last Trakt Sync: {0} minutes ago", tsLastRun.TotalMinutes);
				if (tsLastRun.TotalHours < freqHours)
				{
					if (!forceRefresh) return;
				}
			}

            if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken))
            {
                CommandRequest_TraktSyncCollection cmd = new CommandRequest_TraktSyncCollection(false);
                cmd.Save();
            }
		}
Esempio n. 2
0
        public ActionResult SyncTrakt()
        {
            if (ServerSettings.Instance.TraktTv.Enabled && !string.IsNullOrEmpty(ServerSettings.Instance.TraktTv.AuthToken))
            {
                CommandRequest_TraktSyncCollection cmd = new CommandRequest_TraktSyncCollection(true);
                cmd.Save();
                return(APIStatus.OK());
            }

            return(new APIMessage(204, "Trakt is not enabled or you are missing the authtoken"));
        }
Esempio n. 3
0
        /// <summary>
        /// Sync Trakt Collection
        /// </summary>
        /// <returns></returns>
        private object SyncTrakt()
        {
            if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken))
            {
                CommandRequest_TraktSyncCollection cmd = new CommandRequest_TraktSyncCollection(true);
                cmd.Save();
                return(APIStatus.OK());
            }

            return(new APIMessage(204, "Trak is not enabled or you missing authtoken"));
        }
 void btnSyncTrakt_Click(object sender, RoutedEventArgs e)
 {
     Cursor = Cursors.Wait;
     if (ServerSettings.Instance.TraktTv.Enabled && !string.IsNullOrEmpty(ServerSettings.Instance.TraktTv.AuthToken))
     {
         CommandRequest_TraktSyncCollection cmd = new CommandRequest_TraktSyncCollection(true);
         cmd.Save();
     }
     Cursor = Cursors.Arrow;
     MessageBox.Show(Commons.Properties.Resources.Server_SyncTrakt,
                     Commons.Properties.Resources.Success,
                     MessageBoxButton.OK, MessageBoxImage.Information);
 }