示例#1
0
文件: Global.asax.cs 项目: MrNor/WxMp
        private void ExThread()
        {
            var list = db.Select(a => a.type == "手机号码"
                    && !(bool)a.isReMsg
                    && a.phoneNbr != null
                    && a.msgExtNbr != null
                    );
            foreach (var o in list)
            {
                var dt = ws.GetReceiveSMSList(o.phoneNbr, (int)o.msgExtNbr);
                if (dt.Rows.Count > 0)
                {

                    Entity.TemplateMsg obj = new Entity.TemplateMsg()
                    {
                        touser = o.code,
                        template_id = "_oLYvePWs8av6gP34TqAAo8KgUDr-y1uKrUs3ebRXv4",
                        topcolor = "#FFF",
                        url = string.Empty,
                        data = new Tuple<string, string, string>[]{
                            new Tuple<string, string, string>("first","手机用户[" + o.phoneNbr + "]已回复确认","#173177"),
                            new Tuple<string, string, string>("keyword1",o.gift,"#173177"),
                            new Tuple<string, string, string>("keyword2",o.nbr.ToString(),"#173177"),
                            new Tuple<string, string, string>("keyword3",DateTime.Now.ToString(),"#173177"),
                            new Tuple<string, string, string>("remark","用户确认成功,请发放赠品。","#173177")
                        }
                    };

                    if (wx.SendTemplateMsg(obj))
                    {
                        o.isReMsg = true;
                        db.Update(o);
                    }
                }
            }
            thread.Abort();
        }
示例#2
0
文件: WxMPUtility.cs 项目: MrNor/WxMp
        /// <summary>
        /// 发送模版消息
        /// </summary>
        /// <param name="obj">TemplateMsg</param>
        /// <returns></returns>
        public bool SendTemplateMsg(TemplateMsg obj)
        {
            var res = HttpUtil.PostUrl(string.Format("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}", this.GetAccessToken()), obj.ToJson());

            return JsonHepler.GetJsonValueByKey(res, "errcode") == "0";
        }