Пример #1
0
        /// <summary>
        /// Entry point for the background task.
        /// </summary>
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            var triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails;

            if (null != triggerDetails && triggerDetails.Name == "LightControllerVoiceCommandService")
            {
                _deferral              = taskInstance.GetDeferral();
                taskInstance.Canceled += (s, e) => _deferral.Complete();
                if (true != await InitializeAsync(triggerDetails))
                {
                    return;
                }
                // These command phrases are coded in the VoiceCommands.xml file.
                switch (_voiceCommand.CommandName)
                {
                case "changeLightsState": await ChangeLightStateAsync(); break;

                case "changeLightsColor": await SelectColorAsync(); break;

                case "changeLightStateByName": await ChangeSpecificLightStateAsync(); break;

                default: await _voiceServiceConnection.RequestAppLaunchAsync(
                        CreateCortanaResponse("Launching HueLightController")); break;
                }
                // keep alive for 1 second to ensure all HTTP requests sent.
                await Task.Delay(1000);

                _deferral.Complete();
            }
        }
        private async void LaunchAppInForegroundPms()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "Opening your private messages...";

            var    response = VoiceCommandResponse.CreateResponse(userMessage);
            string test     = "{type:'toast', openPrivateMessages:true}";

            response.AppLaunchArgument = test;

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #3
0
        private async void LaunchApp()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "Launching Sample app";

            var response = VoiceCommandResponse.CreateResponse(userMessage);
            await m_voiceServiceConnection.RequestAppLaunchAsync(response);
        }
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "Starte DSA Wahrscheinlichkeit";

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #5
0
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "开启 App 中...请稍后";
            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "";
            await vcConnection.RequestAppLaunchAsync(response);
        }
Пример #6
0
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "Launching Queueing Theory Calculator";

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "";
            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #7
0
        private async void LaunchAppInForeground(string appLaunchArgument = "")
        {
            var userMessage = new VoiceCommandUserMessage {
                SpokenMessage = string.Empty
            };
            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = appLaunchArgument ?? string.Empty;

            await _voiceServiceConnection.RequestAppLaunchAsync(response);
        }
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage
            {
                SpokenMessage = "Launching Custom commands for Cortana"
            };

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #9
0
        private async void LaunchAppInForeground()
        {
            var    userMessage = new VoiceCommandUserMessage();
            string book        = "opening contoso cabs";

            userMessage.DisplayMessage = userMessage.SpokenMessage = book;
            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "";
            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #10
0
        /// <summary>
        /// Provide a simple response that launches the app. Expected to be used in the
        /// case where the voice command could not be recognized (eg, a VCD/code mismatch.)
        /// </summary>
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "Starte Drink O'Band";

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "";

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
        internal static async void LaunchAppInForegroundAsync(VoiceCommandServiceConnection voiceServiceConnection, string parameters)
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.DisplayMessage = "Launching Factoid...";

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "type=fact&" + parameters;

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "Launching Demo King";

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "key=val";

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
        public static async void LaunchAppInForeground(VoiceCommandServiceConnection voiceServiceConnection)
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.DisplayMessage = "Launching OfficePoint...";

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "type=" + VoiceCommandType.None;

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #14
0
        /// <summary>
        /// Provide a simple response that launches the app. Expected to be used in the
        /// case where the voice command could not be recognized (eg, a VCD/code mismatch.)
        /// </summary>
        private async Task RequestAppLaunchAsync()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "Launching Cortana Todo";

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "";

            await voiceConnection.RequestAppLaunchAsync(response);
        }
Пример #15
0
        /// <summary>
        /// Provide a simple response that launches the app. Expected to be used in the
        /// case where the voice command could not be recognized (eg, a VCD/code mismatch.)
        /// </summary>
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage  = "GOD BLESS AMERICA JOHN MADDEN! JOHN MADDEN! JOHN MADDEN! FOOTBALL!";
            userMessage.DisplayMessage = "Launching Manto";
            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "";

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #16
0
        /// <summary>
        /// Provide a simple response that launches the app. Expected to be used in the
        /// case where the voice command could not be recognized (eg, a VCD/code mismatch.)
        /// </summary>
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = cortanaResourceMap.GetValue("LaunchingListenApp", cortanaContext).ValueAsString;

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "";

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #17
0
        /// <summary>
        /// Provide a simple response that launches the app. Expected to be used in the
        /// case where the voice command could not be recognized (eg, a VCD/code mismatch.)
        /// </summary>
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "lancement de l'application ...";

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "";

            await _voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #18
