Пример #1
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            var tile = (from t in ShellTile.ActiveTiles select t).FirstOrDefault();
            var common = new Common();
            var startHour = new DateTime(2014, 05, 13, 08, 50, 00).Hour;
            var startMinute = new DateTime(2014, 05, 13, 08, 50, 00).Minute;
            var currentHour = DateTime.Now.Hour;
            var currentMinute = DateTime.Now.Minute;
            var callReport = (currentHour == startHour && currentMinute >= startMinute) || currentHour >= startHour;
            if (callReport)
            {
                var isUpdated = common.IsUpdated();

                if (tile != null && isUpdated.Result)
                {
                    var newTile = new IconicTileData
                        {
                            Count = 1
                        };
                    tile.Update(newTile);
                }
            }

            // Call NotifyComplete to let the system know the agent is done working.
            NotifyComplete();
        }
Пример #2
0
        /// <summary>
        /// 运行计划任务的代理
        /// </summary>
        /// <param name="task">
        /// 调用的任务
        /// </param>
        /// <remarks>
        /// 调用定期或资源密集型任务时调用此方法
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            string taskType="";
            //TODO: 添加用于在后台执行任务的代码
            if (task is PeriodicTask)
                taskType = "PeriodicTask";
            if (task is ResourceIntensiveTask)
                taskType = "ResourceIntensiveTask";

            ShellToast shellToast = new ShellToast();
            shellToast.Title = taskType;
            shellToast.Content = "测试";
            shellToast.NavigationUri=new System.Uri("/MainPage.xaml?taskType="+taskType, System.UriKind.Relative);
            shellToast.Show();

            ShellTile shellTile=ShellTile.ActiveTiles.First();
            shellTile.Update
                (new StandardTileData{
             Count=5
                } );

            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(15));

            NotifyComplete(); 
        }
Пример #3
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            if (FBDataAccess.Current.IsLoggedIn())
            {
                // wait handler for the end of task processing
                var lcklist = new List<ManualResetEvent>();

                // toast notifications
                lcklist.Add(NotifyLatestNotifications(task.LastScheduledTime));

                // update live tiles
                var tileMapping = new Dictionary<string, ShellTile>(); // user id, tile
                for (int i = 0; i < ShellTile.ActiveTiles.Count(); i++)
                {
                    var tile = ShellTile.ActiveTiles.ElementAt(i);
                    var id = i == 0 ? "me" : tile.NavigationUri.GetQueryString("id");
                    tileMapping.Add(id, tile);
                }
                foreach (var tilemap in tileMapping)
                {
                    lcklist.Add(UpdateUserLiveTile(tilemap.Key, tilemap.Value));
                }

                // wait for the handler
                foreach (var lck in lcklist)
                {
                    lck.WaitOne();
                }
            }

            // Call NotifyComplete to let the system know the agent is done working.
            NotifyComplete();
        }
Пример #4
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        //protected override void OnInvoke(ScheduledTask task)
        //{
        //    //TODO: Add code to perform your task in background
        //    NotifyComplete();
        //}
        protected override void OnInvoke(ScheduledTask task)
        {
            // some random number
            Random random = new Random();
            // get application tile
            ShellTile tile = ShellTile.ActiveTiles.First();
            if (null != tile)
            {
                // creata a new data for tile
                StandardTileData data = new StandardTileData();
                // tile foreground data
                data.Title = "Title text here";
                data.BackgroundImage = new Uri("/Images/Blue.jpg", UriKind.Relative);
                data.Count = random.Next(99);
                // to make tile flip add data to background also
                data.BackTitle = "Secret text here";
                data.BackBackgroundImage = new Uri("/Images/Green.jpg", UriKind.Relative);
                data.BackContent = "Back Content Text here...";
                // update tile
                tile.Update(data);
            }
            #if DEBUG_AGENT
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(30));
            System.Diagnostics.Debug.WriteLine("Periodic task is started again: " + task.Name);
            #endif

            NotifyComplete();
        }
