Esempio n. 1
0
        //Muestro una noticia random
        private static async Task <NoticeModel> GetRandomNotice()
        {
            var noticeInDay = await ReadResitory.GetNoticesInDay();

            var random = new Random();
            var number = random.Next(0, noticeInDay.Count - 1);

            return(noticeInDay[number]);
        }
Esempio n. 2
0
        private static async Task HandleReadNamedaysCommandAsync(VoiceCommandServiceConnection connection)
        {
            //Genero un mensaje de espera para que el usuario vea
            var userMessage = new VoiceCommandUserMessage();

            userMessage.DisplayMessage = "Los eventos que se realizan el dia de hoy son";
            userMessage.SpokenMessage  = "Los eventos que se realizan el dia de hoy son";
            var response = VoiceCommandResponse.CreateResponse(userMessage);
            await connection.ReportProgressAsync(response);

            var today   = DateTime.Now.Date;
            var notices = await ReadResitory.GetNoticesInDay();


            if (notices.Count() > 1)
            {
                userMessage.SpokenMessage      =
                    userMessage.DisplayMessage =
                        $"El dia de hoy se realizan {notices.Count} eventos";

                var tile = new VoiceCommandContentTile();
                tile.ContentTileType = VoiceCommandContentTileType.TitleOnly;
                var titleList = new List <VoiceCommandContentTile>();
                var count     = 0;
                foreach (var noticeModel in notices)
                {
                    if (count <= 5)
                    {
                        titleList.Add(new VoiceCommandContentTile
                        {
                            Title           = noticeModel.Title.ToString(),
                            ContentTileType = VoiceCommandContentTileType.TitleWithText,
                            TextLine1       = noticeModel.Date
                        });
                        ++count;
                    }
                }
                response = VoiceCommandResponse.CreateResponse(userMessage, titleList);
                await connection.ReportProgressAsync(response);
            }
            else
            {
                if (notices != null)
                {
                    userMessage.SpokenMessage      =
                        userMessage.DisplayMessage =
                            $"El evento que se realiza hoy es {notices.First().Title} eventos";
                    response = VoiceCommandResponse.CreateResponse(userMessage);
                }
            }

            await connection.ReportSuccessAsync(response);
        }
Esempio n. 3
0
        private async Task SendNotificationAsync()
        {
            var noticeInDay = await ReadResitory.GetNoticesInDay();

            if (noticeInDay == null)
            {
                return;
            }

            ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
            XmlDocument   content  = ToastNotificationManager.GetTemplateContent(
                ToastTemplateType.ToastText02);

            var texts = content.GetElementsByTagName("text");

            texts[0].InnerText = "Usted tienen algunas noticias para el dia de hoy!";

            texts[1].InnerText = $"Usted tiene un total de  {noticeInDay.Count} noticias!";

            notifier.Show(new ToastNotification(content));
        }