Exemplo n.º 1
0
 /// <summary>
 /// 回复图文信息
 /// </summary>
 /// <param name="requestXML">接收到的请求信息</param>
 /// <param name="articleList">图文列表</param>
 /// <returns></returns>
 public string SendMsg(RequestVO requestXML, IList<WXArticle> articleList)
 {
     string strResult = "";
     var strItems = "";
     foreach (var item in articleList)
     {
         strItems += "<item>"
             + "<Title><![CDATA[" + item.Title + "]]></Title>"
             + "<Description><![CDATA[" + item.Description + "]]></Description>"
             + "<PicUrl><![CDATA[" + item.PicUrl + "]]></PicUrl>"
             + "<Url><![CDATA[" + item.Url + "]]></Url>"
             + "</item>";
     }
     strResult = "<xml>"
         + "<ToUserName><![CDATA[" + requestXML.fromUserName + "]]></ToUserName>"
         + "<FromUserName><![CDATA[" + requestXML.toUserName + "]]></FromUserName>"
         + "<CreateTime>" + Jabinfo.Help.Date.Now + "</CreateTime>"
         + "<MsgType><![CDATA[news]]></MsgType>"
         + "<ArticleCount>" + articleList.Count + "</ArticleCount>"
         + "<Articles>"
         + strItems
         + "</Articles>"
         + "</xml>";
     return strResult;
 }
Exemplo n.º 2
0
        private string devlopID = "wx6522a9d862ae7a0f"; //微信里面开发者模式:开发者ID

        #endregion Fields

        #region Methods

        public string Event(RequestVO requesXML,string key)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string message = string.Empty;
            string strResult = string.Empty;
            Msg msg = new Msg ();
            switch (key)
            {
            case "subscribe":
                message = "感谢您关注【知识产权那点事】微信公众号,我们会定期为你推送我们最新的新闻资讯";
                strResult = msg.SendMsg (requesXML, message);
                // 将关注信息写入follow 表中
                string json = GetInfo (GetAccessToken (), requesXML.fromUserName);
                FollowVO follow = serializer.Deserialize<FollowVO> (json);
                JabinfoKeyValue data = new JabinfoKeyValue ();
                data ["openid"] = follow.openId;
                data ["nickname"] = follow.nickname;
                data ["sex"] = follow.sex;
                data ["province"] = follow.province;
                data ["city"] = follow.city;
                data ["country"] = follow.country;
                data ["headimgurl"] = follow.headimgurl;
                data ["createtime"] = requesXML.createTime.ToString();
                FollowMapper.I.Insert (data);
                break;
            case "unsubscribe":
                message = "取消关注";
                strResult = msg.SendMsg (requesXML, message);
                // 将关注者从数据库中取消
                FollowMapper.I.DeleteByPrimary (requesXML.fromUserName);
                break;
            case "CLICK":
                if (requesXML.EventKey == "inn") {
                    IList<WXArticle> articles = new List<WXArticle> ();
                    WXArticle article = new WXArticle ();
                    article.Description = "上海知识产权研究所,提供最具价值的知识产权资讯";
                    article.PicUrl = "http://www.iprlawyers.com/Files/2014.5.22fugang.jpg";
                    article.Title = "知识产权那点事";
                    article.Url = "http://www.iprlawyers.com/";
                    articles.Add (article);
                    strResult = msg.SendMsg (requesXML, articles);
                }
                break;
            //			case "SCAN":
            //				IList<WXArticle> articles1 = new List<WXArticle> ();
            //				WXArticle item = new WXArticle ();
            //				item.Title = "Kooteam";
            //				item.Description = "KooTeam是一款轻量级的团队时间管理与项目管理的系统,免费提供项目管理,团队协作SaaS解决方案。不需要安装或升级任何软件,您只要注册一个KooTeam账户就马上可以拥有一个多功能、一体化的在线项目管理,团队协作办公系统——无需购买服务器,使用次数不限、使用时长不限、用户数不限、项目数量不限";
            //				item.PicUrl = "http://p.kooteam.com/res/tma/banner/01.jpg";
            //				item.Url = "http://p.kooteam.com";
            //				articles1.Add (item);
            //				strResult = msg.SendMsg (requesXML, articles1);
            //				break;
            default:
                message = "receive a new event:" + requesXML.EventKey;
                strResult = msg.SendMsg (requesXML, message);
                break;
            }
            return strResult;
        }
Exemplo n.º 3
0
 public RequestVO[] Collection(DataTable table)
 {
     int length = table.Rows.Count;
     RequestVO[] result = new RequestVO[length];
     for (int i = 0; i < length; i++) {
         result [i] = new RequestVO ();
     }
     return result;
 }
