コード例 #1
0
        private async Task <bool> RefreshDlLevelListAsync()
        {
            try
            {
                JsonWebClient  client = new JsonWebClient();
                List <LevelDl> resp   = await client.DoRequestJsonAsync <List <LevelDl> >(QUIZZ_APP_INIT_BASE_URL + "/" + QUIZZ_APP_SERVICE_LEVELS_LIST + "/" + QUIZZ_APP_MEDIA_TYPE_IDENTIFIER);

                this.toDlLevels           = resp;
                this.LastDlLevelsListTime = DateTime.Now;
                return(this.toDlLevels != null);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error retrieving packs to dl list !!", ex);
                return(false);
            }
        }
コード例 #2
0
        private async Task <bool> RefreshInitInfosAsync(bool updateIndicatorOfAllPacks)
        {
            try
            {
                JsonWebClient client = new JsonWebClient();
                InitInfosRep  resp   = await client.DoRequestJsonAsync <InitInfosRep>(QUIZZ_APP_INIT_BASE_URL + "/" + QUIZZ_APP_SERVICE_INFO + "/" + QUIZZ_APP_MEDIA_TYPE_IDENTIFIER);

                this.LastInitInfosRep     = resp;
                this.LastInitInfosRepTime = DateTime.Now;

                // Inject dificulties
                if (this.LastInitInfosRep == null)
                {
                    return(false);
                }

                var difficulties = this.LastInitInfosRep.Difficulties.Where(m => m.Language.Value.Equals(LanguagesUtils.GetCurrentLanguageOnQuizzAppFormat(), StringComparison.InvariantCultureIgnoreCase)).ToList();
                using (var dbHelper = new GameDBHelper(MAIN_DATABASE_PATH, MAIN_PACKS_FOLDER_PATH))
                {
                    var installedDifficulties = dbHelper.GetDifficulties();
                    foreach (var item in difficulties)
                    {
                        if (!installedDifficulties.ContainsKey(item.Difficulty.Id))
                        {
                            dbHelper.AddDifficulty(item);
                        }
                    }

                    var toto = dbHelper.GetDifficulties();
                }



                //if (updateIndicatorOfAllPacks)
                //    this.UpdateIndicatorNewOfPacks();

                return(true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error doing 'init' on server!!", ex);
                return(false);
            }
        }