Example #1
0
 private static void ProduceImage(Dictionary<string, string> model)
 {
     SendText text = new SendText();
     text.ToUserName = model.ReadKey(PublicField.FromUserName);
     text.FromUserName = model.ReadKey(PublicField.ToUserName);
     text.CreateTime = int.Parse(model.ReadKey(PublicField.CreateTime));
     text.MsgType = "image";
 }
Example #2
0
 /// <summary>
 ///  生成图文消息
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="content">The content.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-24 09:57:37
 private static void ProduceNews(Dictionary<string, string> model, string content)
 {
     SendText text = new SendText();
     text.ToUserName = model.ReadKey(PublicField.FromUserName);
     text.FromUserName = model.ReadKey(PublicField.ToUserName);
     text.CreateTime = int.Parse(model.ReadKey(PublicField.CreateTime));
     text.MsgType = "text";
     text.Content = content;
 }
Example #3
0
 /// <summary>
 ///  生成图文消息
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="articles">The content.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-24 09:57:37
 private static void ProduceNews(Dictionary<string, string> model, List<ArticlesModel> articles)
 {
     SendPicTxt text = new SendPicTxt();
     text.ToUserName = model.ReadKey(PublicField.FromUserName);
     text.FromUserName = model.ReadKey(PublicField.ToUserName);
     text.CreateTime = int.Parse(model.ReadKey(PublicField.CreateTime));
     text.MsgType = "news";
     text.ArticleCount = articles.Count.ToString("D");
 }
Example #4
0
 /// <summary>
 ///  回复图片消息的函数
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="mediaId">服务器上图片的ID</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-24 10:23:10
 private static void ProduceImage(Dictionary<string, string> model,int mediaId)
 {
     SendImage image = new SendImage();
     image.ToUserName = model.ReadKey(PublicField.FromUserName);
     image.FromUserName = model.ReadKey(PublicField.ToUserName);
     image.CreateTime = int.Parse(model.ReadKey(PublicField.CreateTime));
     image.MsgType = "image";
     image.MediaId = mediaId;
     OperateXml.ResponseEnd(Templete.SendImg(image));
 }
Example #5
0
 /// <summary>
 ///  生成文本函数
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="content">The content.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-17 14:46:20
 private static void ProduceText(Dictionary<string, string> model, string content)
 {
     SendText text = new SendText();
     text.ToUserName = model.ReadKey(PublicField.FromUserName);
     text.FromUserName = model.ReadKey(PublicField.ToUserName);
     text.CreateTime = int.Parse(model.ReadKey(PublicField.CreateTime));
     text.MsgType = "text";
     text.Content = content;
     OperateXml.ResponseEnd(Templete.SendText(text));
 }
Example #6
0
 /// <summary>
 ///  回复图文消息的函数
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="articles">The content.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-24 09:57:37
 private static void ProduceNews(Dictionary<string, string> model, List<ArticlesModel> articles)
 {
     SendPicTxt news = new SendPicTxt();
     news.ToUserName = model.ReadKey(PublicField.FromUserName);
     news.FromUserName = model.ReadKey(PublicField.ToUserName);
     news.CreateTime = int.Parse(model.ReadKey(PublicField.CreateTime));
     news.MsgType = "news";
     news.ArticleCount = articles.Count.ToString("D");
     news.Articles = articles;
     OperateXml.ResponseEnd(Templete.SendNews(news));
 }
Example #7
0
 /// <summary>
 ///  回复扫码推事件且弹出“消息接收中”提示框消息
 /// </summary>
 /// <param name="model">The model.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-13 16:09:53
 public static void ReplyScanCodeWaitmsg(Dictionary<string, string> model)
 {
     string value = model.ReadKey("ScanCodeInfo");
     switch (value)
     {
         case "1":
             string content = string.Format("项目编号:{0};\n验收状态:{1};\n验收结果:{2};\n报表查看:<a href='{3}'>点击查看</a>", value.Substring(6), "完成", "通过", "http://www.sxajj.gov.cn/1.jpg");
             ProduceText(model, content);
             break;
         case "2":
             List<ArticlesModel> articles = new List<ArticlesModel>();
             ArticlesModel article = new ArticlesModel();
             article.Title = string.Format("一号项目\n项目编号:CX2501;验收状态:完成;验收结果:通过;");
             article.PicUrl = "http://www.sxajj.gov.cn/1.jpg";
             article.Url = "http://www.sxajj.gov.cn/1.jpg";
             articles.Add(article);
             article = new ArticlesModel();
             article.Title = string.Format("二号项目\n项目编号:CX2502;验收状态:完成;验收结果:通过;");
             article.PicUrl = "http://www.sxajj.gov.cn/1.jpg";
             article.Url = "http://www.sxajj.gov.cn/1.jpg";
             articles.Add(article);
             ProduceNews(model, articles);
             break;
     }
 }