Пример #5
0
        public void FireExitingTask(ScheduledTask scheduledTask)
        {
            var jobKey = scheduledTask.GetJob().Key;

            if (_scheduler.CheckExists(jobKey))
                _scheduler.TriggerJob(jobKey);
        }
Пример #6
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {

            string toastMessage;

            if(task is PeriodicTask)
            {

                toastMessage = "Periodic task running.";

            }
            else
            {
                toastMessage = "Resource-intensive task running.";
            }

            var toast = new ShellToast {Title = "Background Agent Sample", Content = toastMessage};

            toast.Show();

#if DEBUG_AGENT

            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds((60)));

#endif

            NotifyComplete();
        }
Пример #7
0
        protected override void OnInvoke(ScheduledTask task)
        {
            if (LockScreenManager.IsProvidedByCurrentApplication)
            {
                try
                {
                    var currentImage = LockScreen.GetImageUri();
                    string Imagename = string.Empty;
                    IsolatedStorageFile isoStorageFile = IsolatedStorageFile.GetUserStoreForApplication();
                    string[] totalImags = isoStorageFile.GetFileNames("/Shared/ShellContent/");
                    

                    string imgCount = currentImage.ToString().Substring(currentImage.ToString().IndexOf('_') + 1, currentImage.ToString().Length - (currentImage.ToString().IndexOf('_') + 1)).Replace(".jpg", "");
                    Random miIdRand = new Random();
                    Imagename = string.Format("Img{0}.jpg", miIdRand.Next(1, totalImags.Length));
                    LockScreenChange(Imagename);

                    //ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(5));
                    Thread.Sleep(6000);
                    OnInvoke(task);
                }
                catch
                {
                    NotifyComplete();
                }
            }
            else
            {
                
                ScheduledActionService.Remove(task.Name);
            }            
        }
        public ActionResult AddTask(string name = "", string runtime = "", int interval = 0,string url = "")
        {
            try {
                if (url.Trim() == "") {
                    throw new Exception("Task must have a path.");
                }
                if (runtime.Trim() == "" && interval < 1) {
                    throw new Exception("Task must have a run time or an interval greater than 5 minutes.");
                }

                ScheduledTask s = new ScheduledTask {
                    name = name,
                    url = url
                };
                if (runtime.Trim() != "") {
                    DateTime rtime = Convert.ToDateTime(runtime).ToUniversalTime();
                    s.runtime = rtime;
                } else if(interval > 1) {
                    s.interval = interval;
                }
                EcommercePlatformDataContext db = new EcommercePlatformDataContext();
                db.ScheduledTasks.InsertOnSubmit(s);
                db.SubmitChanges();
            } catch {}
            return RedirectToAction("index");
        }
Пример #9
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {

            //TODO: Add code to perform your task in background

            /// If application uses both PeriodicTask and ResourceIntensiveTask
            if (task is PeriodicTask)
            {
                // Execute periodic task actions here.
                ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("TileID=2"));
                if (TileToFind != null)
                {
                     StandardTileData NewTileData = new StandardTileData
                        {
                            Title= "updated by scheduled task",
                            Count = System.DateTime.Now.Minute
                        };
                     TileToFind.Update(NewTileData);
                }
            }
            else
            {
                // Execute resource-intensive task actions here.
            }

            NotifyComplete();
           
        }
