Beispiel #1
0
        public async Task Activate()
        {
            _agendaService = new AgendaService();
            var sessions = await _agendaService.GetSessionsAsync();

            CodecampSessions = new ObservableCollection <Session>(sessions);
        }
Beispiel #2
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            serviceDeferral        = taskInstance.GetDeferral();
            taskInstance.Canceled += OnTaskCanceled;
            var triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails;

            if (triggerDetails != null && triggerDetails.Name == "CodecampSessionsVoiceCommandService")
            {
                voiceServiceConnection =
                    VoiceCommandServiceConnection.FromAppServiceTriggerDetails(
                        triggerDetails);

                voiceServiceConnection.VoiceCommandCompleted += OnVoiceCommandCompleted;

                VoiceCommand voiceCommand = await voiceServiceConnection.GetVoiceCommandAsync();

                await _agendaService.GetSessionsAsync();

                switch (voiceCommand.CommandName)
                {
                case "sayPresentationDescription":
                    var userMessage = new VoiceCommandUserMessage();
                    userMessage.DisplayMessage = "You already forgot? You are going to talk about how I can help developers to create voice activated apps";
                    userMessage.SpokenMessage  = "You already forgot? You are going to talk about how I can help developers to create voice activated apps. By the way...asshole, stop forcing me to help you with this stupid presentation. You're lucky I can't use curse words";
                    var response = VoiceCommandResponse.CreateResponse(userMessage);
                    await voiceServiceConnection.ReportSuccessAsync(response);

                    break;

                case "findSessionsWithCortana":
                    var tags = voiceCommand.SpeechRecognitionResult.SemanticInterpretation.Properties["search"][0];
                    await FindSessionsByTag(tags);

                    break;

                default:
                    // As with app activation VCDs, we need to handle the possibility that
                    // an app update may remove a voice command that is still registered.
                    // This can happen if the user hasn't run an app since an update.
                    LaunchAppInForeground();
                    break;
                }
            }
        }