コード例 #1
0
ファイル: HttpHelper.cs プロジェクト: JeremiahW/runningrecord
        public static TextMessageModel GetMessage(string message)
        {
            XmlDocument requestDocXml = new XmlDocument();
            requestDocXml.LoadXml(message);
            XmlElement rootElement = requestDocXml.DocumentElement;

            string msgType = rootElement.SelectSingleNode("MsgType").InnerText;
            TextMessageModel model = new TextMessageModel();
            model.ToUserName = rootElement.SelectSingleNode("ToUserName").InnerText;
            model.FromUserName = rootElement.SelectSingleNode("FromUserName").InnerText;
            model.CreateTime = rootElement.SelectSingleNode("CreateTime").InnerText;
            model.MsgType = rootElement.SelectSingleNode("MsgType").InnerText;
            model.Content = rootElement.SelectSingleNode("Content").InnerText;
            return model;
        }
コード例 #2
0
ファイル: HttpHelper.cs プロジェクト: JeremiahW/runningrecord
        public static string ReplyMessage(TextMessageModel model, HttpContext context)
        {
            string template = @"<xml>
                    <ToUserName>{0}</ToUserName>
                    <FromUserName>{1}</FromUserName>
                    <CreateTime>{2}</CreateTime>
                    <MsgType>{3}</MsgType>
                    <Content><![CDATA[{4}]]></Content>
                    </xml>";
            string replyMsg = string.Empty;
            switch (model.Content.ToLower())
            {
                case "help":
                    replyMsg = string.Format("1. <a href='{0}'>{1}</a>" + Environment.NewLine, GetUserRegPage(context),
                        Resource.UserRegisteration);
                    replyMsg += string.Format("2. <a href='{0}'>{1}</a>" + Environment.NewLine, GetRunningRecordPage(context),
                        Resource.UploadRecord);
                    replyMsg += string.Format("3. <a href='{0}'>{1}</a>", GetRunningRecordPage(context),
                        Resource.CheckMemberCardNum);
                    break;
                default:
                    replyMsg = string.Format(Resource.DefultReplyMessage, model.Content);
                    break;
            }

            return string.Format(template, model.FromUserName, model.ToUserName, DateTime.Now.Ticks, "text", replyMsg);
        }