Пример #10
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            specifics = task.Description.Split(new string[] { "split" }, StringSplitOptions.None);
            StartHour = int.Parse(specifics[0]);
            StartMin = int.Parse(specifics[1]);
            LateHour = int.Parse(specifics[2]);
            LateMin = int.Parse(specifics[3]);
            Tune = specifics[4];
            DateTime LateAlarmTime = new DateTime(2013, 1, 1, LateHour, LateMin, 0);
            IEnumerable<ScheduledNotification> notifications = ScheduledActionService.GetActions<ScheduledNotification>();
            AlarmsSet = 0;
            if (notifications != null)
            {
                for (int i = 0; i < notifications.Count(); i++)
                {
                    if (notifications.ElementAt(i).ExpirationTime.TimeOfDay > notifications.ElementAt(i).BeginTime.AddSeconds(1).TimeOfDay && notifications.ElementAt(i).ExpirationTime.TimeOfDay < notifications.ElementAt(i).BeginTime.AddSeconds(5).TimeOfDay && notifications.ElementAt(i).BeginTime.TimeOfDay < LateAlarmTime.TimeOfDay)
                    {
                        AlarmsSet++;
                    }
                }
            }

            Appointments appts = new Appointments();

            appts.SearchCompleted += new EventHandler<AppointmentsSearchEventArgs>(Appointments_SearchCompleted_Background);

            DateTime start = DateTime.Now;
            start = start.AddHours(-start.Hour);
            start = start.AddMinutes(-start.Minute);
            DateTime end = DateTime.Now.AddDays(7);

            appts.SearchAsync(start, end, "Appointments Test #1");
        }
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background

            string toastMessage = "";

            // If your application uses both PeriodicTask and ResourceIntensiveTask
            // you can branch your application code here. Otherwise, you don't need to.
            if (task is PeriodicTask)
            {
                // Execute periodic task actions here.
                toastMessage = "Periodic task running.";
            }
            else
            {  
                // Execute resource-intensive task actions here.
                toastMessage = "Resource-intensive task running.";
            }

            // Launch a toast to show that the agent is running.
            // The toast will not be shown if the foreground application is running.
            ShellToast toast = new ShellToast();
            toast.Title = "Background Agent Sample";
            toast.Content = toastMessage;
            toast.Show();

            // If debugging is enabled, launch the agent again in one minute.
            #if DEBUG_AGENT
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
            #endif

            // Call NotifyComplete to let the system know the agent is done working.
            NotifyComplete();
        }
Пример #12
0
        /// <summary>
        ///     Method called when PeriodicTask is invoked.
        /// </summary>
        /// <param name="task">Periodic task invoked.</param>
        protected override void OnInvoke(ScheduledTask task)
        {
            if (!new SettingsController().CatURLExists())
            {
                // Cat URL doesn't exist, so parse RSS.
                this.ParseRSSFeed();
            }
            else
            {
                // Cat URL exists, so perform date check.
                SettingsController settingsController = new SettingsController();

                if (settingsController.LastUpdatedExists())
                {
                    // lastUpdated setting exists, so check.
                    DateTime lastUpdated = new SettingsController().GetLastUpdated();
                    DateTime now = DateTime.Now;

                    if (lastUpdated.Date.CompareTo(now.Date) < 0)
                    {
                        // lastUpdated date is before Today, so parse RSS Feed to get a new image.
                        this.ParseRSSFeed();
                    }
                }
                else
                {
                    // lastUpdated setting doesn't exist, so parse RSS.
                    this.ParseRSSFeed();
                }
            }
        }
Пример #13
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            // TODO: see when last prompted & if time for next prompt

            var data = new MainViewModel();

            var nextLesson = data.Lessons.FirstOrDefault(l => !l.Completed);

            var toast = new ShellToast
            {
                Title = "Time for",
                Content = nextLesson.Name
            };
            toast.Show();

            var mainTile = ShellTile.ActiveTiles.First();

            mainTile.Update(new IconicTileData
            {
                WideContent1 = "Time for more",
                WideContent2 = "watch " + nextLesson.Name
            });

            #if DEBUG
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
            #endif

            NotifyComplete();
        }
