Exemplo n.º 1
0
        /// <summary>
        /// 将内容转化为实体
        /// </summary>
        /// <param name="xe"></param>
        /// <returns></returns>
        public static WeixinMessageEntity ConsoleXmlToModel(XmlElement xe)
        {
            var model = new WeixinMessageEntity();

            model.FromUser = xe.SelectSingleNode("FromUserName").InnerText;
            switch (xe.SelectSingleNode("MsgType").InnerText)
            {
            case "text":
                model.MsgType    = MsgType.text;
                model.Content    = xe.SelectSingleNode("Content").InnerText;
                model.MessageID  = xe.SelectSingleNode("MsgId").InnerText;
                model.ToUser     = xe.SelectSingleNode("ToUserName").InnerText;
                model.CreateTime = xe.SelectSingleNode("CreateTime").InnerText;
                break;

            case "event":
                model.MsgType  = MsgType.Event;
                model.Event    = xe.SelectSingleNode("Event").InnerText;
                model.EventKey = xe.SelectSingleNode("EventKey").InnerText;
                break;

            default:
                model.MsgType = MsgType.text;
                break;
            }
            return(model);
        }
Exemplo n.º 2
0
        public static WeixinMessageEntity CreateToSendModel(WeixinMessageEntity sourceEntity)
        {
            var model = new WeixinMessageEntity
            {
                CreateTime = CommonMethod.DateTimeToUnixInt(DateTime.Now).ToString(),
                FromUser   = sourceEntity.ToUser,
                ToUser     = sourceEntity.FromUser,
                MessageID  = sourceEntity.MessageID
            };

            return(model);
        }
Exemplo n.º 3
0
        public string ReadStreamAndReply(HttpRequestBase request)
        {
            string txt = new WeiXinCommon().PostInput(request, Encoding.UTF8);

            FileMessageSave.MessageSave(txt);

            XmlDocument xml = new XmlDocument();

            xml.LoadXml(txt);
            XmlElement          xe     = xml.DocumentElement;
            WeixinMessageEntity entity = ModelCommon.ConsoleXmlToModel(xe);

            MessageFactory factory = new MessageFactory(entity);
            var            message = factory.ConsoleMessage();

            FileMessageSave.MessageSave(message);
            return(message);
        }
Exemplo n.º 4
0
 public TextMessageConsole(WeixinMessageEntity entity)
 {
     this.entity = entity;
 }
Exemplo n.º 5
0
 public EventClickMessageConsole(WeixinMessageEntity entity)
 {
     this.entity = entity;
 }
Exemplo n.º 6
0
 public MessageFactory(WeixinMessageEntity entity)
 {
     this.entity = entity;
 }