Beispiel #1
0
        public async void SetTrophyList(string userName, string npCommunicationId)
        {
            IsLoading = true;
            TrophyDetailEntity trophys =
                await
                _trophyDetailManager.GetTrophyDetailList(npCommunicationId,
                                                         userName, true,
                                                         App.UserAccountEntity);

            if (trophys == null)
            {
                IsLoading = false;
                return;
            }
            if (trophys.Trophies == null)
            {
                IsLoading = false;
                return;
            }
            foreach (TrophyDetailEntity.Trophy trophy in trophys.Trophies)
            {
                Trophies.Add(trophy);
            }
            if (!trophys.Trophies.Any())
            {
                IsEmpty = true;
            }
            IsLoading = false;
        }
Beispiel #2
0
        public async Task <IEnumerable <TrophyEntry> > GetTrophies(Account account, DateTime lastUpdatedStamp)
        {
            var results  = new List <TrophyEntry>();
            var trophies = await _trophyManager.GetTrophyList(account.PSNName, 0, _userAccountEntity);

            int flag = 0;

            while (flag < 10)
            {
                if (trophies != null && trophies.TrophyTitles != null && trophies.TrophyTitles.Any())
                {
                    foreach (var trophy in trophies.TrophyTitles.Where(tt => tt.ComparedUser != null && (DateTime.Parse(tt.ComparedUser.LastUpdateDate).ToUniversalTime() > lastUpdatedStamp)))
                    {
                        int f = 0;
                        while (f < 10)
                        {
                            var details = await _trophyDetailManager.GetTrophyDetailList(trophy.NpCommunicationId, account.PSNName, true, _userAccountEntity);

                            if (details != null && details.Trophies != null && details.Trophies.Any())
                            {
                                foreach (var detail in details.Trophies.Where(t => t.ComparedUser.Earned && DateTime.Parse(t.ComparedUser.EarnedDate).ToUniversalTime() > account.LastPolledTrophy))
                                {
                                    results.Add(new TrophyEntry(account, detail, DateTime.Parse(detail.ComparedUser.EarnedDate).ToUniversalTime(), trophy.TrophyTitleName, trophy.NpCommunicationId));
                                }
                                f = 10;
                            }
                            else
                            {
                                f++;
                                Console.WriteLine("{0} Can't fetch details", DateTime.Now);
                                Thread.Sleep(5000);
                            }
                        }
                    }
                    flag = 10;
                }
                else
                {
                    flag++;
                    Console.WriteLine("{0} Can't fetch achievments for user {1}", DateTime.Now, account.PSNName);
                    Thread.Sleep(5000);
                }
            }
            return(results.OrderBy(r => r.TimeStamp));
        }
Beispiel #3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            TrophyTitleGrid.DataContext = App.SelectedTrophyTitle;
            var trophyDetailManager    = new TrophyDetailManager();
            TrophyDetailEntity trophys =
                await
                trophyDetailManager.GetTrophyDetailList(App.SelectedTrophyTitle.NpCommunicationId,
                                                        App.SelectedUser.OnlineId, true,
                                                        App.UserAccountEntity);

            if (trophys == null)
            {
                MessageBox.Show(AppResources.GenericError);
                var rootFrame = Application.Current.RootVisual as PhoneApplicationFrame;
                if (rootFrame != null)
                {
                    rootFrame.GoBack();
                }
                return;
            }
            TrophyList.DataContext = trophys;
        }