Example #8
0
 /// <summary>
 ///  回复扫码推事件且弹出“消息接收中”提示框消息
 /// </summary>
 /// <param name="model">The model.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-13 16:09:53
 public static void ReplyScanCodeWaitmsg(Dictionary<string, string> model)
 {
     string value = model.ReadKey("ScanCodeInfo");
     switch (value)
     {
         case "1":
             string content = string.Format("项目编号:{0};\n验收状态:{1};\n验收结果:{2};\n报表查看:<a href='{3}'>点击查看</a>", value.Substring(6), "完成", "通过", "http://www.sxajj.gov.cn/1.jpg");
             ProduceText(model, content);
             break;
         case "2":
             List<ArticlesModel> articles = new List<ArticlesModel>();
             ArticlesModel article = new ArticlesModel();
             article.Title = string.Format("一号项目\n项目编号:CX2501;验收状态:完成;验收结果:通过;");
             article.PicUrl = "http://www.sxajj.gov.cn/1.jpg";
             article.Url = "http://www.sxajj.gov.cn/1.jpg";
             articles.Add(article);
             article = new ArticlesModel();
             article.Title = string.Format("二号项目\n项目编号:CX2502;验收状态:完成;验收结果:通过;");
             article.PicUrl = "http://www.sxajj.gov.cn/1.jpg";
             article.Url = "http://www.sxajj.gov.cn/1.jpg";
             articles.Add(article);
             ProduceNews(model, articles);
             break;
         case "3":
             //生成图片
             string mediaId = "IBH9UW7Ptrvbs9rQHAnu2zonxeq5Jh0uL6WwuYauIEWNF0UlyVMecLV3ploxRc5X";
             ProduceImage(model, mediaId);
             break;
     }
 }
Example #9
0
 public static void ReplayTemplete(Dictionary<string, string> model)
 {
     string url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=gITQNRtcDKDX6Lsv3k5WUy537xmBZNp8i3kpLZ0WWdFHKKW0y1Ps165q4_gVca-Z1YPtg8I2KWDmWxrFDoDDAJw4Qp4Aw2x69UQHAa0fVCw";
     StringBuilder data = new StringBuilder();
     data.Append("{\"touser\":\"");
     data.AppendFormat("{0}", model.ReadKey(PublicField.FromUserName));
     data.Append("\",\"template_id\":\"JUif5V5O1PEhmdl8IDsNNlS6xVp_yHNSq0PIh8F9iTk\",\"url\":\"http://weixin.qq.com/download\",\"topcolor\":\"#FF0000\",\"data\":{\"first\": {\"value\":\"您好,您已成功消费。\",\"color\":\"#173177\"},\"keynote1\":{\"value\":\"巧克力\",\"color\":\"#173177\"},\"keynote2\":{\"value\":\"39.8元\",\"color\":\"#173177\"},\"keynote3\":{\"value\":\"2014年9月16日\",\"color\":\"#173177\"},\"remark\":{\"value\":\"欢迎再次购买。\",\"color\":\"#173177\"}}}");
     PublicFun.RequestUpDownData(url, HttpMethod.Post, data.ToString());
 }
Example #10
0
 /// <summary>
 ///  使用官方模版借口
 /// </summary>
 /// <param name="model">The model.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-24 16:13:13
 public static void ReplayTemplete(Dictionary<string, string> model)
 {
     string url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=gITQNRtcDKDX6Lsv3k5WUy537xmBZNp8i3kpLZ0WWdFHKKW0y1Ps165q4_gVca-Z1YPtg8I2KWDmWxrFDoDDAJw4Qp4Aw2x69UQHAa0fVCw";
     StringBuilder json = new StringBuilder();
     json.Append("{\"touser\":\"");
     json.AppendFormat("{0}", model.ReadKey(PublicField.FromUserName));
     json.Append("\",\"template_id\":\"JUif5V5O1PEhmdl8IDsNNlS6xVp_yHNSq0PIh8F9iTk\",\"url\":\"http://www.sxajj.gov.cn/1.jpg\",\"topcolor\":\"#FF0000\",\"data\":{\"first\": {\"value\":\"您好,您有一条工单审核反馈\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"OA20140830123456\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"关于某文件的审批审阅\",\"color\":\"#173177\"},\"keyword3\":{\"value\":\"待审核\",\"color\":\"#173177\"},\"keyword4\":{\"value\":\"20140830093014\",\"color\":\"#173177\"},\"keyword5\":{\"value\":\"20140831093014\",\"color\":\"#173177\"},\"remark\":{\"value\":\"请点击查看审核结果。\",\"color\":\"#173177\"}}}");
     PublicFun.RequestUpDownData(url, HttpMethod.Post, json.ToString());
 }
