我正在创建一个简单的电影票预订应用程序,我使用英雄卡选择电影,在选择电影时,将显示带有YES / NO选项的确认消息。 这是高级代码流 1.使用HeroCard选择电影的MovieDialog 2.确认对话框以“是/否”显示确认选项
问题: 我在ConfirmationDialog中有一个resume方法(OnOptionConfirmationSelected),它应该在选择了prompt选项后执行,但是在单击movie按钮后会立即调用此方法。你能检查代码并告诉我问题在哪里吗?
[Serializable]
public class ConfirmationDialog : IDialog<object>
{
public async Task StartAsync(IDialogContext context)
{
context.Wait(MessageReceivedAsync);
//return Task.CompletedTask;
}
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
{
Activity activity = (Activity)context.Activity;
this.ShowOptions(context);
//Below is Test line
//context.ConversationData.TryGetValue(ContextConstants.MovieDateKey, out szMovieDate);
//await context.PostAsync("List of movies in " + Convert.ToString(activity.Text));
//If Context Forward is there then ContextWait is not needed.
//context.Wait(MessageReceivedAsync);
}
private void ShowOptions(IDialogContext context)
{
string szMovieDate = "";
string szMovieLanguage = "";
string szMovieName = "";
context.ConversationData.TryGetValue(ContextConstants.MovieDateKey, out szMovieDate);
context.ConversationData.TryGetValue(ContextConstants.LanguageKey, out szMovieLanguage);
context.ConversationData.TryGetValue(ContextConstants.MovieNameKey, out szMovieName);
string szConfirmationMessage = "";
szConfirmationMessage = String.Format("You have booked ticket for movie {0} for this date {1}", szMovieName, szMovieDate);
PromptDialog.Choice(context, this.OnOptionConfirmationSelected, new List<string>() { "Yes", "No" }, szConfirmationMessage, "Not a valid option", 3);
//context.Wait(this.MessageReceivedAsync);
}
private async Task OnOptionConfirmationSelected(IDialogContext context, IAwaitable<string> result)
{
Activity activity = (Activity)context.Activity;
var optionSelected = activity.Text;
if (optionSelected.ToUpper() == "YES" || optionSelected.ToUpper() == "NO")
{
//await context.PostAsync(Convert.ToString(optionSelected));
context.Done(optionSelected);
}
else
{
context.Wait(this.MessageReceivedAsync);
}
}
}
=Sum(iif(Fields!Category.Value="Labor", Fields!ActualCost.Value, 0), "Dataset1")
答案 0 :(得分:0)
问题是在MessageReceivedAsync
MovieDialog
方法中你在if / else子句之外做context.Wait(this.MessageReceivedAsync);
,所以你在同一个对话框中等待您要将邮件转发到ConfirmationDialog
。您应该在PostAync