0
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "Alterna wird gestartet";

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            // When launching the app in the foreground, pass an app
            // specific launch parameter to indicate what page to show.
            response.AppLaunchArgument = "map";
            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #19
0
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage
            {
                SpokenMessage = "Opening Magic Mirror at this time"
            };

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "";

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
        /// <summary>
        /// Provide a simple response that launches the app. Expected to be used in the
        /// case where the voice command could not be recognized (eg, a VCD/code mismatch.)
        /// </summary>
        private async void LaunchAppInForeground()
        {
            var userMessage = new VoiceCommandUserMessage();

            //userMessage.SpokenMessage = cortanaResourceMap.GetValue("LaunchingAdventureWorks", cortanaContext).ValueAsString;
            userMessage.SpokenMessage = "Initializing Reveille...";

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = "";

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #21
0
        /// <summary>
        /// Launch app and pass the appropriate parameters to it
        /// </summary>
        /// <param name="voiceServiceConnection"></param>
        /// <param name="aiResponse"></param>
        /// <returns></returns>
        public async Task LaunchAppInForegroundAsync(VoiceCommandServiceConnection voiceServiceConnection, AIResponse aiResponse)
        {
            var textMessage = aiResponse?.Result?.Fulfillment?.Speech ?? string.Empty;

            var userMessage = new VoiceCommandUserMessage
            {
                SpokenMessage  = textMessage,
                DisplayMessage = textMessage
            };

            var response = VoiceCommandResponse.CreateResponse(userMessage);

            response.AppLaunchArgument = JsonConvert.SerializeObject(aiResponse, Formatting.Indented);

            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #22
0
        async void LaunchAppInForeground()
        {
            try
            {
                var userMessage = new VoiceCommandUserMessage();
                userMessage.SpokenMessage = "Launching Denna";

                var response = VoiceCommandResponse.CreateResponse(userMessage);

                // When launching the app in the foreground, pass an app
                // specific launch parameter to indicate what page to show.
                response.AppLaunchArgument = "agsonCortana";

                await voiceServiceConnection.RequestAppLaunchAsync(response);
            }
            catch { }
        }
Пример #23
0
        private async void launchAppInForeground()
        {
            string progressMessage = "Trying to launch the tic tac toe app now";

            await ShowProgressScreen(progressMessage);

            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "Launching a game of tic tac toe";

            var response = VoiceCommandResponse.
                           CreateResponse(userMessage);

            response.AppLaunchArgument = "";

            await voiceServiceConection.
            RequestAppLaunchAsync(response);
        }
Пример #24
0
        private async void launchAppInForeground()
        {
            string progressMessage = "Please wait. . .";

            await ShowProgressScreen(progressMessage);

            var userMessage = new VoiceCommandUserMessage();

            userMessage.SpokenMessage = "Naking some coffee";

            var response = VoiceCommandResponse.
                           CreateResponse(userMessage);

            response.AppLaunchArgument = "";

            await voiceServiceConection.
            RequestAppLaunchAsync(response);
        }
Пример #25
0
        private async Task SearchCheckedOutDocumentsAsync(string rootSiteUrl, string searchAPIUrl)
        {
            await ShowProgressScreen("Finding documents checked out to you...");

            VoiceCommandResponse response;
            var destinationsContentTiles = new List <VoiceCommandContentTile>();

            var documents = await Core.Helpers.SharePointHelper.GetSharePointDocuments(rootSiteUrl, searchAPIUrl);

            if (documents.Count > 0)
            {
                foreach (var document in documents)
                {
                    var destinationTile = new VoiceCommandContentTile();

                    try
                    {
                        destinationTile.ContentTileType = VoiceCommandContentTileType.TitleWith68x68IconAndText;
                        destinationTile.Image           = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Office365Search.Services.Background" + document.IconUrl.EnsureStartsWith("/")));

                        // destinationTile.AppLaunchArgument = "type=" + "SharePointWhatsCheckedOutQueryCommand" + "&itemId=" + document.ItemId.ToString();

                        destinationTile.AppLaunchArgument = document.Url;
                        destinationTile.Title             = document.Title;
                        destinationTile.TextLine1         = "Last modified: " + document.ModifiedDate.ToString();
                        // destinationTile.TextLine2 = "test";
                        //  destinationTile.TextLine1 = document.AuthorInformation.DisplayName;
                        // destinationTile.TextLine1 = "modified: " + document;
                        // destinationTile.TextLine2 = "views: " + document.ViewCount;
                        destinationTile.AppContext = document;


                        destinationsContentTiles.Add(destinationTile);
                    }
                    catch (Exception ex)
                    {
                    }
                }

                await ShowProgressScreen("I found " + documents.Count + " documents...");

                var userPrompt = new VoiceCommandUserMessage();
                userPrompt.DisplayMessage = userPrompt.SpokenMessage = "Which document you want to open?";

                var userReprompt = new VoiceCommandUserMessage();
                userReprompt.DisplayMessage = userReprompt.SpokenMessage = "Please suggest, Which document you want to open?";

                response = VoiceCommandResponse.CreateResponseForPrompt(userPrompt, userReprompt, destinationsContentTiles);
                // await voiceServiceConnection.ReportSuccessAsync(response);
                try
                {
                    var voiceCommandDisambiguationResult = await voiceServiceConnection.RequestDisambiguationAsync(response);

                    if (voiceCommandDisambiguationResult != null && voiceCommandDisambiguationResult.SelectedItem != null)
                    {
                        string uriToLaunch = voiceCommandDisambiguationResult.SelectedItem.AppLaunchArgument;
                        var    uri         = new Uri(uriToLaunch);
                        //  var success = Windows.System.Launcher.LaunchUriAsync(uri);

                        var userMessage = new VoiceCommandUserMessage();
                        userMessage.DisplayMessage = "Opening the Document.";
                        userMessage.SpokenMessage  = "Opening the Document.";

                        response = VoiceCommandResponse.CreateResponse(userMessage);
                        response.AppLaunchArgument = uri.ToString();

                        await voiceServiceConnection.RequestAppLaunchAsync(response);

                        //var userConfirmMessage = new VoiceCommandUserMessage();
                        //userConfirmMessage.DisplayMessage = userConfirmMessage.SpokenMessage = "Requested Document Opened. Thank you!";

                        //response = VoiceCommandResponse.CreateResponse(userConfirmMessage);
                        //response.AppLaunchArgument = uri.ToString();
                        //await voiceServiceConnection.ReportSuccessAsync(response);
                    }
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                response = VoiceCommandResponse.CreateResponse(new VoiceCommandUserMessage()
                {
                    DisplayMessage = "There's nothing checked out to you",
                    SpokenMessage  = "I didn't find anything checked out to you. Time to get working on something."
                }, destinationsContentTiles);

                await voiceServiceConnection.ReportSuccessAsync(response);
            }


            return;
        }
Пример #26
0
        /// <summary>
        /// Launch app and pass the appropriate parameters to it
        /// </summary>
        /// <param name="voiceServiceConnection"></param>
        /// <param name="aiResponse"></param>
        /// <returns></returns>
        public async Task LaunchAppInForegroundAsync(VoiceCommandServiceConnection voiceServiceConnection, AIResponse aiResponse)
        {
            var textMessage = aiResponse?.Result?.Fulfillment?.Speech ?? string.Empty;

            var userMessage = new VoiceCommandUserMessage
            {
                SpokenMessage = textMessage,
                DisplayMessage = textMessage
            };

            var response = VoiceCommandResponse.CreateResponse(userMessage);
            response.AppLaunchArgument = JsonConvert.SerializeObject(aiResponse, Formatting.Indented);
            
            await voiceServiceConnection.RequestAppLaunchAsync(response);
        }
Пример #27
0
        /// <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);
            }
        }