Example #11
0
        /// <summary>
        ///  回复扫码推事件且弹出“消息接收中”提示框消息
        /// </summary>
        /// <param name="model">The model.</param>
        /// Author  : 俞立钢
        /// Company : 绍兴标点电子技术有限公司
        /// Created : 2014-10-13 16:09:53
        public static void ReplyScanCodeWaitmsg(Dictionary<string, string> model)
        {
            string value = model.ReadKey("ScanCodeInfo");
            /*string content = string.Format("项目编号:{0};\n验收状态:{1};\n验收结果:{2};\n报表查看:<a href='{3}'>点击查看</a>", value.Substring(6), "完成", "通过", "http://www.sxajj.gov.cn/1.jpg");
            ProduceText(model, content);*/
            for (int i = 0; i < 2; i++)
            {

            }
        }
Example #12
0
 public static void ReplayTemplete(Dictionary<string, string> model)
 {
     string url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=gITQNRtcDKDX6Lsv3k5WUy537xmBZNp8i3kpLZ0WWdFHKKW0y1Ps165q4_gVca-Z1YPtg8I2KWDmWxrFDoDDAJw4Qp4Aw2x69UQHAa0fVCw";
     StringBuilder data = new StringBuilder();
     data.Append("{\"touser\":\"");
     data.AppendFormat("{0}", model.ReadKey(PublicField.FromUserName));
     data.Append("\",\"template_id\":\"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY\",\"url\":\"http://weixin.qq.com/download\",\"topcolor\":\"#FF0000\",\"data\":{\"User\": {\"value\":\"黄先生\",\"color\":\"#173177\"},\"Date\":{\"value\":\"06月07日 19时24分\",\"color\":\"#173177\"},\"CardNumber\":{\"value\":\"0426\",\"color\":\"#173177\"},\"Type\":{\"value\":\"消费\",\"color\":\"#173177\"},\"Money\":{\"value\":\"人民币260.00元\",\"color\":\"#173177\"},\"DeadTime\":{\"value\":\"06月07日19时24分\",\"color\":\"#173177\"},\"Left\":{\"value\":\"6504.09\",\"color\":\"#173177\"}}}");
     string json = JsonConvert.SerializeObject(data.ToString());
     string result = PublicFun.RequestUpDownData(url, HttpMethod.Post, data.ToString());
 }
Example #13
0
 /// <summary>
 ///  回复扫码推事件且弹出“消息接收中”提示框消息
 /// </summary>
 /// <param name="model">The model.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-13 16:09:53
 public static void ReplyScanCodeWaitmsg(Dictionary<string, string> model)
 {
     string value = model.ReadKey("ScanCodeInfo");
     /*string content = string.Format("项目编号:{0};\n验收状态:{1};\n验收结果:{2};\n报表查看:<a href='{3}'>点击查看</a>", value.Substring(6), "完成", "通过", "http://www.sxajj.gov.cn/1.jpg");
     ProduceText(model, content);*/
     List<ArticlesModel> articles = new List<ArticlesModel>();
     for (int i = 0; i < 2; i++)
     {
         ArticlesModel article = new ArticlesModel();
         article.Title = "一号项目";
         article.Description = string.Format("项目编号:CX2505;\n验收状态:完成;\n验收结果:通过;\n");
     }
 }
