コード例 #1
0
        public async void InitHotRecomenAsync()
        {
            try
            {
                //获取我的游戏

                DisplayMetro = Visibility.Visible;
                IHome home     = BridgeFactory.BridgeManager.GetHomeManager();
                var   genrator = await home.GetHomeGames();

                if (genrator.code.Equals("000"))
                {
                    var Results = JsonConvert.DeserializeObject <GetHomeResultEntity>(genrator.result.ToString());
                    if (Loginer.LoginerUser.ToolEntities.Count != 0)
                    {
                        foreach (var item in Loginer.LoginerUser.ToolEntities)
                        {
                            foreach (var recommen in Results.recommendGames)
                            {
                                if (recommen.id.Equals(item.gamesId))
                                {
                                    recommen.Purchased = 1;
                                }
                                else if (recommen.isPurchased)
                                {
                                    recommen.Purchased = 2;
                                }
                            }
                            foreach (var hotgameItem in Results.hotGames)
                            {
                                if (hotgameItem.id.Equals(item.gamesId))
                                {
                                    hotgameItem.Purchased = 1;
                                }
                                else if (hotgameItem.isPurchased)
                                {
                                    hotgameItem.Purchased = 2;
                                }
                            }
                        }
                    }
                    if (Results.recommendGames != null && Results.recommendGames.Length != 0)
                    {
                        Results.recommendGames.OrderBy(s => s.displayOrder).ToList().ForEach((ary) => RecommendGames.Add(ary));
                        var ItemsSource = Results.recommendGames.OrderBy(s => s.displayOrder).Skip(0).Take(4);
                        ItemsSource.ForEach((ary) => RecommendSkipGames.Add(ary));
                    }
                    if (Results.hotGames != null && Results.hotGames.Length != 0)
                    {
                        DownloadManager.LoadModulesAsync(Results.hotGames.OrderBy(s => s.displayOrder).ToList());
                    }
                }
                //常用游戏
                var comkmogenrator = await home.GetCommonUseGames();

                if (comkmogenrator.code.Equals("000"))
                {
                    var Results = JsonConvert.DeserializeObject <List <GetCommonUseGamesEntity> >(comkmogenrator.result.ToString());
                    if (Results != null && Results.Count != 0)
                    {
                        Results.ToList().ForEach((ary) => HotGames.Add(ary));
                    }
                }

                ICommon common         = BridgeFactory.BridgeManager.GetCommonManager();
                var     Commongenrator = await common.GetCommonDes();

                if (Commongenrator.code.Equals("000"))
                {
                    var Results = JsonConvert.DeserializeObject <HomePageModel>(Commongenrator.result.ToString());
                    about   = Results.about;
                    toolDes = Results.toolDes;
                }
            }
            catch (Exception ex)
            {
                Msg.Error(ex);
            }
            finally
            {
                DisplayMetro = Visibility.Collapsed;
            }
        }