Example #1
0
        private async Task <DialogTurnResult> ReportAuthCheckingStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var state = await reportStateAccessor.GetAsync(stepContext.Context, () => null);

            if (state == null)
            {
                return(await EndDialogAsync(stepContext, cancellationToken));
            }

            var previousStepResult = CardSubmitResult <string> .Get(stepContext);

            if (previousStepResult != null)
            {
                if (ReportFileFormatConverter.TryParse(previousStepResult.Result, out ReportFormatType format))
                {
                    state.Format = format;
                }
                else
                {
                    return(await EndDialogAsync(stepContext, cancellationToken, Resources.Strings.DialogReportFormatErrorMessage));
                }
            }
            else
            {
                return(await CancelCurrentAndBeginNew(stepContext, cancellationToken));
            }

            return(await stepContext.BeginDialogAsync(nameof(OAuthPrompt), null, cancellationToken));
        }
Example #2
0
        private async Task <DialogTurnResult> ReportScopeStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var state = await reportStateAccessor.GetAsync(stepContext.Context, () => new ReportParameters());

            var previousStepResult = CardSubmitResult <bool> .Get(stepContext);

            if (previousStepResult != null)
            {
                if (previousStepResult.Result)
                {
                    var context  = stepContext.Context;
                    var activity = context.Activity;
                    state.IsChannel = activity.Conversation.ConversationType == Constants.ChannelConversationType;
                    if (state.IsChannel)
                    {
                        var choices = new List <string>
                        {
                            Resources.Strings.ChannelHistoryOptionAll,
                            Resources.Strings.ChannelHistoryOptionConversation,
                            Resources.Strings.CancelOption,
                        };

                        var message = AdaptiveCardsHelper.GetChoicesPrompt(Resources.Strings.DialogReportScopeMessage, choices);
                        message.Id = state.MessageId;
                        await stepContext.Context.UpdateActivityAsync(message, cancellationToken);

                        await reportStateAccessor.SetAsync(stepContext.Context, state);

                        return(new DialogTurnResult(DialogTurnStatus.Waiting)
                        {
                            ParentEnded = false
                        });
                    }
                    else
                    {
                        await reportStateAccessor.SetAsync(stepContext.Context, state);

                        return(await NextAsync(stepContext, cancellationToken));
                    }
                }
                else
                {
                    return(await EndDialogAsync(stepContext, cancellationToken, Resources.Strings.DialogsCancelledMessage));
                }
            }
            else
            {
                return(await CancelCurrentAndBeginNew(stepContext, cancellationToken));
            }
        }
Example #3
0
        private async Task <DialogTurnResult> ReportFileFormatStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var state = await reportStateAccessor.GetAsync(stepContext.Context, () => null);

            if (state == null)
            {
                return(await EndDialogAsync(stepContext, cancellationToken));
            }

            var previousStepResult = CardSubmitResult <string> .Get(stepContext);

            if (state.ReportType == ReportSourceType.Conversation)
            {
                state.ReportPeriod = ReportPeriodType.AllTime;
            }
            else
            {
                if (previousStepResult != null)
                {
                    if (ReportPeriodConverter.TryParse(previousStepResult.Result, out ReportPeriodType period))
                    {
                        state.ReportPeriod = period;
                    }
                    else
                    {
                        return(await EndDialogAsync(stepContext, cancellationToken, Resources.Strings.DialogTimePeriodErrorMessage));
                    }
                }
                else
                {
                    return(await CancelCurrentAndBeginNew(stepContext, cancellationToken));
                }
            }

            var formats = configuration.ReportFormats.Select(x => ReportFileFormatConverter.GetReportFormat(x)).ToList();
            var message = AdaptiveCardsHelper.GetChoicesPrompt(Resources.Strings.DialogFileTypeReportMessage, formats);

            message.Id = state.MessageId;

            await stepContext.Context.UpdateActivityAsync(message, cancellationToken);

            await reportStateAccessor.SetAsync(stepContext.Context, state);

            return(new DialogTurnResult(DialogTurnStatus.Waiting)
            {
                ParentEnded = false
            });
        }
Example #4
0
        private async Task <DialogTurnResult> ReportTimeRangeStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var state = await reportStateAccessor.GetAsync(stepContext.Context, () => null);

            // check dialog state
            if (state == null)
            {
                return(await EndDialogAsync(stepContext, cancellationToken));
            }

            var choices = new List <string> {
                Resources.Strings.TimePeriodOptionAllTime, Resources.Strings.TimePeriodOptionLast7Days, Resources.Strings.TimePeriodOptionLastDay, Resources.Strings.CancelOption
            };
            var message = AdaptiveCardsHelper.GetChoicesPrompt(Resources.Strings.DialogTimeRangeReportMessage, choices);

            message.Id = state.MessageId;

            if (state.IsChannel)
            {
                var previousStepResult = CardSubmitResult <string> .Get(stepContext);

                if (previousStepResult != null && !string.IsNullOrEmpty(previousStepResult.Result))
                {
                    if (previousStepResult.Result.Equals(Resources.Strings.ChannelHistoryOptionAll))
                    {
                        state.ReportType = ReportSourceType.Channel;
                        await state.FillRestDetailsFromActivity(stepContext.Context, cancellationToken);

                        await stepContext.Context.UpdateActivityAsync(message, cancellationToken);

                        await reportStateAccessor.SetAsync(stepContext.Context, state);

                        return(new DialogTurnResult(DialogTurnStatus.Waiting)
                        {
                            ParentEnded = false
                        });
                    }
                    else if (previousStepResult.Result.Equals(Resources.Strings.ChannelHistoryOptionConversation))
                    {
                        state.ReportType = ReportSourceType.Conversation;
                        await state.FillRestDetailsFromActivity(stepContext.Context, cancellationToken);

                        await reportStateAccessor.SetAsync(stepContext.Context, state);

                        return(await NextAsync(stepContext, cancellationToken));
                    }
                }
                else
                {
                    return(await CancelCurrentAndBeginNew(stepContext, cancellationToken));
                }
            }
            else
            {
                state.ReportType = ReportSourceType.Chat;
                await state.FillRestDetailsFromActivity(stepContext.Context, cancellationToken);

                await stepContext.Context.UpdateActivityAsync(message, cancellationToken);

                await reportStateAccessor.SetAsync(stepContext.Context, state);

                return(new DialogTurnResult(DialogTurnStatus.Waiting)
                {
                    ParentEnded = false
                });
            }

            return(await EndDialogAsync(stepContext, cancellationToken, Resources.Strings.DialogsCancelledMessage));
        }