Beispiel #1
0
        /// <summary>
        /// 发送微信
        /// </summary>
        /// <param name="push">系统消息推送</param>
        public static void SendWeixinMessage(SystemPushMongo push)
        {
            try
            {
                var title      = push.Title;
                var content    = push.Content;
                var wxCustomer = CusServer.GetModel(push.CustomerId);
                if (null == wxCustomer /*|| string.IsNullOrEmpty(wxCustomer.OpenId)*/)
                {
                    throw new Exception("CustomerId=" + push.CustomerId + "的客户不存在");
                }
                var openId = wxCustomer.OpenId;

                var sysConfig   = SysConfigService.GetModel(Config.WeiXinKey);
                var accessToken = sysConfig.Value;

                // 获取消息模板
                var datainfo = MessageTemplete(openId, title, content);

                GetPage("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token= " + accessToken, datainfo, "UTF-8");
            }
            catch (Exception ex)
            {
                //LogHelper.Error("红包-发生改变微信通知出现异常", exception);
                throw ex;
            }
        }