Exemplo n.º 4
0
 /// <summary>
 /// 回复文字消息
 /// </summary>
 /// <param name="requestXML">接收到的请求信息</param>
 /// <param name="txt">消息内容</param>
 /// <returns></returns>
 public string SendMsg(RequestVO requestXML, string txt)
 {
     string strResult = "";
     strResult = "<xml>"
         + "<ToUserName><![CDATA[" + requestXML.fromUserName + "]]></ToUserName>"
         + "<FromUserName><![CDATA[" + requestXML.toUserName + "]]></FromUserName>"
         + "<CreateTime>" + Jabinfo.Help.Date.Now + "</CreateTime>"
         + "<MsgType><![CDATA[text]]></MsgType>"
         + "<Content><![CDATA[" + txt + "]]></Content>"
         + "</xml>";
     return strResult;
 }
Exemplo n.º 5
0
 /// <summary>
 /// 回复音乐消息
 /// </summary>
 /// <param name="requestXML"></param>
 /// <param name="music"></param>
 /// <returns></returns>
 public string SendMusic(RequestVO requestXML, WXMusic music)
 {
     string strResult = "";
     strResult = "<xml>"
         + "<ToUserName><![CDATA[" + requestXML.fromUserName + "]]></ToUserName>"
         + "<FromUserName><![CDATA[" + requestXML.toUserName + "]]></FromUserName>"
         + "<CreateTime>" + Jabinfo.Help.Date.Now + "</CreateTime>"
         + "<MsgType><![CDATA[music]]></MsgType>"
         + "<Music>"
         + "<Title><![CDATA[" + music.Title + "]]></Title>"
         + "<Description><![CDATA[" + music.Description + "]]></Description>"
         + "<MusicUrl><![CDATA[" + music.MusicUrl + "]]></MusicUrl>"
         + "<HQMusicUrl><![CDATA[" + music.HQMusicUrl + "]]></HQMusicUrl>"
         + "</Music>"
         + "</xml>";
     return strResult;
 }