Пример #14
0
 /// <summary>
 /// Agent zum Ausführen einer geplanten Aufgabe
 /// </summary>
 /// <param name="task">
 /// Die aufgerufene Aufgabe
 /// </param>
 /// <remarks>
 /// Diese Methode wird aufgerufen, wenn eine regelmäßige oder ressourcenintensive Aufgabe aufgerufen wird
 /// </remarks>
 protected override void OnInvoke(ScheduledTask task)
 {
     _curTask = task;
     //TODO: Code zum Ausführen der Aufgabe im Hintergrund hinzufügen
     if (_settingsFile.Contains("mode") != true)
     {
         NotifyComplete();
     }
     if ((int)_settingsFile["mode"] == 0) {
         _dayStr = " heute ";
     }
     else if ((int)_settingsFile["mode"] == 1)
     {
         _dayStr = " morgen ";
     }
     _fetcher = new Fetcher((int)_settingsFile["mode"]);
     _fetcher.RaiseErrorMessage += (sender, e) =>
     {
         Stop();
     };
     _fetcher.RaiseRetreivedScheduleItems += (sender, e) =>
     {
         Proceed(e.Schedule);
     };
     if (_settingsFile.Contains("group"))
     {
         _fetcher.GetTimes((int)_settingsFile["group"] + 1);
     }
     else
     {
         Stop();
     }
 }
Пример #15
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            try
            {
                //TODO: Add code to perform your task in background
                // 更新应用程序磁贴
                int lastDay = task.LastScheduledTime.Day;
                int today = DateTime.Today.Day;

                if (task.LastScheduledTime.Year > 1 && today != lastDay)
                {
                    RefreshTile();
                }

                //toast
                // 弹出 Toast
                LoadSetting();
                DateTime now = DateTime.Now;
                if (now.TimeOfDay.CompareTo(ALARM_TIME.TimeOfDay) >= 0 //alarm time is arrived  .fix on 2013-6-1, add "time of the day"
                    && !HASALARMED //alarm is not triggered today
                    && ALARM_SWITCH //alarm is on
                    && (ALARM_THRESHOLD + LEFTGLASSES > 8)) //threshold is not reached
                    //if (now.TimeOfDay.CompareTo(ALARM_TIME.TimeOfDay) >= 0  && ALARM_SWITCH && (ALARM_THRESHOLD + LEFTGLASSES > 8))  //for TEST
                {
                    ShowToast();
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                NotifyComplete();
            }
        }
Пример #16
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            UpdateTile.Start();

            // Call NotifyComplete to let the system know the agent is done working.
            NotifyComplete();
        }
Пример #17
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            try
            {
                //rcFetcher.BeginFetchRecentChanges(new ChangesFetcher.RecentChangesFetched(OnFetched));
                rcFetcher.BeginFetchWatchlistChanges(Settings.Instance.Username, Settings.Instance.WatchlistToken,
                    new ChangesFetcher.RecentChangesFetched(OnFetched));
                changesFetchedEvent.WaitOne(20000); //20s timeout

                //we should have changes now, provided there was no error
                if (changes != null && changes.Count > 0 && TileManager.Instance.TileExists())
                {
                    DateTime? lastRead = Settings.Instance.LastRead;
                    int howManyNew = RecentChange.HowManyNewerThanTimestamp(changes, lastRead);
                    TileManager.Instance.UpdateCount(howManyNew);
                }

            #if(DEBUG_AGENT)
                //if we're in the debugging mode, relaunch soon
                TileUpdaterManager taskManager = new TileUpdaterManager();
                taskManager.LaunchForTest();
            #endif
            }
            catch (Exception) //just in case
            { }
            NotifyComplete();
        }
Пример #18
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            var tileToFind = ShellTile.ActiveTiles.FirstOrDefault();

            if(tileToFind != null)
            {
                var tileData = new StandardTileData
                                   {
                                       BackTitle = "Jeg lever!",
                                       BackBackgroundImage = new Uri(_pictureUrl, UriKind.Absolute)
                                   };

                tileToFind.Update(tileData);
            }

            /*

            var toast = new ShellToast
                            {
                                Title = "Toast!",
                                Content = "Backgrond agent says hello!",
                            };
            toast.Show();

            */

            NotifyComplete();
        }
