/// <summary> /// Permet de vérifier si l'application peut s'autoLogger, s'autologue si possible, et lance la recherche /// </summary> /// <returns>true si à tout réussi à faire automatiquement</returns> public async Task <bool> LanceRechercheSansMotDePasse() { if (ContexteAppli.IsCortanaActive) { var mdp = await CortanaBusiness.GetPasswordUser(); if (!string.IsNullOrWhiteSpace(mdp)) { if (await PasswordBusiness.Load(mdp, true)) { await LancerRecherche(); return(true); } } } return(false); }
/// <summary> /// Vérifie si le mot de l'utilisateur est déchiffrable /// </summary> /// <returns>true si ok</returns> public async Task GetPassword() { try { var mdp = await CortanaBusiness.GetPasswordUser(); if (mdp != null) { ErreurVerif = ResourceLoader.GetForCurrentView("Errors").GetString("erreurAffichMdp") + " " + mdp; } else { ErreurVerif = ResourceLoader.GetForCurrentView("Errors").GetString("erreurRecupPass"); } } catch (Exception) { ErreurVerif = ResourceLoader.GetForCurrentView("Errors").GetString("erreurRecupPass"); } }
/// <summary> /// Méthode se lancant lors de l'appel de cortana pour l'appli /// </summary> /// <param name="taskInstance"></param> public async void Run(IBackgroundTaskInstance taskInstance) { //lancement de cortana, récupération des objets nécéssaires _serviceDeferral = taskInstance.GetDeferral(); taskInstance.Canceled += (sender, reason) => _serviceDeferral?.Complete(); var triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails; _voiceCommandServiceConnection = VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails); _voiceCommandServiceConnection.VoiceCommandCompleted += (sender, args) => _serviceDeferral?.Complete(); var identifiant = (await _voiceCommandServiceConnection.GetVoiceCommandAsync()).Properties["site"][0].ToLower(); string message; var openApp = false; var openTiles = false; var tiles = new List <VoiceCommandContentTile>(); //Initialisation de l'appli await ContexteAppli.Initialize(false, null); //si le fichier existe if (await PasswordBusiness.DoesFileCypherExist()) { //si cortana est autorisé if (ContexteAppli.IsCortanaActive) { //récupération du mot de passe var mdp = await CortanaBusiness.GetPasswordUser(); if (!string.IsNullOrWhiteSpace(mdp)) { //chargement du fichier if (await PasswordBusiness.Load(mdp, false)) { tiles = CortanaBusiness.GetMotDePasseTile(identifiant, ContexteAppli.DossierMere); if (tiles.Count == 0) { message = GetString("cortanaAucunIdentifiant"); } else if (tiles.Count > 10) { message = GetString("cortanaPlusieursResultats"); openApp = true; } else { message = GetString("cortanaIdentifiantsTrouves"); openTiles = true; } } else { message = GetString("cortanaEchecFichier"); openApp = true; } } else { message = GetString("cortanaEchecFichier"); openApp = true; } } else { message = GetString("cortanaLanceApp"); openApp = true; } } else { message = GetString("cortanaAucunIdentifiant"); } var userPrompt = new VoiceCommandUserMessage { DisplayMessage = message, SpokenMessage = message }; if (openApp) { var response = VoiceCommandResponse.CreateResponse(userPrompt); response.AppLaunchArgument = identifiant; await _voiceCommandServiceConnection.RequestAppLaunchAsync(response); } else if (openTiles) { var response = VoiceCommandResponse.CreateResponse(userPrompt, tiles); await _voiceCommandServiceConnection.ReportSuccessAsync(response); } else { var response = VoiceCommandResponse.CreateResponse(userPrompt); await _voiceCommandServiceConnection.ReportSuccessAsync(response); } }