Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainDialog"/> class.
        /// </summary>
        /// <param name="logger">Instance to send logs to the Application Insights service.</param>
        /// <param name="graphApiHelper">Helper for working with Microsoft Graph api.</param>
        /// <param name="storageHelper">Helper for working with Microsoft Azure Table storage service.</param>
        /// /// <param name="optionsAccessor">A set of key/value application configuration properties for AADv1 connection name.</param>
        public MainDialog(IGraphApiHelper graphApiHelper, IUserProfileActivityStorageHelper storageHelper, IOptionsMonitor <AADSettings> optionsAccessor, ILogger <MainDialog> logger)
            : base(nameof(MainDialog), optionsAccessor.CurrentValue.ConnectionName)
        {
            this.graphApiHelper = graphApiHelper;
            this.storageHelper  = storageHelper;
            this.logger         = logger;

            this.AddDialog(new OAuthPrompt(
                               nameof(OAuthPrompt),
                               new OAuthPromptSettings
            {
                ConnectionName = optionsAccessor.CurrentValue.ConnectionName,
                Text           = Strings.SigninCardText,
                Title          = Strings.SignInBtnText,
                Timeout        = Convert.ToInt32(TimeSpan.FromMinutes(5).TotalMilliseconds), // In milliseconds
            }));

            this.AddDialog(new WaterfallDialog(
                               nameof(WaterfallDialog),
                               new WaterfallStep[] { this.OAuthPromptStepAsync, this.MyProfileAndSearchAsync }));

            // The initial child Dialog to run.
            this.InitialDialogId = nameof(WaterfallDialog);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MainDialog"/> class.
        /// </summary>
        /// <param name="graphApiHelper">Helper for working with Microsoft Graph API.</param>
        /// <param name="storageHelper">Helper for working with Microsoft Azure Table storage service.</param>
        /// <param name="botSettings">A set of key/value application configuration properties.</param>
        /// <param name="logger">Instance to send logs to the Application Insights service.</param>
        public MainDialog(IGraphApiHelper graphApiHelper, IUserProfileActivityStorageHelper storageHelper, IOptionsMonitor <BotSettings> botSettings, ILogger <MainDialog> logger)
            : base(nameof(MainDialog), botSettings.CurrentValue.OAuthConnectionName)
        {
            this.graphApiHelper = graphApiHelper;
            this.storageHelper  = storageHelper;
            this.logger         = logger;

            this.AddDialog(new OAuthPrompt(
                               nameof(OAuthPrompt),
                               new OAuthPromptSettings
            {
                ConnectionName = botSettings.CurrentValue.OAuthConnectionName,
                Text           = Strings.SignInCardText,
                Title          = Strings.SignInButtonText,
                Timeout        = (int)TimeSpan.FromMinutes(5).TotalMilliseconds,
            }));

            this.AddDialog(new WaterfallDialog(
                               "MainDialog",
                               new WaterfallStep[] { this.CheckForUnknownInputAsync, this.OAuthPromptStepAsync, this.MyProfileAndSearchAsync }));

            // The initial child Dialog to run.
            this.InitialDialogId = "MainDialog";
        }