Пример #19
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected async override void OnInvoke(ScheduledTask task) {
            if(NetworkInterface.GetIsNetworkAvailable()) {
                try {
                    var comic = await XkcdInterface.GetCurrentComic();
                    
                    var tileData = new FlipTileData {
                       BackgroundImage = new Uri(comic.ImageUri),
                       WideBackgroundImage = new Uri(comic.ImageUri)
                    };
                    ShellTile tile = ShellTile.ActiveTiles.First();
                    if(tile != null) {
                        tile.Update(tileData);
                    }

                    //var settings = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings;
                    //if(!(bool)settings["IsAppRunning"]) {
                    //    var list = (ObservableCollection<Comic>)settings["ComicList"];
                    //    if(list[0].Number != comic.Number) {
                    //        list.Insert(0, comic);
                    //    }
                    //}
                } catch(WebException) { } catch(InvalidOperationException) { }
            }
            //NotifyComplete();
        }
Пример #20
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            try
            {
                if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
                    return;

                IAppSettingsStore settings = new AppSettingsStore(IsolatedStorageCacheManager.Instance);
                IFalconService fService = new FalconWebServiceClient(ServiceLoginUrl);
                using (var updatesService = new CheckUpdatesService(settings, new RaptorService(fService, AESCipherManager.Instance), AESCipherManager.Instance))
                {
                    var updates = updatesService.Updates();

                    UpdateTile(updatesService.GetUpdateCount());

                    if (updates.Count() == 0)
                    {
            #if DEBUG
                        ShellToast toast2 = new ShellToast();
                        toast2.Title = "DEBUG: ";
                        toast2.Content = "No updates";
                        toast2.Show();
            #endif
                    }
                    else
                    {
                        string message =
                            updates.Count() == 1
                            ? string.Format("Torrent {0} downloaded", updates.First())
                            : string.Format("{0} favorite torrents were downloaded", updates.Count());

                        ShellToast toast = new ShellToast();
                        toast.Title = "Torrents: ";
                        toast.Content = message;
                        toast.Show();
                    }
                }

            }
            catch (Exception ex)
            {
            #if DEBUG
                ShellToast toast = new ShellToast();
                toast.Title = "Error:";
                toast.Content = ex.Message;
                toast.Show();
            #endif
            }
            finally
            {

            #if DEBUG_AGENT
                ScheduledActionService.LaunchForTest(
                    task.Name, TimeSpan.FromSeconds(30));
            #endif

                NotifyComplete();
            }
        }
Пример #21
0
 protected override void OnInvoke(ScheduledTask task)
 {
     RunOnDispatcher(() =>
     {
         new LiveTileUpdater().UpdateTile();
         NotifyComplete();
     });
 }
Пример #22
0
        public void When_scheduling_a_task_it_should_be_added_to_the_storage()
        {
            var task = new ScheduledTask();
            var taskId = task.Id;
            _scheduler.Schedule(task);

            Assert.That(_taskStorage.Get(taskId).Id, Is.EqualTo(taskId));
        }
Пример #23
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            UpdateCycleTileData();

            #if DEBUG_AGENT
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
            #endif
        }
Пример #24
0
 /// <summary>
 /// 執行排程工作的代理程式
 /// </summary>
 /// <param name="task">
 /// 叫用的工作
 /// </param>
 /// <remarks>
 /// 這個方法的呼叫時機為叫用週期性或耗用大量資料的工作時
 /// </remarks>
 protected override void OnInvoke(ScheduledTask task)
 {
     string[ ] parties = task. Description. Split( '@' );
     //重新组装 cookie
     string cookie = string. Format( "oscid=''; Expires=Thu, 01-Jan-1970 00:00:10 GMT;{0}; Path=/", parties[ 0 ] );
     string uid = parties[ 1 ];
     this. Process_GetNotice( cookie, uid );
 }
Пример #25
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background

            MessageBox.Show("Hello world");

            NotifyComplete();
        }
Пример #26
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background

            ScheduledActionService.LaunchForTest( task.Name, TimeSpan.FromSeconds(30));

            NotifyComplete();
        }
