示例#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)
        {
            //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();
            }
        }
示例#2
0
        public static void SetTile(SimplePlayer p)
        {
            ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault();
            if (tile != null)
            {
                StandardTileData newtile = new StandardTileData();
                string frontTile = "bf3/" + p.RankPic;
                newtile.BackgroundImage = new Uri(frontTile, UriKind.Relative);
                newtile.BackTitle = " ";
                newtile.Title = "BF3 Stats";
                newtile.Count = Convert.ToInt32(p.Rank);

                tile.Update(newtile);
            }
        }