Example #14
0
 /// <summary>
 ///  回复扫码推事件且弹出“消息接收中”提示框消息
 /// </summary>
 /// <param name="model">The model.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-13 16:09:53
 public static void ReplyScanCodeWaitmsg(Dictionary<string, string> model)
 {
     string value = model.ReadKey("ScanCodeInfo");
     /*string content = string.Format("项目编号:{0};\n验收状态:{1};\n验收结果:{2};\n报表查看:<a href='{3}'>点击查看</a>", value.Substring(6), "完成", "通过", "http://www.sxajj.gov.cn/1.jpg");
     ProduceText(model, content);*/
     List<ArticlesModel> articles = new List<ArticlesModel>();
     for (int i = 1; i < 3; i++)
     {
         ArticlesModel article = new ArticlesModel();
         article.Title = string.Format("{0}号项目", i == 1 ? "一" : "二");
         article.Description = string.Format("项目编号:{0};\n验收状态:完成;\n验收结果:通过;\n", i == 1 ? "CX2501" : "CX2502");
         article.PicUrl = "http://www.sxajj.gov.cn/1.jpg";
         articles.Add(article);
     }
     ProduceNews(model, articles);
 }
Example #15
0
 public static void ReplayTemplete(Dictionary<string, string> model)
 {
     string url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=gITQNRtcDKDX6Lsv3k5WUy537xmBZNp8i3kpLZ0WWdFHKKW0y1Ps165q4_gVca-Z1YPtg8I2KWDmWxrFDoDDAJw4Qp4Aw2x69UQHAa0fVCw";
     StringBuilder data = new StringBuilder();
     data.Append("{\"touser\":\"");
     data.AppendFormat("{0}", model.ReadKey(PublicField.FromUserName));
     data.Append("\",\"template_id\":\"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY\",\"url\":\"http://weixin.qq.com/download\",\"topcolor\":\"#FF0000\",\"data\":{\"first\": {\"value\":\"您好,您已成功消费。\",\"color\":\"#173177\"},\"keynote1\":{\"value\":\"巧克力\",\"color\":\"#173177\"},\"keynote2\":{\"value\":\"39.8元\",\"color\":\"#173177\"},\"keynote3\":{\"value\":\"2014年9月16日\",\"color\":\"#173177\"},\"remark\":{\"value\":\"欢迎再次购买。\",\"color\":\"#173177\"}}}");
     string json = data.ToString();
     string result = PublicFun.RequestUpDownData(url, HttpMethod.Post, data.ToString());
     string mediaId = "IBH9UW7Ptrvbs9rQHAnu2zonxeq5Jh0uL6WwuYauIEWNF0UlyVMecLV3ploxRc5X";
     ProduceImage(model, mediaId);
     /*string url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=gITQNRtcDKDX6Lsv3k5WUy537xmBZNp8i3kpLZ0WWdFHKKW0y1Ps165q4_gVca-Z1YPtg8I2KWDmWxrFDoDDAJw4Qp4Aw2x69UQHAa0fVCw";
     StringBuilder data = new StringBuilder();
     data.Append("{\"touser\":\"");
     data.AppendFormat("{0}", model.ReadKey(PublicField.FromUserName));
     data.Append("\",\"template_id\":\"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY\",\"url\":\"http://weixin.qq.com/download\",\"topcolor\":\"#FF0000\",\"data\":{\"User\": {\"value\":\"黄先生\",\"color\":\"#173177\"},\"Date\":{\"value\":\"06月07日 19时24分\",\"color\":\"#173177\"},\"CardNumber\":{\"value\":\"0426\",\"color\":\"#173177\"},\"Type\":{\"value\":\"消费\",\"color\":\"#173177\"},\"Money\":{\"value\":\"人民币260.00元\",\"color\":\"#173177\"},\"DeadTime\":{\"value\":\"06月07日19时24分\",\"color\":\"#173177\"},\"Left\":{\"value\":\"6504.09\",\"color\":\"#173177\"}}}");
     string json = JsonConvert.SerializeObject(data.ToString());
     string result = PublicFun.RequestUpDownData(url, HttpMethod.Post, data.ToString());*/
 }
        /// <summary>
        ///  处理信息
        /// </summary>
        /// <param name="model">Dictionary</param>
        /// Author  : 俞立钢
        /// Company : 绍兴标点电子技术有限公司
        /// Created : 2014-10-10 09:56:36
        private void DoMsg(Dictionary<string, string> model)
        {
            //通过MsgType判断是普通消息还是事件推送
            string msgType = model.ReadKey(PublicField.MsgType);
            switch (msgType)
            {

                #region 普通消息
                case "text": //文本消息
                    SendMsg.ReplyTexts(model);
                    break;
                case "image": //图片
                    break;
                case "voice": //声音
                    break;
                case "video": //视频
                    break;
                case "location": //地理位置
                    break;
                case "link": //链接
                    break;
                #endregion

                #region 事件推送
                case "event":
                    //事件类型
                    msgType = model.ReadKey(PublicField.Event);
                    switch (msgType)
                    {
                        case "subscribe":
                            /*if (model.ReadKey(PublicField.EventKey).StartsWith("qrscene_"))
                            {
                                //带参数的二维码扫描关注
                            }
                            else
                            {
                                //普通关注
                            }*/
                            SendMsg.ReplaySubscribeText(model);
                            break;
                        case "unsubscribe"://取消关注
                            break;
                        case "SCAN"://已经关注的用户扫描带参数的二维码
                            break;
                        case "LOCATION"://用户上报地理位置
                            break;
                        case "CLICK"://自定义菜单点击
                            break;
                        case "VIEW"://自定义菜单跳转事件
                            break;
                        case "scancode_push"://扫码推事件的事件推送
                            break;
                        case "scancode_waitmsg"://扫码推事件且弹出“消息接收中”提示框的事件推送
                            SendMsg.ReplyScanCodeWaitmsg(model);
                            break;
                        case "pic_sysphoto"://弹出系统拍照发图的事件推送
                            break;
                        case "pic_photo_or_album"://弹出拍照或者相册发图的事件推送
                            break;
                        case "pic_weixin"://弹出微信相册发图器的事件推送
                            break;
                        case "location_select"://弹出地理位置选择器的事件推送
                            break;
                    }
                    break;
                #endregion

            }
        }
