Example #1
0
        public ActionResult IndexPost()
        {
            Stream    stream = new MemoryStream(ActionFilter.bytes);
            XDocument xml    = XDocument.Load(stream);
            XMLModel  model  = XmlEX.ResolveXML(xml);

            try
            {
                string msg;//被动回复
                switch (model.MsgType)
                {
                case "text":
                    msg = new WxProcess().TxtProcess(model);
                    Response.Write(msg);
                    break;

                case "event":
                    msg = new WxProcess().WatchEvent(model);
                    Response.Write(msg);
                    break;

                default:
                    Response.Write("success");
                    break;
                }
                Response.End();
            }
            catch (Exception ex)
            {
                string msg = ex.Message + "=>" + ex.InnerException;
                Common.WriteLog(msg);
            }
            return(View());
        }
Example #2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var Request  = filterContext.RequestContext.HttpContext.Request;
            var Response = filterContext.RequestContext.HttpContext.Response;

            Stream    stream = Request.InputStream;
            XDocument xml    = new XDocument();
            string    msg    = "";

            if (stream.Length > 0)
            {
                bytes = new byte[stream.Length]; //复制流到byte
                stream.Read(bytes, 0, bytes.Length);
                string aadaaa     = System.Text.Encoding.Default.GetString(bytes);
                Stream new_stream = new MemoryStream(bytes);

                xml = XDocument.Load(new_stream);
                XMLModel model = XmlEX.ResolveXML(xml);
                msg = model.ToString();
            }
            var    parameter = filterContext.ActionDescriptor.GetParameters();
            string action    = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName.ToString() + " -> " + filterContext.ActionDescriptor.ActionName.ToString();

            Common.WriteLog(JsonConvert.SerializeObject(new { Action = action, Parament = msg }));
        }