0

当对话在 FormFlow 中并且用户键入“帮助”时,目前 Scorables 全局消息处理程序“帮助”将获得控制权。我希望 FormFlows 'Help' 命令在表单内时使用,而 Scorables 'Help' 仅在其他对话中时使用。有没有办法做到这一点?

protected override async Task PostAsync(IActivity item, string state, 
CancellationToken token) 
{ 
     var message = item as IMessageActivity; 

     if (message != null) 
     { 
          var helpDialog = new HelpDialog(); 
          var interruption = helpDialog.Void<object, IMessageActivity>(); 
          this.task.Call(interruption, null); 
          await this.task.PollAsync(token); 
     } 
}


public class HelpDialog : IDialog<object>
{
    public async Task StartAsync(IDialogContext context)
    {

        var userHelpMessage = "You have reached Help Section.\n"
                               + StaticMessages.HelpMessage
                               + "\n Your previous conversation is active 
         and you can return to prior dialog by typing 'Back' or 'Return'.";

        await context.PostAsync(userHelpMessage);

        context.Wait(this.MessageReceived);
    }

    private async Task MessageReceived(IDialogContext context, 
    IAwaitable<IMessageActivity> result)
    {
        var message = await result;

        var incomingMessage = message.Text.ToLowerInvariant();

        if ((incomingMessage != null) && (incomingMessage.Trim().Length > 0))
        {
            context.Done<object>(null);
        }
        else if (incomingMessage.Equals("return", StringComparison.InvariantCultureIgnoreCase))
        {
            context.Done<object>(null);
        }
        else if (incomingMessage.Equals("back", StringComparison.InvariantCultureIgnoreCase))
        {
            context.Done<object>(null);
        }
        else
        {
            context.Fail(new Exception("Message was not a string or was an empty string."));
        }
    }
}

[可序列化] 公共类 BuildARCollRaiseDisputeForm {

    //Custom Form Builder for custom yes options
    BuildCustomForm customForm = new BuildCustomForm();
    ARCollRaiseDisputeQuery disputeQuery = new ARCollRaiseDisputeQuery();

    public IForm<ARCollRaiseDisputeQuery> BuildARCollRaiseDisputeForms()
    {

        IForm<ARCollRaiseDisputeQuery> form;

        OnCompletionAsyncDelegate<ARCollRaiseDisputeQuery> processARCollRaiseDisputeSave = async (context, state) =>
        {
            var message = $"Saving your dispute reason against this Invoice. ";

            await context.PostAsync(message);
        };

        var builder = customForm.CreateCustomForm<ARCollRaiseDisputeQuery>()

            .Field(nameof(disputeQuery.BODISPUTEREASONOPTIONS),
                    validate: async(state, value) => await ValidatePymtDisputeReason(state, value)
                   )

            .Field(nameof(disputeQuery.DisputeItemReasons),
                    active: state =>  ActiveDisputeItemReason(state)
                    )

            .Field(nameof(disputeQuery.DisputeShipmentReasons),
                    active: ActiveDisputeShipmentReason
                    )

            .Field(nameof(disputeQuery.DisputeInvoicingReasons),
                    active: ActiveDisputeInvoicingReason
                    )

            .Field(new FieldReflector<ARCollRaiseDisputeQuery>(nameof(disputeQuery.OtherPymtDisputeReason))
                .SetActive(state => ActiveOtherPymtDisputeReason(state))
                .SetPrompt(new PromptAttribute("Do you have any custom message to my team for non-payment for this Invoice? If yes, then please type and send as single message."))
                .SetValidate(async (state, value) => await ValidateOtherPymtDisputeReason(state, value))
                )

            .AddRemainingFields()
            .Confirm("I have the following reasons for raising dispute against this Invoice and I am ready to submit your message. {BODISPUTEREASONOPTIONS}  Shall I go ahead? ")
            .OnCompletion(processARCollRaiseDisputeSave)
            .Message("Thank you");

        form = builder.Build();

        return form;



    }

}

4

0 回答 0