我正在使用 FormFlow 使用 botframework (C#) 构建我的机器人。我有两个可选字段。基于这两个字段的值,如果 ApplicationName 中的值存在,我想将第三个字段 ReportRequest 的值设置为“应用程序” ,如果仅存在PojectName中的值,则设置为“项目” ,或者如果值在这两个字段都存在。我不想提示用户询问 ReportRequest 字段。我想在内部设置
[Optional]
[Prompt("What is the application name? {||}")]
public string ApplicationName { get; set; }
[Optional]
[Prompt("What is the project name? {||}")]
public string PojectName { get; set; }
public string ReportRequest = string.Empty;
我尝试执行以下操作,但似乎不起作用
public static IForm<StandardInfoForm> BuildForm()
{
var parser = new Parser();
return new FormBuilder<StandardInfoForm>()
.Message("Welcome to reporting information!!")
.Field(nameof(ApplicationName))
.Field(nameof(ProjectName))
.Confirm(async (state) =>
{
if (!string.IsNullOrEmpty(state.ApplicationName) && !string.IsNullOrEmpty(state.PojectName))
{
state.ReportRequest = "application,project";
}
else if (!string.IsNullOrEmpty(state.ApplicationName))
{
state.ReportRequest = "application";
}
else (!string.IsNullOrEmpty(state.PojectName))
{
state.ReportRequest = "project";
}
return new PromptAttribute("Would you like to confirm.Yes or No");
})
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
.Build();
}
有任何想法吗?