我正在使用FormFlow。当机器人完成所有问题并调用processOrder
时,我想继续对话,但我不知道应该在哪里调用另一种方法:
OnCompletionAsyncDelegate<Form> processOrder = async (context, state) =>
{
await context.PostAsync("You done");
// context.Call(OnFormComplete);
};
当我尝试这样打电话时,我收到了这条消息:
错误CS7036没有给出对应于'IDialogStack.Call(IDialog,ResumeAfter)'Project1 C:\ Projects \ Good Version \ v-17.2.2017 \ demo-Project1 \的所需形式参数'resume'的参数Project1 \ Dialogs \ Form.cs 34编译器IntelliSense活动编译器
我在rootdialog.cs中以这种模式调用表单流:
var myform = new FormDialog<Form>(new Form(), Form.BuildForm, FormOptions.PromptInStart, null);
context.Call(myform, ResumeAfterOptionDialog);
Formbuilder是:
return new FormBuilder<Form>()
.Field(nameof(Time))
.Field(nameof(Number1))
.Field(nameof(Number2))
.AddRemainingFields()
.Confirm("Would you like to process")
.OnCompletion(processOrder)
.Build();
我想继续对话,因为机器人停了下来。我怎么称呼另一种方法,我应该在哪里打电话?
答案 0 :(得分:0)
你将在formFlow类中使用类似的东西:
[Serializable]
public class CustomFormDialog
{
public DateTime Time { get; set; }
public int Number1 { get; set; }
public int Number2 { get; set; }
public static IForm<CustomFormDialog> Build()
{
OnCompletionAsyncDelegate<CustomFormDialog> processOrder = async (context, state) =>
{
await context.Forward(new OtherFormDialog(state), onOtherFormProcessed, state, CancellationToken.None);
};
return new FormBuilder<CustomFormDialog>()
.Field(nameof(Time))
.Field(nameof(Number1))
.Field(nameof(Number2))
.AddRemainingFields()
.Confirm("Would you like to process?")
.OnCompletion(processOrder)
.Build();
}
private static async Task onOtherFormProcessed(IDialogContext context, IAwaitable<CustomFormDialog> result)
{
var formValue = await result;
await context.PostAsync($"You are again in the form: Time: {formValue.Time}, Number1: {formValue.Number1}, Number2: {formValue.Number2}");
}
}
我定义了一个虚拟对话框,它接收formFlow对话框的响应,并执行一些操作并调用该对话框的完成并返回到FormFlow类:
public class OtherFormDialog : IDialog<CustomFormDialog>
{
private readonly CustomFormDialog formData;
public OtherFormDialog(CustomFormDialog prevState)
{
this.formData = prevState;
}
public async Task StartAsync(IDialogContext context)
{
//Here, we can do anything
await context.PostAsync("I'll check your data. Please wait!");
await context.PostAsync("Just joking! No validation at all.");
context.Done(this.formData);
}
}