【问题标题】:FormFlow : Cancel form after some timesFormFlow : 一段时间后取消表格
【发布时间】:2017-05-29 06:34:23
【问题描述】:

当用户在一定时间后没有回答时,我想停止我的表单流。

public IForm<PatientForm> BuildForm()
        {
            if (dateFirstAnswer.AddSeconds(30) < DateTime.Now)
                return null;
            else
            {
                return new FormBuilder<PatientForm>()
                        .Message(ResourceStringExtentionsPatientForm.IntroForm.Spintax())
                        .OnCompletion(async (context, profileForm) =>
                        {
                            string message = ResourceStringExtentionsPatientForm.OutroForm.Spintax();
                            await context.PostAsync(message);
                        })
                        .Build();
            }
        }

我尝试返回 null,但离开表单流后我无法管理任何内容。

返回new FormBuilder&lt;PatientForm&gt;().Build()只跳过1个问题,formflow继续。

有没有办法像用户一样调用 FormCommand.Quit ?

第二个问题,我看到了一些 BuildForm() 是静态的例子,有什么理由这样做吗?

【问题讨论】:

    标签: c# botframework formflow


    【解决方案1】:

    你应该试试这个:

    IForm<PatientForm> newForm;
    
    public void BuildForm()
            {
                if (dateFirstAnswer.AddSeconds(30) > DateTime.Now)
                {
                    newForm = new FormBuilder<PatientForm>()
                            .Message(ResourceStringExtentionsPatientForm.IntroForm.Spintax())
                            .OnCompletion(async (context, profileForm) =>
                            {
                                string message = ResourceStringExtentionsPatientForm.OutroForm.Spintax();
                                await context.PostAsync(message);
                            })
                            .Build();
                }
            }
    

    【讨论】:

    • 我无法创建IForm 的实例,它是一个接口。我的主要问题是我需要退出表单流并返回一些我可以使用的东西。
    • 所以如果你必须拥有它,请返回一个空白的 IForm。
    • 我不能,这是一个界面。
    • 可以,你在说什么,给个空值就行了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多