public override void ProcessWeiXin(WeiXinContext context)
 {
     XElement result = new XElement("xml", new XElement("ToUserName", context.Request.FromUserName),
                                    new XElement("FromUserName", context.Request.ToUserName),
                                    new XElement("CreateTime", DateTime.Now.GetInt()),
                                    new XElement("MsgType", WeiXinMsgType.Text.ToString().ToLower()),
                                    new XElement("Content", "为什么不爱我?"));
     context.Response.Write(result);
 }
        public override void ProcessWeiXin(WeiXinContext context)
        {
            WeiXinTextMessageEntity requestModel = context.Request.GetRequestModel<WeiXinTextMessageEntity>();

            WeiXinTextMessageEntity responseModel = new WeiXinTextMessageEntity
                {
                    ToUserName =requestModel.FromUserName,
                    Content = string.Format("你请求的是text类型消息!执行的控制器是:{0},实现:{1}", this.GetType().FullName, this.GetType().GetInterface("IWeiXinHandler").FullName),
                    MsgType = requestModel.MsgType
                };
            context.Response.Write(responseModel);
        }
        public override void ProcessWeiXin(WeiXinContext context)
        {
            WeiXinImageMessageEntity requestModel = context.Request.GetRequestModel<WeiXinImageMessageEntity>();

            WeiXinImageMessageEntity responseModel = new WeiXinImageMessageEntity
                {
                    ToUserName = requestModel.FromUserName,
                    MsgType = WeiXinMsgType.Image.ToString().ToLower()
                };

            XElement xElement = responseModel.GetXElement();
            xElement.Add(new XElement("Image", new XElement("MediaId", requestModel.MediaId)));

            context.Response.Write(xElement);
        }
 /// <summary>
 /// 构造函数,把请求消息封装到微信上下文
 /// </summary>
 /// <param name="requestXml">请求消息Xml</param>
 public WeiXinApplication(XElement requestXml)
 {
     this._context = new WeiXinContext(requestXml);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 构造函数,把请求消息封装到微信上下文
 /// </summary>
 /// <param name="requestXml">请求消息Xml</param>
 public WeiXinApplication(XElement requestXml)
 {
     this._context = new WeiXinContext(requestXml);
 }
        public override void ProcessWeiXin(WeiXinContext context)
        {
            string userInfo = string.Empty;
            string nick_name = UtilityAccessToken.GetUserInfo(context.Request.FromUserName);

            UtilityMenu.DeleteMenu();
            string menu = "{" +
    "\"button\": [" +
        "{" +
            "\"name\": \"关于我们\"," +
            "\"sub_button\": [" +
                "{" +
                    "\"type\": \"view\"," +
                    "\"name\": \"关于我们\"," +
                    "\"url\": \"http://www.soyisoft.cn/WebUI/pages/a5001.aspx\"" +
                "}," +
                "{" +
                    "\"type\": \"view\"," +
                    "\"name\": \"信息中心\"," +
                    "\"url\": \"http://www.soyisoft.cn/WebUI/pages/a1001.aspx\"" +
                "}" +
            "]" +
        "}," +
        "{" +
            "\"name\": \"产品方案\"," +
            "\"sub_button\": [" +
                "{" +
                    "\"type\": \"view\"," +
                    "\"name\": \"产品列表\"," +
                    "\"url\": \"http://www.soyisoft.cn/WeiXin/Ui/Products/ShowProduct.aspx?shop_id=1\"" +
                "}," +
                "{" +
                    "\"type\": \"view\"," +
                    "\"name\": \"店铺列表\"," +
                    "\"url\": \"http://www.soyisoft.cn/WeiXin/Ui/Shop/ShopPreview.htm?shop_id=1\"" +
                "}," +
                "{" +
                    "\"type\": \"view\"," +
                    "\"name\": \"活动列表\"," +
                    "\"url\": \"http://www.soyisoft.cn/WeiXin/Ui/Activity/ActViewList.aspx?shop_id=1\"" +
                "}" +
            "]" +
        "}," +
        "{" +
            "\"name\": \"沃尔沃\"," +
            "\"sub_button\": [" +
                "{" +
                    "\"type\": \"view\"," +
                    "\"name\": \"报修登记\"," +
                    "\"url\": \"http://t.vdis.cn/BI/Ui/Wx/RepairEdit.aspx\"" +
                "}," +
                "{" +
                    "\"type\": \"view\"," +
                    "\"name\": \"报修查询\"," +
                    "\"url\": \"http://t.vdis.cn/BI/Ui/Wx/RepairList.aspx\"" +
                "}," +
                "{" +
                    "\"type\": \"view\"," +
                    "\"name\": \"经验分享\"," +
                    "\"url\": \"http://t.vdis.cn/BI/Ui/Wx/ShareList.aspx\"" +
                "}" +
            "]" +
        "}" +
    "]" +
"}";
            menu = menu.Replace(" ", "");
            UtilityMenu.CreateMenu(menu);
            //context.Response.Write(menu);
            //s_Log.Info(this.GetType().ToString() + ":" + menu);
            
            XElement result = new XElement("xml", new XElement("ToUserName", context.Request.FromUserName),
                new XElement("FromUserName", context.Request.ToUserName),
                new XElement("CreateTime", DateTime.Now.GetInt()),
                new XElement("MsgType", WeiXinMsgType.Text.ToString().ToLower()),
                new XElement("Content", nick_name + " 您好:欢迎关注索一软件微信订阅号。"));
            context.Response.Write(result);

            
        }