예제 #1
0
        /// <summary>
        /// Get valid options based on current state of bot.
        /// </summary>
        /// <returns></returns>
        protected async Task <IEnumerable <string> > GetValidOptions(IDialogContext context)
        {
            var options = new List <string>();

            // Can log in or out.
            var accessToken = await _authenticationService.GetAccessToken(context);

            if (accessToken != null)
            {
                options.Add(Constants.Choices.LogOut);

                // If logged in, can select site and find out the current site.
                options.Add(Constants.Choices.SelectSite);
                options.Add(Constants.Choices.GetCurrentSite);

                // If a site is selected, can select list.
                _sharePointBotStateService.BotContext = context;
                if (await _sharePointBotStateService.GetCurrentSite() != null)
                {
                    options.Add(Constants.Choices.SelectList);
                }
            }
            else
            {
                options.Add(Constants.Choices.LogIn);
            }

            return(options);
        }
예제 #2
0
        public async Task StartAsync(IDialogContext context)
        {
            BotSite currentSite = null;

            _sharePointBotStateService.BotContext = context;
            currentSite = await _sharePointBotStateService.GetCurrentSite();


            if (currentSite != null)
            {
                var siteNameToDisplay = !string.IsNullOrEmpty(currentSite.Alias) ? currentSite.Alias : currentSite.Title;

                await context.PostAsync($"You are on site '{siteNameToDisplay}' ({currentSite.Url}).");
            }
            else
            {
                await context.PostAsync("You haven't selected a site.");
            }

            context.Done(currentSite);
        }