Ejemplo n.º 1
0
        protected async override void OnInvoke(Microsoft.Phone.Scheduler.ScheduledTask task)
        {
            var  userAccountEntity = new UserAccountEntity();
            var  authManager       = new AuthenticationManager();
            bool loginTest         = await authManager.RefreshAccessToken(userAccountEntity);

            if (loginTest)
            {
                UserAccountEntity.User user = await authManager.GetUserEntity(userAccountEntity);

                if (user == null)
                {
                    return;
                }
                userAccountEntity.SetUserEntity(user);
                NotificationEntity notificationEntity = await GetNotifications(userAccountEntity);

                if (notificationEntity == null)
                {
                    return;
                }
                if (notificationEntity.Notifications == null)
                {
                    return;
                }
                var notificationList = notificationEntity.Notifications.Where(o => o.SeenFlag == false);
                NotificationEntity.Notification firstNotification = notificationList.FirstOrDefault();
                ShellTile appTile = ShellTile.ActiveTiles.First();
                if (firstNotification != null)
                {
                    var toastMessage = firstNotification.Message;
                    var toast        = new ShellToast {
                        Title = "FoulPlay", Content = toastMessage
                    };
                    toast.Show();
                    if (appTile != null)
                    {
                        var tileData = new FlipTileData
                        {
                            Title           = "FoulPlay",
                            BackTitle       = "FoulPlay",
                            BackContent     = firstNotification.Message,
                            WideBackContent = firstNotification.Message,
                            Count           = notificationList.Count()
                        };
                        appTile.Update(tileData);
                    }
                    await NotificationManager.ClearNotification(firstNotification, userAccountEntity);
                }
            }
#if DEBUG_AGENT
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
#endif
            NotifyComplete();
        }
Ejemplo n.º 2
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(Microsoft.Phone.Scheduler.ScheduledTask task)
        {
            var tileToBeUpdated = ShellTile.ActiveTiles.FirstOrDefault();

            if (tileToBeUpdated != null)
            {
                var newTileData = new StandardTileData
                {
                    Title = "updated tile",
                    //BackgroundImage
                    Count = 2,
                    //BackBackgroundImage
                    BackContent = "text"
                };
                tileToBeUpdated.Update(newTileData);
            }
            NotifyComplete();
        }