Exemplo n.º 6
0
 /// <summary>
 /// 发送消息日志
 /// </summary>
 /// <param name="postString">Post string.</param>
 public void loger(RequestVO request)
 {
     JabinfoKeyValue data = new JabinfoKeyValue ();
     data ["requestId"] = Jabinfo.Help.Basic.JabId;
     data ["toUserName"] = request.toUserName;
     data["fromUserName"]=request.fromUserName;
     data ["createTime"] = request.createTime.ToString();
     data ["msgType"] = request.msgType;
     data ["content"] = request.content;
     data ["msgId"] = request.msgId;
     RequestMapper.I.Insert (data);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 获取客户发送来的请求信息
 /// </summary>
 /// <param name="postStr"></param>
 /// <returns></returns>
 public RequestVO GetRequest(string postStr)
 {
     //封装请求类
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(postStr);
     XmlElement rootElement = doc.DocumentElement;
     XmlNode MsgType = rootElement.SelectSingleNode("MsgType");
     RequestVO requestXML = new RequestVO();
     requestXML.toUserName = rootElement.SelectSingleNode("ToUserName").InnerText;
     requestXML.fromUserName = rootElement.SelectSingleNode("FromUserName").InnerText;
     requestXML.createTime = Convert.ToInt32(rootElement.SelectSingleNode("CreateTime").InnerText);
     requestXML.msgType = MsgType.InnerText;
     if (requestXML.msgType == "text") {
         requestXML.content = rootElement.SelectSingleNode ("Content").InnerText;
         requestXML.msgId = rootElement.SelectSingleNode ("MsgId").InnerText;
     } else if (requestXML.msgType == "location") {
         requestXML.Location_X = rootElement.SelectSingleNode ("Location_X").InnerText;
         requestXML.Location_Y = rootElement.SelectSingleNode ("Location_Y").InnerText;
         requestXML.Scale = rootElement.SelectSingleNode ("Scale").InnerText;
         requestXML.Label = rootElement.SelectSingleNode ("Label").InnerText;
         requestXML.msgId = rootElement.SelectSingleNode ("MsgId").InnerText;
     } else if (requestXML.msgType == "image") {
         requestXML.PicUrl = rootElement.SelectSingleNode ("PicUrl").InnerText;
         requestXML.msgId = rootElement.SelectSingleNode ("MsgId").InnerText;
     } else if (requestXML.msgType == "vedio") {
         requestXML.MediaId = rootElement.SelectSingleNode ("MediaId").InnerText;
         requestXML.Title = rootElement.SelectSingleNode ("Title").InnerText;
         requestXML.Description = rootElement.SelectSingleNode ("Description").InnerText;
     } else if (requestXML.msgType == "voice") {
         requestXML.MediaId = rootElement.SelectSingleNode ("MediaId").InnerText;
     } else if (requestXML.msgType == "link")
     {
         requestXML.Title = rootElement.SelectSingleNode("Title").InnerText;
         requestXML.Description = rootElement.SelectSingleNode("Description").InnerText;
         requestXML.Url = rootElement.SelectSingleNode("Url").InnerText;
         requestXML.msgId = rootElement.SelectSingleNode("MsgId").InnerText;
     }
     else if (requestXML.msgType == "event")
     {
         requestXML.createTime = Convert.ToInt32(rootElement.SelectSingleNode ("CreateTime").InnerText);
         requestXML.Event = rootElement.SelectSingleNode("Event").InnerText;
         requestXML.EventKey = rootElement.SelectSingleNode ("EventKey").InnerText;
     }
     return requestXML;
 }
Exemplo n.º 8
0
 RequestVO Init(DataRow dr)
 {
     if (dr == null)
         return null;
     RequestVO VO = new RequestVO ();
     VO.requestId = dr["request_id"] as string;
     VO.toUserName = dr["ToUserName"] as string;
     VO.fromUserName = dr["FromUserName"] as string;
     VO.createTime = Convert.ToInt32(dr["CreateTime"]);
     VO.msgType = dr["MsgType"] as string;
     VO.content = dr["Content"] as string;
     VO.msgId = dr["MsgId"] as string;
     VO.status = dr["status"] as string;
     VO.reply = dr["reply"] as string;
     return VO;
 }
Exemplo n.º 9
0
 /// <summary>
 /// 发送图片消息
 /// </summary>
 /// <returns>The pic.</returns>
 /// <param name="requestXML">Request XM.</param>
 /// <param name="pic">Pic.</param>
 public string SendPic(RequestVO requestXML)
 {
     string strResult = "";
     strResult = " <xml>"
         + "<ToUserName><![CDATA["+requestXML.fromUserName+"]]></ToUserName>"
         + "<FromUserName><![CDATA["+requestXML.toUserName+"]]></FromUserName>"
         + "<CreateTime>"+Jabinfo.Help.Date.Now+"</CreateTime> "
         + "<MsgType><![CDATA[image]]></MsgType>"
         + "<PicUrl><![CDATA["+requestXML.PicUrl+"]]></PicUrl>"
         + "<MediaId><![CDATA["+requestXML.MediaId+"]]></MediaId>"
         + "<MsgId>"+requestXML.msgId+"</MsgId>"
         + "</xml>";
     return strResult;
 }
Exemplo n.º 10
0
 /// <summary>
 /// 回复语音消息
 /// </summary>
 /// <returns>The voice.</returns>
 /// <param name="requestXML">Request XM.</param>
 public string SendVoice(RequestVO requestXML)
 {
     string strResult = string.Empty;
     strResult="<xml>"
         + "<ToUserName><![CDATA["+requestXML.fromUserName+"]]></ToUserName>"
         + "<FromUserName><![CDATA["+requestXML.toUserName+"]]></FromUserName>"
         + "<CreateTime>"+Jabinfo.Help.Date.Now+"</CreateTime>"
         + "<MsgType><![CDATA[voice]]></MsgType>"
         + "<Voice>"
         + "<MediaId><![CDATA["+requestXML.MediaId+"]]></MediaId>"
         + "</Voice>"
         + "</xml>";
     return strResult;
 }
Exemplo n.º 11
0
 /// <summary>
 /// 发送视频消息
 /// </summary>
 /// <returns>The vedio.</returns>
 /// <param name="requestXml">Request xml.</param>
 /// <param name="vedio">Vedio.</param>
 public string SendVedio(RequestVO requestXml)
 {
     string strResult = string.Empty;
     strResult="<xml>"
         + "<ToUserName><![CDATA["+requestXml.fromUserName+"]]></ToUserName>"
         + "<FromUserName><![CDATA["+requestXml.toUserName+"]]></FromUserName>"
         + "<CreateTime>"+Jabinfo.Help.Date.Now+"</CreateTime>"
         + "<MsgType><![CDATA[video]]></MsgType>"
         + "<Video>"
         + "<MediaId><![CDATA["+requestXml.MediaId+"]]></MediaId>"
         + "<Title><![CDATA["+requestXml.Title+"]]></Title>"
         + "<Description><![CDATA["+requestXml.Description+"]]></Description>"
         + "</Video> "
         + "<xml>";
     return strResult;
 }