コード例 #1
0
ファイル: ProductDialog.cs プロジェクト: rizlajf/SampleBot
        private async Task OnShowOptionSelected(IDialogContext context, IAwaitable <string> result)
        {
            // Construct a base URL for Image
            // To allow it to be found wherever the application is deployed
            string strCurrentURL = ConfigurationManager.AppSettings["strCurrentURL"];

            try
            {
                var resultMessage = context.MakeMessage();
                resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                resultMessage.Attachments      = new List <Attachment>();

                string              optionSelected = await result;
                List <HeroCard>     herocardList   = null;
                ProductContentClass pc             = new ProductContentClass();

                switch (optionSelected)
                {
                case "Amplifiers":
                    herocardList = pc.GenerateAmplifiersContent();
                    break;

                case "Balun":
                    herocardList = pc.GenerateBalunContent();
                    break;

                case "Bias Tees":

                    break;

                case "Couplers":

                    break;

                case "Equalizers":

                    break;
                }
                foreach (HeroCard hc in herocardList)
                {
                    resultMessage.Attachments.Add(hc.ToAttachment());
                }
                await context.PostAsync(resultMessage);
            }
            catch (TooManyAttemptsException ex)
            {
                await context.PostAsync($"Ooops! Too many attemps :(. But don't worry, I'm handling that exception and you can try again!");

                context.Wait(this.MessageReceivedAsync);
            }
            finally
            {
                PromptDialog.Choice(context, this.MoreQuestionAsync, new List <string>()
                {
                    "Yes", "No"
                }, "Is anything else I can help you out?");
                //context.Wait(this.MessageReceivedAsync);
            }
        }
コード例 #2
0
        public async Task SearchProduct(IDialogContext context, LuisResult luisResult)
        {
            //var dialog = new RootDialog();
            //await context.Forward(new ProductDialog(), dialog.ResumeAfterProductDialog, null, CancellationToken.None);
            foreach (EntityRecommendation curEntity in luisResult.Entities)
            {
                //await dialog.RedirectToproductContentGenerator(context, curEntity.Entity);

                var resultMessage = context.MakeMessage();
                resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                resultMessage.Attachments      = new List <Attachment>();

                List <HeroCard>     herocardList = null;
                ProductContentClass pc           = new ProductContentClass();

                switch (curEntity.Entity.ToLower().ToString())
                {
                case "amplifier":
                    herocardList = pc.GenerateAmplifiersContent();
                    break;

                case "balun":
                    herocardList = pc.GenerateBalunContent();
                    break;

                case "bias tees":

                    break;

                case "coupler":

                    break;

                case "equalizer":

                    break;

                default:
                    herocardList = null;
                    break;
                }
                if (herocardList != null)
                {
                    await context.PostAsync("Collecting informstions on " + curEntity.Entity);

                    foreach (HeroCard hc in herocardList)
                    {
                        resultMessage.Attachments.Add(hc.ToAttachment());
                    }
                    await context.PostAsync(resultMessage);

                    context.Wait(this.MessageReceived);
                }
                else
                {
                    continue;
                }
            }
        }
コード例 #3
0
        public async Task RedirectToproductContentGenerator(IDialogContext context, string product)
        {
            string category      = product;
            var    resultMessage = context.MakeMessage();

            resultMessage.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            resultMessage.Attachments      = new List <Attachment>();

            List <HeroCard>     herocardList = null;
            ProductContentClass pc           = new ProductContentClass();

            switch (product.ToLower().ToString())
            {
            case "amplifier":
                herocardList = pc.GenerateAmplifiersContent();
                break;

            case "balun":
                herocardList = pc.GenerateBalunContent();
                break;

            case "bias tees":

                break;

            case "coupler":

                break;

            case "equalizer":

                break;

            default:
                herocardList = null;
                break;
            }
            if (herocardList != null)
            {
                foreach (HeroCard hc in herocardList)
                {
                    resultMessage.Attachments.Add(hc.ToAttachment());
                }
            }
            else
            {
                return;
            }

            await context.PostAsync(resultMessage);

            context.Wait(this.MessageReceivedAsync);
        }