简体   繁体   English

在FormFlow(Bot Framework)中显示Datepicker

[英]Showing Datepicker in FormFlow (Bot Framework)

I am working on a FormFlow feature of a bot framework in one of my bot projects. 我正在其中一个机器人项目中使用机器人框架的FormFlow功能。 The bot is required to get input from user about the date range (From and To). 该机器人必须从用户那里获取有关日期范围(从和到)的输入。 The form flow works, however the bot requires to enter DateTime in string. 表单流有效,但是漫游器需要在字符串中输入DateTime。 To avoid human errors, I would like it to be a Date picker (like the one in Adaptive Cards) instead of string input from user. 为避免人为错误,我希望它是一个日期选择器(如自适应卡中的那个),而不是用户输入的字符串。

I tried setting type of field explicitly but it didn't work for some reason. 我尝试显式设置字段类型,但由于某些原因无法正常工作。 See the code below. 请参见下面的代码。

    [Serializable]
    public class Leave
    {
        [Prompt("Select type of leave you want to apply.")]
        public LeaveTypeEnum LeaveType;

        [Prompt("Vacations from date")]
        public DateTime? From;

        [Prompt("To date")]
        public DateTime? To;



        public static IForm<Leave> BuildForm()
        {
            return new FormBuilder<Leave>().Message
            ("Fill in the form.")
                .Field(new FieldReflector<Leave>(nameof(From)).SetType(typeof(DateTime)))
                .Field(nameof(From))
                .Field(nameof(To))
                .Build();
        }
    }

在此处输入图片说明

Can we show datepicker instead? 我们可以改为显示日期选择器吗?

The short answer is no, there is no DatePicker component in botframework. 简短的答案是“否”,botframework中没有DatePicker组件。

Handle datetime inputs 处理日期时间输入

You should instead be able to get a datetime by text from your user and handle many formats, by using Microsoft's Recognizers-Text GitHub project for example: https://github.com/Microsoft/Recognizers-Text 相反,您应该能够通过使用Microsoft的Recognizers-Text GitHub项目从用户那里获取文本的日期时间并处理多种格式,例如: https : //github.com/Microsoft/Recognizers-Text

It is made for parsing text inputs in several types, and DateTime is one of the provided types. 它用于解析多种类型的文本输入,而DateTime是提供的类型之一。 It is available in NuGet packages. 它在NuGet软件包中可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM