/// <summary> /// Charge les données du fichier de compte en roaming s'il existe /// </summary> private static async Task LoadFileCompte() { if (await _roamingCompteFile.FileExist() && await _roamingCompteFile.GetSizeFile() > 0) { var inFile = await _roamingCompteFile.LireByteArray(); var xmlIn = CryptUtils.AesDecryptByteArrayToString(inFile, ContexteStatic.CleChiffrement, ContexteStatic.CleChiffrement); var xsb = new XmlSerializer(typeof(RoamingCompteModel)); var rd = new StringReader(xmlIn); _roamingCompte = xsb.Deserialize(rd) as RoamingCompteModel; } }
/// <summary> /// Retourne en % l'espace occupé par le fichier dans le dossier de roaming /// </summary> /// <returns></returns> public async static Task <int> GetEspaceFichierOccupePourcent() { await DemarrageRoaming(); var espaceMax = (ApplicationData.Current.RoamingStorageQuota > 0) ? ApplicationData.Current.RoamingStorageQuota * 1000 : ContexteStatic.RoaminsStorageQuotaBis * 1000; var espaceOccupe = await _roamingEcheancierFile.GetSizeFile(); var ret = (100 * espaceOccupe) / espaceMax; return((espaceOccupe > 0 && ret == 0) ? 1 : (int)ret); }
/// <summary> /// Charger les données liées au roaming /// </summary> /// <returns>la task</returns> private static async Task DemarrageRoaming() { if (_roamingCompte == null) { _roamingCompte = new RoamingCompteModel(); } if (_roamingCompteFile == null) { _roamingCompteFile = new ComFile(ContexteStatic.FichierCompteRoaming, ComFile.PlaceEcriture.Roaming); var sqlite = await ComSqlite.GetComSqlite(); var dbExist = await sqlite.CheckDbExist(); //controle du fichier (si il est vide et que la base de donnée (si elle existe) contient des données, on syncrhonise) if ((!await _roamingCompteFile.FileExist() || (await _roamingCompteFile.FileExist() && await _roamingCompteFile.GetSizeFile() == 0)) && App.ModeApp == AppareilEnum.ModeAppareilPrincipal && dbExist) { var business = new BanqueBusiness(); await business.Initialization; var listeBanque = await business.GetBanques(); foreach (var banque in listeBanque) { await AjouterBanque(banque); var listeCompte = await business.GetCompteFmBanque(banque.Id); foreach (var compte in listeCompte) { await AjouterCompte(compte); } } } } await LoadFileCompte(); }