Esempio n. 1
0
 static string ProcessKeyMvc(WechatContext context)
 {
     if (pluginAssembly == null)
     {
         lock (obj)
         {
             if (pluginAssembly == null)
             {
                 var       d         = @"D:\Work\OpenData.Core\Server\WechatMessageServer\Process";
                 Generator generator = new Generator();
                 pluginAssembly = generator.Generate(d);
             }
         }
     }
     foreach (var item in pluginAssembly.GetTypes())
     {
         var plugin = (DynamicView)Activator.CreateInstance(item);
         plugin.ExecuteAsync().GetAwaiter().GetResult();
         if (!string.IsNullOrEmpty(plugin.Content.ToString()))
         {
             return(plugin.Content.ToString());
         }
     }
     return("Mvc");
 }
Esempio n. 2
0
        static string ProcessKeyWord(WechatContext context)
        {
            IWechatService service = AppEngine.Default.GetService <IWechatService>();
            var            list    = service.GetWechatResponse(context.openId, Module.Wechat.Entity.SearchType.None, context.CurrentOfficialAccount.Id);

            return("Keyword");
        }
Esempio n. 3
0
 static string ProcessBase(WechatContext context)
 {
     if (!context.Signatured)
     {
         return(string.Empty);
     }
     //todo
     return(null);
 }
Esempio n. 4
0
            Task <object> Process(WechatContext context)
            {
                Task <object> task = new Task <object>(() =>
                {
                    foreach (var item in this.messageProcessor)
                    {
                        var result = item(context);
                        if (result != null)
                        {
                            return(result);
                        }
                    }
                    return(string.Empty);
                });

                task.Start();
                return(task);
            }
Esempio n. 5
0
            public async Task Invoke(HttpContext context)
            {
                WechatContext wechatContext = new WechatContext(context);

                if (!wechatContext.Signatured)
                {
                    await context.Response.WriteAsync(string.Empty);
                }
                var echoString = wechatContext.Echo();

                if (!string.IsNullOrEmpty(echoString))
                {
                    await context.Response.WriteAsync(echoString);
                }
                wechatContext.Echo();
                var result = this.Process(wechatContext);

                if (result.Wait(4900))
                {
                    await context.Response.WriteAsync(result.Result.ToString());
                }
                await next(context);
            }