예제 #1
0
        /// <summary>
        /// Send message asking what field user wants to edit.
        /// </summary>
        private async Task SendEditMessageAsync(IDialogContext context, IAwaitable <TicketFieldsTracker> result)
        {
            ticketFieldsTracker = await result as TicketFieldsTracker;

            await context.PostAsync("What would you like to change?");

            // Get list of fields that user can edit.
            List <MenuOption> options = new List <MenuOption>();
            var fields = typeof(TicketFieldType).GetFields();

            for (int i = 2; i < fields.Length; i++)
            {
                var field = fields[i];
                options.Add(new MenuOption
                {
                    DisplayValue = field.Name,
                    ReturnValue  = field.Name
                });
            }

            // Post menu options.
            var activity = context.Activity as Activity;
            await context.PostAsync(ActivityGenerator.Default.GenerateMenuOptions(activity, options));

            context.Wait(ReceiveEditChoice);
        }
예제 #2
0
        /// <summary>
        /// Sends message to user asking them to fill in the next field.
        /// </summary>
        private async Task SendTicketQnaMessageAsync(IDialogContext context, IAwaitable <TicketFieldsTracker> result)
        {
            // Receive the object that tracks the progress of the ticket creation
            ticketFieldsTracker = await result as TicketFieldsTracker;
            var activity = context.Activity as Activity;

            // Send message asking user to fill in the next field.
            System.Diagnostics.Trace.TraceInformation($"CreateTicketDialog.PostNextQuestionAsync: {ticketFieldsTracker.CurrentField.Question}");
            await ResponseGenerator.Default.SendResponseAsync(activity, this.ticketFieldsTracker.CurrentField.Question, context);

            context.Wait(ReceiveResponseAsync);
        }
예제 #3
0
 /// <summary>
 /// Begins create ticket dialog cycle.
 /// Welcome message.
 /// </summary>
 /// <param name="context">Helps send and receive messages, contains conversation state data.</param>
 public Task StartAsync(IDialogContext context)
 {
     this.ticketFieldsTracker = new TicketFieldsTracker();
     context.Wait(MessageReceivedAsync);
     return(Task.CompletedTask);
 }