private Task OnChoiceRecieved(IDialogContext context, IAwaitable <string> result) { Log.Logger.Debug("RootDialog.OnChoiceRecieved started"); var choice = result.GetAwaiter().GetResult(); switch (choice) { case "Emlekezteto": context.Call(new ReminderDialog(), OnDialogDone); break; case "Kepfelismero": context.Call(new ImageAnalyzerDialog(), OnDialogDone); break; default: context.PostAsync($"Hmm, erre meg nem vagyok felkeszitve, ezt valasztottad: {choice}") .GetAwaiter() .GetResult(); break; } return(Task.CompletedTask); }
private Task OnImageUploaded(IDialogContext context, IAwaitable <object> result) { var message = (Activity)result.GetAwaiter().GetResult(); if (ImageAnalyzer.IsImageUpladed(message)) { //Ha elhagyjuk az alkalmazás határait, érdemes //vigyázni, nehogy válasz nélkül hagyjunk egy kérést try { var caption = ImageAnalyzer.GetCaption(message, "6a4a771ce05c475c8fac21308d279136", "https://northeurope.api.cognitive.microsoft.com/vision/v1.0"); context.PostAsync(message.CreateReply(caption)).GetAwaiter().GetResult(); } catch (System.Exception) { context.PostAsync(message.CreateReply("Hiba történt, értesültünk róla, az elhárítás folyamatban")).GetAwaiter().GetResult(); } context.Done(true); } else { context.PostAsync("Nem jo filet toltottel fel, probald ujra!") .GetAwaiter() .GetResult(); context.Wait(OnImageUploaded); } return(Task.CompletedTask); }
private Task OnMessageReceived(IDialogContext context, IAwaitable <object> result) { var message = (Activity)result.GetAwaiter().GetResult(); context.ConversationData.SetValue(ReminderTextKey, message.Text); PromptDialog.Number(context, OnSecondReceived, "Hany masodperc mulva szeretned kapni az ertesitot?"); return(Task.CompletedTask); }
private Task OnMessageRecieved(IDialogContext context, IAwaitable <object> result) { var message = (Activity)result.GetAwaiter().GetResult(); context.PostAsync(message.CreateReply($"Ezt üzented:{ message.Text}")); PromptDialog.Choice(context, OnChoiceRecieved, new[] { "Emlekezteto", "Kepfelismero", "Arcazonositas", "Idojaras" }, "Menupontok:"); return(Task.CompletedTask); }
private async Task AfterShareAsync(IDialogContext context, IAwaitable <bool> result) { if (result.GetAwaiter().GetResult() == true) { // Yes, share the picture. await context.PostAsync("Posting tweet."); } else { // No, don't share the picture. await context.PostAsync("OK, I won't share it."); } }
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument) { // Recupera o arquivo anexado pelo usuário var activity = argument.GetAwaiter().GetResult().Attachments?.FirstOrDefault(a => a.ContentType.Contains("image")); // Retorna o o documento IRRF Processado var retornoOcr = await _ocr.GetDocumentData(activity.ContentUrl); var message = await argument; await context.PostAsync(retornoOcr); context.Wait(MessageReceivedAsync); }
public async Task Step03_AskUser4RoomName(IDialogContext context, IAwaitable <string> result) { _roomLocation = result.GetAwaiter().GetResult(); await context.PostAsync( StorageDataAccess.GetBotMessage("Ask4RoomMessage")); PromptDialog.Choice( context, Step04_InformUserOfRoomDirections, StorageDataAccess.GetListOfRooms(_roomLocation), string.Empty, StorageDataAccess.GetBotMessage("InputNotOK")); }
private async Task AfterShareAsync(IDialogContext context, IAwaitable <bool> result) { if (result.GetAwaiter().GetResult() == true) { // Yes, share the picture. // TODO: for purposes of this hands-on lab, we are not going to bother to get everyone set // up with Twitter dev accounts and actually post, but feel free to implement if you want! await context.PostAsync("Posting tweet."); } else { // No, don't share the picture. await context.PostAsync("OK, I won't share it."); } }
public static Task<T> ToTask<T>(this IAwaitable<T> item) { var source = new TaskCompletionSource<T>(); try { var result = item.GetAwaiter().GetResult(); source.SetResult(result); } catch (Exception error) { source.SetException(error); } return source.Task; }
private Task OnSecondReceived(IDialogContext context, IAwaitable <long> result) { var seconds = result.GetAwaiter().GetResult(); var text = context.ConversationData.GetValue <string>(ReminderTextKey); context.PostAsync($"Ok, {seconds} masodperc mulva kuldunk ertesitot ezzel a szoveggel: {text} ") .GetAwaiter() .GetResult(); var reminder = new Reminder(seconds, text, context); Reminders.Add(reminder); context.Done(true); return(Task.CompletedTask); }
public static bool ExceptionOfType <T, E>(IAwaitable <T> item) where E : Exception { try { item.GetAwaiter().GetResult(); return(false); } catch (E) { return(true); } catch { return(false); } }
private async Task SaveChangesfromCancelBooking(IDialogContext context, IAwaitable <string> result) { using (var db = new Model.EntityModelContainer()) { var id = 0; id = int.Parse(result.GetAwaiter().GetResult()); var itemToRemove = db.Bookings.SingleOrDefault(b => b.Id == id); itemToRemove.IsCancel = true; db.SaveChanges(); } await context.PostAsync("Great....Cancelled Reservation."); }
private async Task IntroDialogResumeAfter(IDialogContext context, IAwaitable <string> result) { try { switch (result.GetAwaiter().GetResult()) { //case "Schade melden": case "Report damage": //await context.PostAsync("Wat vervelend voor u, is er iets defect geraakt?"); await context.PostAsync("Oh that's a pity, did you have some damage?"); context.Call(new ObjectDialog(), ObjectDialogResumeAfter); break; //case "Informatie over mijn verzekeringen": case "Information about my insurance": //await context.PostAsync("Deze functie ondersteunen we helaas nog niet, maak een andere keus."); await context.PostAsync("This function is not supported yet, please select another one."); context.Call(new IntroDialog(), IntroDialogResumeAfter); break; //case "Overstappen op andere verzekeraar": case "Switch to another insurer": //await context.PostAsync("Deze functie ondersteunen we helaas nog niet, maak een andere keus."); await context.PostAsync("This function is not supported yet, please select another one."); context.Call(new IntroDialog(), IntroDialogResumeAfter); break; default: context.Call(new IntroDialog(), IntroDialogResumeAfter); break; } } catch (TooManyAttemptsException) { //await context.PostAsync("Ik begrijp je helaas niet. Laten we het opnieuw proberen."); await context.PostAsync("I don't understand, let's try again."); await StartAsync(context); } }
private async Task ObjectDialogResumeAfter(IDialogContext context, IAwaitable <string> result) { try { _tagList = JsonConvert.DeserializeObject <IEnumerable <string> >(result.GetAwaiter().GetResult()); //Translate tags //var translator = new Translator(); //var translatedTags = translator.Translate(_tagList); //PromptDialog.Choice(context, PriceDialogResumeAfter, translatedTags, "Welk object uit de foto bedoelt u?", "Sorry dat begrijp ik niet, probeer het opnieuw.", 3); PromptDialog.Choice(context, PriceDialogResumeAfter, _tagList, "Which object from the image did you mean?", "I don't understand, let's try again.", 3); } catch (TooManyAttemptsException) { //await context.PostAsync("Ik begrijp je helaas niet. Laten we het opnieuw proberen."); await context.PostAsync("I don't understand, let's try again."); await StartAsync(context); } }
public async Task Step04_InformUserOfRoomDirections(IDialogContext context, IAwaitable <string> result) { _roomName = result.GetAwaiter().GetResult(); var directions = StorageDataAccess.GetRoomDirections(_roomLocation, _roomName); if (string.IsNullOrEmpty(directions)) { await context.PostAsync( StorageDataAccess.GetBotMessage( "RoomNotFoundMessage").Replace("XXXX", directions)); } else { await context.PostAsync( StorageDataAccess.GetBotMessage( "FoundRoomMessage").Replace("XXXX", directions)); } await Step05_GoodbyeUser(context, null); }
private Task OnImageUploaded(IDialogContext context, IAwaitable <object> result) { var message = (Activity)result.GetAwaiter().GetResult(); if (ImageAnalyzer.IsImageUpladed(message)) { var caption = ImageAnalyzer.GetCaption(message, "0902cbc4bf524361a961e16495e36fac", "https://westcentralus.api.cognitive.microsoft.com/vision/v1.0"); context.PostAsync(message.CreateReply(caption)).GetAwaiter().GetResult(); context.Done(true); } else { context.PostAsync("Nem jo filet toltottel fel, probald ujra!") .GetAwaiter() .GetResult(); context.Wait(OnImageUploaded); } return(Task.CompletedTask); }
/// <summary> /// </summary> public static void Subscribe(this IAwaitable awaitable, Action action) { var awaiter = awaitable.GetAwaiter(); awaiter.OnCompleted(() => { try { awaiter.GetResult(); action(); } catch (OperationCanceledException) { } }); }
protected override Task MessageReceived(IDialogContext context, IAwaitable <IMessageActivity> item) { User = item.GetAwaiter().GetResult().From.Name; return(base.MessageReceived(context, item)); }