コード例 #1
0
        private async Task <DialogTurnResult> SendDateTimeCard(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            string path         = TimeOffBL.GetPath();
            string DateTimeCard = File.ReadAllText(path + "\\Cards\\PTODateTimeCard.json");
            await stepContext.Context.SendActivityAsync(MessageFactory.Attachment(SendCards.SendAdaptiveCard(DateTimeCard)), cancellationToken);

            return(EndOfTurn);
        }
コード例 #2
0
        private async Task <DialogTurnResult> ValidateDateTime(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var activity = stepContext.Context.Activity;

            if (activity.Value != null)
            {
                var value  = JsonConvert.DeserializeObject <JObject>(activity.Value.ToString());
                var Action = value["Action"].ToString();
                if (Action.Equals("validate&ApplyPTO"))
                {
                    var card = AdaptiveRuntimeValidation.DateCardValidation(stepContext.Context.Activity.Value.ToString());
                    if (string.IsNullOrEmpty(card))
                    {
                        var userData = await statePropertyAccessor.GetAsync(stepContext.Context, () => new UserData());

                        var    Data      = JsonConvert.DeserializeObject <JObject>(activity.Value.ToString());
                        string startDate = Data["StartDate"].ToString();
                        string endDate   = Data["EndDate"].ToString();
                        string ptoReason = Data["Reason"].ToString();
                        userData.PTOData = new PTOData {
                            EndDate = endDate, StartDate = startDate, Reason = ptoReason
                        };
                        await statePropertyAccessor.SetAsync(stepContext.Context, userData);

                        return(await stepContext.NextAsync());
                    }
                    else
                    {
                        await stepContext.Context.SendActivityAsync(MessageFactory.Attachment(SendCards.SendAdaptiveCard(card)), cancellationToken);

                        stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                        return(EndOfTurn);
                    }
                }
                //string DateTimeCard = File.ReadAllText(path + "\\Cards\\PTODateTimeCard.json");
                //await stepContext.Context.SendActivityAsync(MessageFactory.Attachment(SendCards.SendAdaptiveCard(DateTimeCard)), cancellationToken);
            }
            await stepContext.Context.SendActivityAsync(MessageFactory.Text("I don't understand this input cancelling this flow please restart again"), cancellationToken);

            return(await stepContext.CancelAllDialogsAsync());
        }
コード例 #3
0
        private async Task <DialogTurnResult> ActionAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)

        {
            var activity = stepContext.Context.Activity;

            if (activity.Value != null)
            {
                var Value       = JsonConvert.DeserializeObject <JObject>(activity.Value.ToString());
                var ActionValue = Value["Action"];
                if (ActionValue != null)
                {
                    var state = await stepContext.ContinueDialogAsync();
                }
                else
                {
                    ImBackData imBackData = JsonConvert.DeserializeObject <ImBackData>(activity.Value.ToString());
                    activity.Text = imBackData.msteams.value;
                }
            }

            var topScoringintent = LuisData.LuisResult(activity.Text);

            switch (topScoringintent)
            {
            case "Cancel":
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("Cancelling All dialogs please restart the flow"));

                return(await stepContext.CancelAllDialogsAsync(cancellationToken));

            case IntentToken.PTOApply:
                return(await stepContext.ReplaceDialogAsync(nameof(BookTimeOffDialog)));

            case IntentToken.PTOBalance:
                return(await stepContext.ReplaceDialogAsync(nameof(TimeOfBalanceDialog)));

            default:
                string path        = TimeOffBL.GetPath();
                string WelcomeCard = File.ReadAllText(path + "\\Cards\\NoneIntent.json");
                await stepContext.Context.SendActivityAsync(MessageFactory.Attachment(SendCards.SendAdaptiveCard(WelcomeCard)), cancellationToken);

                return(await stepContext.CancelAllDialogsAsync(cancellationToken));
            }
        }