Example #17
0
 /// <summary>
 ///  回复文本消息
 /// </summary>
 /// <param name="model">The model.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-10 12:58:35
 public static void ReplyTexts(Dictionary<string, string> model)
 {
     string content = string.Format("您输入的内容1为:{0}", model.ReadKey(PublicField.Content));
     ProduceText(model, content);
 }
Example #18
0
 /// <summary>
 ///  回复的视频消息的函数
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="mediaId">服务器上视频的ID</param>
 /// <param name="title">title</param>
 /// <param name="description">描述</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-24 10:25:01
 private static void ProduceVideo(Dictionary<string, string> model, int mediaId, string title, string description)
 {
     SendVideo video = new SendVideo();
     video.ToUserName = model.ReadKey(PublicField.FromUserName);
     video.FromUserName = model.ReadKey(PublicField.ToUserName);
     video.CreateTime = int.Parse(model.ReadKey(PublicField.CreateTime));
     video.MsgType = "video";
     video.MediaId = mediaId;
     video.Title = title;
     video.Description = description;
     OperateXml.ResponseEnd(Templete.SendVideo(video));
 }
Example #19
0
 /// <summary>
 ///  回复的音乐消息的函数
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="title">音乐标题</param>
 /// <param name="description">音乐描述</param>
 /// <param name="musicUrl">音乐链接</param>
 /// <param name="hqMusicUrl">高质量音乐链接,WIFI环境优先使用该链接播放音乐</param>
 /// <param name="thumbMediaId">缩略图的媒体id,通过上传多媒体文件,得到的id</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-24 10:25:01
 private static void ProduceMusic(Dictionary<string, string> model, string title, string description, string musicUrl, string hqMusicUrl, int thumbMediaId)
 {
     SendMusic music = new SendMusic();
     music.ToUserName = model.ReadKey(PublicField.FromUserName);
     music.FromUserName = model.ReadKey(PublicField.ToUserName);
     music.CreateTime = int.Parse(model.ReadKey(PublicField.CreateTime));
     music.MsgType = "music";
     music.Title = title;
     music.Description = description;
     music.MusicUrl = musicUrl;
     music.HqMusicUrl = hqMusicUrl;
     music.ThumbMediaId = thumbMediaId;
     OperateXml.ResponseEnd(Templete.SendMusic(music));
 }
Example #20
0
 /// <summary>
 ///  回复扫码推事件且弹出“消息接收中”提示框消息
 /// </summary>
 /// <param name="model">The model.</param>
 /// Author  : 俞立钢
 /// Company : 绍兴标点电子技术有限公司
 /// Created : 2014-10-13 16:09:53
 public static void ReplyScanCodeWaitmsg(Dictionary<string, string> model)
 {
     string value = model.ReadKey("ScanCodeInfo");
     string content = string.Format("项目编号:{0};\n验收状态:{1};\n验收结果:{2};\n", value.Substring(6), "完成", "通过", "http://www.sxajj.gov.cn/1.jpg");
     ProduceText(model, content);
 }