Пример #27
0
 /// <summary>
 /// Agent that runs a scheduled task
 /// </summary>
 /// <param name="task">
 /// The invoked task
 /// </param>
 /// <remarks>
 /// This method is called when a periodic or resource intensive task is invoked
 /// </remarks>
 protected override async void OnInvoke(ScheduledTask task)
 {
     //TODO: Add code to perform your task in background
     //set random image from local storage
     await LockscreenHelpers.SetRandomImageFromLocalStorage();
    // ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(30)); //Only for debugging. Release version can only update every 20-40min
     NotifyComplete();
 }
Пример #28
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            //ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(30));

            int rotation = DuplicateCode.GetScheduleRotation();
            DuplicateCode.IncScheduleRotation(rotation);

            if (rotation == 2)
            {
                GetAPIData();

                //ShellToast debugtoast = new ShellToast();
                //debugtoast.Title = "BFS";
                //double mem = (DeviceStatus.ApplicationCurrentMemoryUsage / 1000.00);
                //string memstring = String.Format("{0:0.##}", mem);
                //debugtoast.Content = memstring + "MB " + "web pull";
                //debugtoast.Show();

                //DispatcherTimer dt = new DispatcherTimer();
                //dt.Interval = TimeSpan.FromSeconds(7);
                //dt.Tick += new EventHandler(dt_Tick);
                //dt.Start();
            }
            else if (rotation == 1)
            {
                SignedRequest sr = new SignedRequest();
                TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                string unixtime = ts.TotalSeconds.ToString();
                sr.ident = DuplicateCode.GetIdent();
                sr.time = unixtime;
                sr.player = DuplicateCode.GetPlayer();
                string json = JsonConvert.SerializeObject(sr);
                MakeSignedRequest("playerupdate", DuplicateCode.GetPlatform(), json);
            }
            else
            {
                string oldRank = DuplicateCode.GetPlayerRank();
                SimplePlayer newPlayer = new SimplePlayer(DuplicateCode.GetPlayerJSON());
                if (oldRank != newPlayer.Rank)
                {
                    ShellToast debugtoast = new ShellToast();
                    debugtoast.Title = "BFS";
                    double mem = (DeviceStatus.ApplicationCurrentMemoryUsage / 1000.00);
                    string memstring = String.Format("{0:0.##}", mem);

                    debugtoast.Content = newPlayer.PlayerName + " leveled up to " + newPlayer.Rank;
                    //debugtoast.Content = "O:" + oldRank + " N:" + newPlayer.Rank + " " + memstring;

                    DuplicateCode.SetPlayerRank(newPlayer.Rank);
                    DuplicateCode.SetTile(newPlayer);

                    debugtoast.Show();
                }

                NotifyComplete();
            }
        }
Пример #29
0
 /// <summary>
 /// 執行排程工作的代理程式
 /// </summary>
 /// <param name="task">
 /// 叫用的工作
 /// </param>
 /// <remarks>
 /// 這個方法的呼叫時機為叫用週期性或耗用大量資料的工作時
 /// </remarks>
 protected override void OnInvoke(ScheduledTask task)
 {
     TileUpdateWorker tileUpdateWorker = new TileUpdateWorker();
     tileUpdateWorker.UpdateCompleted += ((sender) =>
     {
         NotifyComplete();
     });
     tileUpdateWorker.Update();
 }
Пример #30
0
 /// <summary>
 /// Agent that runs a scheduled task
 /// </summary>
 /// <param name="task">
 /// The invoked task
 /// </param>
 /// <remarks>
 /// This method is called when a periodic or resource intensive task is invoked
 /// </remarks>
 protected override void OnInvoke(ScheduledTask task)
 {
     //TODO: Add code to perform your task in background
     ShellToast toast = new ShellToast();
     toast.Title = "DropboxSync";
     toast.Content = "Ran";
     toast.Show();
     NotifyComplete();
 }