Exemplo n.º 1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string secretout = appid + ":" + secret;
                var    uri       = new Uri("https://directline.botframework.com");

                string newsecret = "zHhveP4jk4o.cwA.cIA.QERY2t7safaD557XAYfyFp0WZrpQji3s2nI7QbPunSQ";

                DirectLineClientCredentials creds = new DirectLineClientCredentials(newsecret);

                DirectLineClient client = new DirectLineClient(uri, creds);
                Microsoft.Bot.Connector.DirectLine.Conversations convs = new Microsoft.Bot.Connector.DirectLine.Conversations(client);

                string waterMark;

                var conv = convs.NewConversation();
                var set  = convs.GetMessages(conv.ConversationId);
                waterMark = set.Watermark;

                Microsoft.Bot.Connector.DirectLine.Models.Message message = new Microsoft.Bot.Connector.DirectLine.Models.Message(conversationId: conv.ConversationId, text: textBox1.Text);
                //Console.WriteLine(message.Text);
                convs.PostMessage(conv.ConversationId, message);

                set = convs.GetMessages(conv.ConversationId, waterMark);
                PrintResponse(set);
                waterMark = set.Watermark;

                string x = await MakeRequest(textBox1.Text);

                //System.Threading.Thread.Sleep(15000);

                if (x != String.Empty)
                {
                    textBox2.Text += " Return JSON: " + x + System.Environment.NewLine;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                string secretout = appid + ":" + secret;
                //var uri = new Uri("https://directline.botframework.com");
                var uri = new Uri(ConfigurationManager.AppSettings["DirectLineURL"].ToString());

                //string newsecret = "zHhveP4jk4o.cwA.cIA.QERY2t7safaD557XAYfyFp0WZrpQji3s2nI7QbPunSQ";

                string newsecret = ConfigurationManager.AppSettings["DirectLineSecret"].ToString();

                DirectLineClientCredentials creds = new DirectLineClientCredentials(newsecret);

                DirectLineClient client = new DirectLineClient(uri, creds);
                Microsoft.Bot.Connector.DirectLine.Conversations convs = new Microsoft.Bot.Connector.DirectLine.Conversations(client);

                string waterMark;

                var conv = convs.NewConversation();
                var set  = convs.GetMessages(conv.ConversationId);
                waterMark = set.Watermark;

                Microsoft.Bot.Connector.DirectLine.Models.Message message = new Microsoft.Bot.Connector.DirectLine.Models.Message(conversationId: conv.ConversationId, text: textBox1.Text);
                //Console.WriteLine(message.Text);
                convs.PostMessage(conv.ConversationId, message);

                set = convs.GetMessages(conv.ConversationId, waterMark);
                PrintResponse(set);
                waterMark = set.Watermark;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }