public void DeployPackagesInApp(ResourceManager appRessourceManager) { // We deploy files of levels "on app" LevelsLoader.DeployLevelsInApp(appRessourceManager); List <string> levelsNewlyInstalled = LevelsLoader.LevelsNewlyInstalledDbPath; // we generate thumbnail for new installed packages and we insert data on main DB if (levelsNewlyInstalled != null) { foreach (var item in levelsNewlyInstalled) { // Install Level on MainDb InstallLevelOnMainDb(item, null, new CancellationToken()); } } //var installedLevels = new GameDBHelper(MAIN_DATABASE_PATH, MAIN_PACKS_FOLDER_PATH).GetLevels(); LevelsLoader.LevelsNewlyInstalledDbPath.Clear(); }
public async Task <bool> DownloadAndInstallLevel(int idLevel, Action <int> downloadProgress, Action <int> installProgress, CancellationToken cancellationToken) { try { string url = QUIZZ_APP_INIT_BASE_URL + "/" + QUIZZ_APP_SERVICE_DOWNLOAD_LEVEL + "/" + idLevel; MQHttpWebClient client = new MQHttpWebClient(); string fileDownloadedName = await client.DoDownloadRequestAsync(url, LevelsLoader.GetPackagesTempFolderPath(), downloadProgress, cancellationToken); string extractToFolderName = fileDownloadedName.Replace(LevelsLoader.LEVEL_COMPRESS_EXTENSION, string.Empty); cancellationToken.ThrowIfCancellationRequested(); await Task.Factory.StartNew(() => { // We install the pack and ad it to list string dbPath = LevelsLoader.InstallLevelFiles(fileDownloadedName, fileDownloadedName.Replace(LevelsLoader.LEVEL_COMPRESS_EXTENSION, string.Empty)); cancellationToken.ThrowIfCancellationRequested(); this.InstallLevelOnMainDb(dbPath, installProgress, cancellationToken); }, cancellationToken); return(true); } catch (OperationCanceledException) { Debug.WriteLine("Downloading pack cancelled !!"); return(false); } catch (Exception ex) { Debug.WriteLine("Error downloading pack !!", ex); return(false); } }