Пример #1
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":
                case "amplifiers":
                    herocardList = pc.GenerateAmplifiersContent();
                    break;

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

                case "bias tees":
                case "bias":
                    herocardList = pc.GenerateBiasTeesContent();
                    break;

                case "coupler":
                case "couplers":
                    herocardList = pc.GenerateCouplersContent();
                    break;

                case "equalizer":
                case "equalizers":
                    herocardList = pc.GenerateEqualizersContent();
                    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;
                }
            }
        }
Пример #2
0
        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":
                    herocardList = pc.GenerateBiasTeesContent();
                    break;

                case "Couplers":
                    herocardList = pc.GenerateCouplersContent();
                    break;

                case "Equalizers":
                    herocardList = pc.GenerateEqualizersContent();
                    break;

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

                    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);
            }
        }