Beispiel #1
0
        private async Task AfterChoiceAsync(IDialogContext context, IAwaitable <string> result)
        {
            var selection = await result;

            if (selection == "네, 맞아요!")
            {
                using (CommentService service = new CommentService(new KetBotContext()))
                {
                    await context.PostAsync(await service.GetCommentAsync("RPB02"));

                    // get state
                    KetBotState state = null;
                    // category 2 question
                    context.ConversationData.TryGetValue("KetBotState", out state);
                    // category 2 list
                    var cat2 = await service.GetFormsAsync(state.Stage0Selection);

                    var cat2numbering = ListNumberingHelper.Numbering(cat2);
                    await context.PostAsync(string.Join("\n", cat2numbering.ToArray()));

                    // go next
                    context.Done("");
                }
            }
            else if (selection == "아닌데요?")
            {
                // go back
                context.Call(new Stage0Dialog(), async(c, r) =>
                {
                    var s = await r;
                    //context.Done("");
                    context.Wait(MessageReceivedAsync);
                });
            }
        }
Beispiel #2
0
        public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument)
        {
            using (CommentService service = new CommentService(new KetBotContext()))
            {
                var activity = await argument;

                // get state
                KetBotState state = null;
                context.ConversationData.TryGetValue("KetBotState", out state);

                var cat2 = await service.GetFormsAsync(state.Stage0Selection);

                bool checkflag = false;
                int  selected;
                if (int.TryParse(activity.Text, out selected) && selected > 0 && selected <= cat2.Count)
                {
                    checkflag = true;
                }

                if (checkflag == true)
                {
                    // save Stage 2 selection
                    state.Stage1Selection = activity.Text;
                    // save state
                    context.ConversationData.SetValue("KetBotState", state);

                    // stage 3 question
                    var q = await service.GetCommentAsync("RCB01");

                    q = string.Format(q, cat2[selected - 1]);
                    var cat3 = await service.GetFormsAsync(state.Stage0Selection + state.Stage1Selection);

                    var cat3numbering = ListNumberingHelper.Numbering(cat3);
                    await context.PostAsync(q);

                    await context.PostAsync(string.Join("\n", cat3numbering.ToArray()));

                    context.Done("");
                }
                else
                {
                    // Go back to stage 0
                    // TODO : How to go back?
                    context.Call(new Stage1Dialog(), async(c, r) => { var s = await r; context.Done(""); });
                }
            }
        }
Beispiel #3
0
        public async Task StartAsync(IDialogContext context)
        {
            // First Question and selection
            using (CommentService service = new CommentService(new KetBotContext()))
            {
                // Question
                await context.PostAsync(await service.GetCommentAsync("RPB01"));

                // Category 1
                var cat1 = await service.GetFormsAsync("0");

                var cat1numbering = ListNumberingHelper.Numbering(cat1);
                await context.PostAsync(string.Join("\n", cat1numbering.ToArray()));

                context.Done("");
            }
        }