Пример #1
0
        public MainDialog(
            BotSettings settings,
            BotServices services,
            ResponseManager responseManager,
            ConversationState conversationState,
            UserState userState,
            ForwardEmailDialog forwardEmailDialog,
            SendEmailDialog sendEmailDialog,
            ShowEmailDialog showEmailDialog,
            ReplyEmailDialog replyEmailDialog,
            DeleteEmailDialog deleteEmailDialog,
            IBotTelemetryClient telemetryClient)
            : base(nameof(MainDialog), telemetryClient)
        {
            _settings          = settings;
            _services          = services;
            _userState         = userState;
            _responseManager   = responseManager;
            _conversationState = conversationState;
            TelemetryClient    = telemetryClient;
            _stateAccessor     = _conversationState.CreateProperty <EmailSkillState>(nameof(EmailSkillState));

            AddDialog(forwardEmailDialog ?? throw new ArgumentNullException(nameof(forwardEmailDialog)));
            AddDialog(sendEmailDialog ?? throw new ArgumentNullException(nameof(sendEmailDialog)));
            AddDialog(showEmailDialog ?? throw new ArgumentNullException(nameof(showEmailDialog)));
            AddDialog(replyEmailDialog ?? throw new ArgumentNullException(nameof(replyEmailDialog)));
            AddDialog(deleteEmailDialog ?? throw new ArgumentNullException(nameof(deleteEmailDialog)));

            GetReadingDisplayConfig();
        }
        public MainDialog(
            IServiceProvider serviceProvider,
            IBotTelemetryClient telemetryClient)
            : base(nameof(MainDialog), telemetryClient)
        {
            _settings          = serviceProvider.GetService <BotSettings>();
            _services          = serviceProvider.GetService <BotServices>();
            _userState         = serviceProvider.GetService <UserState>();
            _responseManager   = serviceProvider.GetService <ResponseManager>();
            _conversationState = serviceProvider.GetService <ConversationState>();
            TelemetryClient    = telemetryClient;
            _stateAccessor     = _conversationState.CreateProperty <EmailSkillState>(nameof(EmailSkillState));

            _forwardEmailDialog = serviceProvider.GetService <ForwardEmailDialog>();
            _sendEmailDialog    = serviceProvider.GetService <SendEmailDialog>();
            _showEmailDialog    = serviceProvider.GetService <ShowEmailDialog>();
            _replyEmailDialog   = serviceProvider.GetService <ReplyEmailDialog>();
            _deleteEmailDialog  = serviceProvider.GetService <DeleteEmailDialog>();

            AddDialog(_forwardEmailDialog ?? throw new ArgumentNullException(nameof(_forwardEmailDialog)));
            AddDialog(_sendEmailDialog ?? throw new ArgumentNullException(nameof(_sendEmailDialog)));
            AddDialog(_showEmailDialog ?? throw new ArgumentNullException(nameof(_showEmailDialog)));
            AddDialog(_replyEmailDialog ?? throw new ArgumentNullException(nameof(_replyEmailDialog)));
            AddDialog(_deleteEmailDialog ?? throw new ArgumentNullException(nameof(_deleteEmailDialog)));

            GetReadingDisplayConfig();
        }
        public ShowEmailDialog(
            BotSettings settings,
            BotServices services,
            ResponseManager responseManager,
            ConversationState conversationState,
            DeleteEmailDialog deleteEmailDialog,
            ReplyEmailDialog replyEmailDialog,
            ForwardEmailDialog forwardEmailDialog,
            IServiceManager serviceManager,
            IBotTelemetryClient telemetryClient,
            MicrosoftAppCredentials appCredentials)
            : base(nameof(ShowEmailDialog), settings, services, responseManager, conversationState, serviceManager, telemetryClient, appCredentials)
        {
            TelemetryClient = telemetryClient;

            var showEmail = new WaterfallStep[]
            {
                IfClearContextStep,
                GetAuthToken,
                AfterGetAuthToken,
                Display
            };

            var readEmail = new WaterfallStep[]
            {
                ReadEmail,
                Reshow
            };

            var deleteEmail = new WaterfallStep[]
            {
                DeleteEmail,
                Reshow
            };

            var forwardEmail = new WaterfallStep[]
            {
                ForwardEmail,
                Reshow
            };

            var replyEmail = new WaterfallStep[]
            {
                ReplyEmail,
                Reshow
            };

            var displayEmail = new WaterfallStep[]
            {
                IfClearPagingConditionStep,
                PagingStep,
                ShowEmails,
                PromptToHandle,
                CheckRead,
                HandleMore
            };

            var displayFilteredEmail = new WaterfallStep[]
            {
                ShowFilteredEmails,
                PromptToHandle,
                CheckRead,
                HandleMore
            };

            var redisplayEmail = new WaterfallStep[]
            {
                PromptToReshow,
                CheckReshow,
                HandleMore,
            };

            // Define the conversation flow using a waterfall model.
            AddDialog(new WaterfallDialog(Actions.Show, showEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.Read, readEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.Delete, deleteEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.Forward, forwardEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.Reply, replyEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.Display, displayEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.DisplayFiltered, displayFilteredEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(new WaterfallDialog(Actions.ReDisplay, redisplayEmail)
            {
                TelemetryClient = telemetryClient
            });
            AddDialog(deleteEmailDialog ?? throw new ArgumentNullException(nameof(deleteEmailDialog)));
            AddDialog(replyEmailDialog ?? throw new ArgumentNullException(nameof(replyEmailDialog)));
            AddDialog(forwardEmailDialog ?? throw new ArgumentNullException(nameof(forwardEmailDialog)));
            InitialDialogId = Actions.Show;
        }