示例#1
0
        /// <summary>
        /// init
        /// </summary>
        /// <returns></returns>
        public sealed override async Task InitializeAsync()
        {
            _movieDbBusiness = new MovieDbBusiness();
            _filmBusiness    = new FilmBusiness();
            await _filmBusiness.Initialization;

            //récupération des films de la bibliothèque
            FilmVoir          = new ObservableCollection <Film>(await _filmBusiness.GetFilmSuggestionVoir());
            VisibleAVoir      = FilmVoir != null && FilmVoir.Any();
            FilmPosseder      = new ObservableCollection <Film>(await _filmBusiness.GetFilmSuggestionPosseder());
            VisibleAcheter    = FilmPosseder != null && FilmPosseder.Any();
            FilmFavoris       = new ObservableCollection <Film>(await _filmBusiness.GetFilmSuggestionFavoris());
            VisibleFavoris    = FilmFavoris != null && FilmFavoris.Any();
            FilmSuggestion    = new ObservableCollection <Film>(await _filmBusiness.GetFilmSuggestionAleatoire());
            VisibleSuggestion = FilmSuggestion != null && FilmSuggestion.Any();

            //récupértion d'internet
            try
            {
                ListeNowPlaying     = new ObservableCollection <ResultSearchMovieJson>(await _movieDbBusiness.GetNowPlayingMovie());
                IsVisibleNowPlaying = ListeNowPlaying != null && ListeNowPlaying.Any();
            }
            catch (Exception)
            {
                // ignored
            }

            try
            {
                ListeFilmPopulaire     = new ObservableCollection <ResultSearchMovieJson>(await _movieDbBusiness.GetPopularMovie());
                IsVisibleFilmPopulaire = ListeFilmPopulaire != null && ListeFilmPopulaire.Any();
            }
            catch (Exception)
            {
                // ignored
            }

            try
            {
                ListeTvMoment     = new ObservableCollection <ResultSearchTvJson>(await _movieDbBusiness.GetNowPlayingTv());
                IsVisibleTvMoment = ListeTvMoment != null && ListeTvMoment.Any();
            }
            catch (Exception)
            {
                // ignored
            }

            try
            {
                ListeTvPopular     = new ObservableCollection <ResultSearchTvJson>(await _movieDbBusiness.GetPopularSerie());
                IsVisibleTvPopular = ListeTvPopular != null && ListeTvPopular.Any();
            }
            catch (Exception)
            {
                // ignored
            }
        }
示例#2
0
        /// <summary>
        /// Méthode de lancement de l'appel de cortana
        /// </summary>
        /// <param name="taskInstance"></param>
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            //lancement
            _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 voicecommand = await _voiceCommandServiceConnection.GetVoiceCommandAsync();

            await ContexteAppli.Init(true);

            var filmBusiness = new FilmBusiness();
            await filmBusiness.Initialization;
            var movieDbBusiness = new MovieDbBusiness();

            var tiles = new List <VoiceCommandContentTile>();

            switch (voicecommand.CommandName)
            {
            case "showVoirFilm":
                var listeFilmVoir = await filmBusiness.GetFilmSuggestionVoir();

                tiles.AddRange(listeFilmVoir.Select(film => new VoiceCommandContentTile
                {
                    ContentTileType = VoiceCommandContentTileType.TitleOnly,
                    Title           = film.Titre,
                    AppContext      = film
                }));
                break;

            case "showFilm":
                var listeFilm = await filmBusiness.GetFilmSuggestionAleatoire();

                tiles.AddRange(listeFilm.Select(film => new VoiceCommandContentTile
                {
                    ContentTileType = VoiceCommandContentTileType.TitleOnly,
                    Title           = film.Titre,
                    AppContext      = film
                }));
                break;

            case "showFilmFav":
                var listeFilmFav = await filmBusiness.GetFilmSuggestionFavoris();

                tiles.AddRange(listeFilmFav.Select(film => new VoiceCommandContentTile
                {
                    ContentTileType = VoiceCommandContentTileType.TitleOnly,
                    Title           = film.Titre,
                    AppContext      = film
                }));
                break;

            case "showAcheter":
                var listeFilmPosseder = await filmBusiness.GetFilmSuggestionPosseder();

                tiles.AddRange(listeFilmPosseder.Select(film => new VoiceCommandContentTile
                {
                    ContentTileType = VoiceCommandContentTileType.TitleOnly,
                    Title           = film.Titre,
                    AppContext      = film
                }));
                break;

            case "showFilmMoment":
                var listeFilmMoment = (await movieDbBusiness.GetPopularMovie()).Take(9);
                tiles.AddRange(listeFilmMoment.Select(film => new VoiceCommandContentTile
                {
                    ContentTileType = VoiceCommandContentTileType.TitleOnly,
                    Title           = film.title,
                    AppContext      = film
                }));
                break;

            case "showSerieMoment":
                var listeserieMoment = (await movieDbBusiness.GetPopularSerie()).Take(9);
                tiles.AddRange(listeserieMoment.Select(film => new VoiceCommandContentTile
                {
                    ContentTileType = VoiceCommandContentTileType.TitleOnly,
                    Title           = film.name,
                    AppContext      = film
                }));
                break;
            }

            var userPrompt = new VoiceCommandUserMessage();

            if (tiles.Count > 0)
            {
                userPrompt.DisplayMessage = GetString("filmTrouve");
                userPrompt.SpokenMessage  = GetString("filmTrouve");
            }
            else
            {
                userPrompt.DisplayMessage = GetString("aucunResultat");
                userPrompt.SpokenMessage  = GetString("aucunResultat");
            }

            if (tiles.Count == 0)
            {
                var response = VoiceCommandResponse.CreateResponse(userPrompt);
                await _voiceCommandServiceConnection.ReportSuccessAsync(response);
            }
            else
            {
                var response = VoiceCommandResponse.CreateResponse(userPrompt, tiles);
                await _voiceCommandServiceConnection.ReportSuccessAsync(response);
            }
        }