首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FormFlow :一段时间后取消表单

FormFlow :一段时间后取消表单
EN

Stack Overflow用户
提问于 2017-03-15 20:20:21
回答 1查看 292关注 0票数 0

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

代码语言:javascript
复制
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,但在离开表单流之后,我无法管理任何东西。

Return new FormBuilder<PatientForm>().Build()只跳过1个问题,表单流继续。

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

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

EN

回答 1

Stack Overflow用户

发布于 2017-03-15 20:31:54

你应该试试这个:

代码语言:javascript
复制
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();
            }
        }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42809608

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档