private async Task <DialogTurnResult> ConfirmStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var details = (ChatbotDetails)stepContext.Result;
            var handler = new AzureHandler(details.User.Tenant, details.User.TokenResponse.Token);

            var messageText = $"Bitte bestätige: Die Landschaft: {details.LandscapeTag} wird gestartet." + Environment.NewLine;

            messageText = messageText + "Folgende Vms werden gestartet: " + Environment.NewLine;
            if (details.OnlyObligationVms)
            {
                foreach (var vm in handler.GetObligationVmsForLandscapeTag(details.LandscapeTag))
                {
                    messageText = messageText + vm + Environment.NewLine;
                }
            }
            else
            {
                foreach (var vm in handler.GetListOfVmsFromSpecificLandscapeTag(details.LandscapeTag))
                {
                    messageText = messageText + vm + Environment.NewLine;
                }
            }

            messageText = messageText + "Ist das korrekt?";
            stepContext.Values["details"] = details;
            var promptMessage = MessageFactory.Text(messageText, messageText, InputHints.ExpectingInput);

            return(await stepContext.PromptAsync(nameof(ConfirmPrompt), new PromptOptions { Prompt = promptMessage }, cancellationToken));
        }
Esempio n. 2
0
        private async Task <DialogTurnResult> AskForObligationVmsStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var details = (ChatbotDetails)stepContext.Values["details"];

            if (stepContext.Result is FoundChoice choice)
            {
                details.LandscapeTag = choice.Value;

                var message = "Die Landschaft " + details.LandscapeTag + " hat folgende VMs." + Environment.NewLine +
                              " Bitte tippe die IDs der VMs mit Leerzeichen getrennt ein, welche als notwendig gekennzeichnet werden sollen.";

                var handler = new AzureHandler(details.User.Tenant, details.User.TokenResponse.Token);
                int id      = 0;
                var dic     = new Dictionary <int, string>();
                foreach (var vm in handler.GetListOfVmsFromSpecificLandscapeTag(details.LandscapeTag))
                {
                    dic.Add(id, vm);
                    message = message + Environment.NewLine + id + ".) " + vm;
                    id++;
                }

                stepContext.Values["dic"] = dic;
                var promptMessage = MessageFactory.Text(message, message, InputHints.ExpectingInput);
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = promptMessage }, cancellationToken));
            }
            else
            {
                return(await stepContext.EndDialogAsync(null, cancellationToken));
            }
        }
        private async Task <DialogTurnResult> ListVmsStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var details = (ChatbotDetails)stepContext.Values["details"];

            if (stepContext.Result is FoundChoice choice)
            {
                details.LandscapeTag          = choice.Value;
                stepContext.Values["details"] = details;
            }
            var handler            = new AzureHandler(details.User.Tenant, details.User.TokenResponse.Token);
            var vmsInThisLandscape = handler.GetListOfVmsFromSpecificLandscapeTag(details.LandscapeTag);
            var message            = "Folgende VMs befinden sich in dieser Landschaft und werden herunter gefahren:" + Environment.NewLine;

            foreach (var vm in vmsInThisLandscape)
            {
                message = message + vm + Environment.NewLine;
            }

            return(await stepContext.NextAsync(details, cancellationToken));
        }