예제 #1
0
파일: Yahoo.cs 프로젝트: amynic/demos
        public static async Task <string> GetStock(string strStock)
        {
            string strRet   = string.Empty;
            double?dblStock = await Yahoo.GetStockPriceAsync(strStock);

            if (null == dblStock)   // might be a company name rather than a stock ticker name
            {
                string strTicker = await GetStockTickerName(strStock);

                if (string.Empty != strTicker)
                {
                    dblStock = await Yahoo.GetStockPriceAsync(strTicker);

                    strStock = strTicker;
                }
            }

            // return our reply to the user
            if (null == dblStock)
            {
                strRet = string.Format("Stock {0} doesn't appear to be valid", strStock.ToUpper());
            }
            else
            {
                strRet = string.Format("Stock: {0}, Value: {1}", strStock.ToUpper(), dblStock);
            }

            return(strRet);
        }
예제 #2
0
        public async Task StockPrice(IDialogContext context, LuisResult result)
        {
            string strRet = result.Entities[0].Entity;

            //store this stock for the conversation
            context.ConversationData.SetValue <string>("LastStock", strRet);

            await context.PostAsync(await Yahoo.GetStock(strRet));

            context.Wait(MessageReceived);
        }
예제 #3
0
        public async Task RepeatLastStock(IDialogContext context, LuisResult result)
        {
            string strRet   = string.Empty;
            string strStock = string.Empty;

            if (!context.ConversationData.TryGetValue("LastStock", out strStock))
            {
                strRet = "I don't have a previous stock to look up!";
            }
            else
            {
                strRet = await Yahoo.GetStock(strStock);
            }
            await context.PostAsync(strRet);

            context.Wait(MessageReceived);
        }