Exemplo n.º 1
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            //Voc.inited_rwl.EnterReadLock();
            //Voc.inited_rwl.ExitReadLock();
            using (var lk = await Voc.inited_rwl.WriterLockAsync())
            {
                bool inited = Voc.inited;
                if (!inited)
                {
                    Init();
                    Voc.inited = true;
                }
            }
            var activity = await result as Activity;

            // calculate something for us to return
            int length = (activity.Text ?? string.Empty).Length;

            // return our reply to the user
            //Voc.Show2(activity.Text);
            //string res = "";
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.AppendLine($"{activity.Text}");
            sb.AppendLine(new string('-', 20));
            foreach (var x in Voc.Show(activity.Text))
            {
                //res += x+" ";
                sb.AppendLine($"{x.Item2}");
                sb.AppendLine($"    {x.Item1}");
                //await context.PostAsync(x);
            }
            var s = sb.ToString().Replace("\n", "<br/>") /*.Replace("(",System.Web.HttpUtility.HtmlEncode("("))*//*.Replace(")","\\)").Replace("[","\\[").Replace("]","\\]")*/;

            //s = System.Web.HttpUtility.UrlEncode(s);
            System.Diagnostics.Trace.WriteLine(s);
            await context.PostAsync(s);

            //await context.PostAsync($"You sent {activity.Text} which is {res} !");
            //await context.PostAsync(HttpRuntime.AppDomainAppPath + "db\\");

            //await context.PostAsync($"You sent {activity.Text} which is {activity.Text} ");

            context.Wait(MessageReceivedAsync);
        }
Exemplo n.º 2
0
        public void OnPost()
        {
            //System.Text.StringBuilder sb = new System.Text.StringBuilder();
            //sb.AppendLine($"{activity.Text}");
            //sb.AppendLine(new string('-', 20));
            Message.Clear();
            foreach (var x in Voc.Show(Query))
            {
                //res += x+" ";
                //sb.AppendLine($"{x.Item2}");
                //sb.AppendLine($"    {x.Item1}");
                Message.Add(new Tuple <string, string>($"{x.Item2}", $"{x.Item1}"));
                //await context.PostAsync(x);
            }
            //var s = sb.ToString().Replace("\n", "<br />");
            /*.Replace("(",System.Web.HttpUtility.HtmlEncode("("))*//*.Replace(")","\\)").Replace("[","\\[").Replace("]","\\]")*/

            //Message = s;
        }