示例#1
0
        //处理扫描带参数二维码事件
        public virtual void HandlerScan(string eventKey)
        {
            var application = new WApplicationInterfaceDAO(requestParams.LoggingSessionInfo);
            var appEntitys  = application.QueryByEntity(new WApplicationInterfaceEntity()
            {
                WeiXinID = requestParams.WeixinId
            }, null);

            if (appEntitys != null && appEntitys.Length > 0)
            {
                var entity = appEntitys.FirstOrDefault();

                BaseService.WriteLogWeixin("AppID:  " + entity.AppID);
                BaseService.WriteLogWeixin("AppSecret:  " + entity.AppSecret);
                BaseService.WriteLogWeixin("qrcodeId:  " + eventKey);

                //保存用户信息
                // /// <param name="isShow">1: 关注  0: 取消关注</param>
                //这个里面处理临时二维码的信息的代码(建立员工与会员的上下级关系)**
                commonService.SaveUserInfo(requestParams.OpenId, requestParams.WeixinId, "1", entity.AppID, entity.AppSecret, eventKey, requestParams.LoggingSessionInfo);

                #region 微信扫描二维码 回复消息 update by wzq 20140731
                var eventsBll = new LEventsBLL(requestParams.LoggingSessionInfo);

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = "二维码信息:" + eventKey
                });

                string nodeMsg = string.Empty;
                foreach (System.Xml.XmlNode item in requestParams.XmlNode.ChildNodes)
                {
                    nodeMsg += " |  " + item.Name + "-" + item.Value;
                }

                //加log记录信息看下 2014-11-24 15:57:30
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = "二维码全部信息:"
                              + "~" + requestParams.OpenId
                              + "~" + requestParams.WeixinId
                              + "~" + requestParams.MsgType
                              + "~" + requestParams.XmlNode.ToString()
                              + nodeMsg
                });

                #region 注释备注:扫码时始终会调用保存用户信息接口,这里已经推送了消息
                //BaseService.WriteLogWeixin("开始推送消息Wzq");
                //处理扫描静态二维码的事件(包含处理上下级关系和推送图文信息)
                int sendMessageCount = 0;
                eventsBll.SendQrCodeWxMessage(requestParams.LoggingSessionInfo, requestParams.LoggingSessionInfo.CurrentLoggingManager.Customer_Id, requestParams.WeixinId, eventKey,
                                              requestParams.OpenId, this.httpContext, requestParams, out sendMessageCount);

                //BaseService.WriteLogWeixin("推送消息成功Wzq");
                #endregion

                #endregion
            }
        }
示例#2
0
        //用户关注微信号
        public override void UserSubscribe()
        {
            var eventsBll = new LEventsBLL(requestParams.LoggingSessionInfo);
            //设置关注信息
            var modelDAO = new WModelDAO(requestParams.LoggingSessionInfo);
            var ds       = new DataSet();// /// <param name="KeyworkType">1=关键字回复 2=关注回复 3=自动回复</param>

            //优先处理二维码
            var qrcodeId = string.Empty;
            var eventKey = requestParams.XmlNode.SelectSingleNode("//EventKey");

            var application = new WApplicationInterfaceDAO(requestParams.LoggingSessionInfo);
            var appEntitys  = application.QueryByEntity(new WApplicationInterfaceEntity()
            {
                WeiXinID = requestParams.WeixinId
            }, null);

            if (eventKey != null && eventKey.InnerText.Contains("qrscene_"))//如果是二维码的就之返回二维码的
            {
                qrcodeId = eventKey.InnerText.Substring(8);
            }
            if (appEntitys != null && appEntitys.Length > 0)
            {
                var entity = appEntitys.FirstOrDefault();
                BaseService.WriteLogWeixin("AppID:  " + entity.AppID);
                BaseService.WriteLogWeixin("AppSecret:  " + entity.AppSecret);
                //扫描带参数二维码事件

                /**
                 * BaseService.WriteLogWeixin("二维码 eventKey:  " + eventKey.InnerText);
                 * if (!string.IsNullOrEmpty(eventKey.InnerText))//这里如果是二维码扫锚,就找出了二维码的code,可以在这里推送该二维码对应的图文素材******
                 * {
                 *  qrcodeId = eventKey.InnerText.Substring(8);
                 *  //这个地方传得是eventKey.ToString(),,而不是上面做的qrcodeId = eventKey.InnerText.Substring(8),所以不会找到对应的二维码的真正的key,也就不会推送二维码的key对应的图文素材信息
                 *  eventsBll.SendQrCodeWxMessage(requestParams.LoggingSessionInfo, requestParams.LoggingSessionInfo.CurrentLoggingManager.Customer_Id, requestParams.WeixinId, eventKey.ToString(),
                 *  requestParams.OpenId, this.httpContext, requestParams);
                 * }
                 **/
                //BaseService.WriteLogWeixin("二维码 qrcodeId:  " + qrcodeId);
                ////保存用户信息///// <param name="isShow">1: 关注  0: 取消关注</param>
                //这个里面处理临时二维码的信息的代码(建立员工与会员的上下级关系)**
                commonService.SaveUserInfo(requestParams.OpenId, requestParams.WeixinId, "1", entity.AppID, entity.AppSecret, qrcodeId, requestParams.LoggingSessionInfo);
            }

            int sendMessageCount = 0;

            if (eventKey != null && eventKey.InnerText.Contains("qrscene_"))//如果是二维码的就之返回二维码的
            {
                qrcodeId = eventKey.InnerText.Substring(8);
                //处理扫描静态二维码的事件(包含处理上下级关系和推送图文信息)
                eventsBll.SendQrCodeWxMessage(requestParams.LoggingSessionInfo, requestParams.LoggingSessionInfo.CurrentLoggingManager.Customer_Id, requestParams.WeixinId, qrcodeId,
                                              requestParams.OpenId, this.httpContext, requestParams, out sendMessageCount); //保存用户信息时,有推送消息
                //eventsBll.QrCodeHandlerText(qrcodeId, requestParams.LoggingSessionInfo,
                // requestParams.WeixinId, 4, requestParams.OpenId, httpContext, requestParams);
                //ds = modelDAO.GetMaterialByWeixinIdJermyn(requestParams.WeixinId, 4);
            }

            if (sendMessageCount == 0) //这种情况,就是没有eventKey,或者这个eventkey没有设置对应的关键字回复
            {
                #region  处理关注事件的图文信息
                ds = modelDAO.GetMaterialByWeixinIdJermyn(requestParams.WeixinId, 2);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string typeId  = ds.Tables[0].Rows[0]["ReplyType"].ToString(); //素材类型 1=文字2=图片3=图文4=语音5=视频6=其他
                    string ReplyId = ds.Tables[0].Rows[0]["ReplyId"].ToString();   //素材ID
                    string Text    = ds.Tables[0].Rows[0]["text"].ToString();      //内容

                    BaseService.WriteLogWeixin("自动回复: typeId:" + typeId);
                    BaseService.WriteLogWeixin("自动回复:ReplyId:" + ReplyId);
                    switch (typeId)
                    {
                    case MaterialType.TEXT:             //回复文字消息
                        //ReplyText(materialId);
                        ReplyTextJermyn(Text);
                        break;

                    case MaterialType.IMAGE_TEXT:       //回复图文消息
                        //ReplyNews(materialId);
                        ReplyNewsJermyn(ReplyId, 2, 1);
                        break;

                    case MaterialType.OTHER:        //后台处理
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    UserSubscribeOld();//老版本的微信关注自动回复 Jermyn20140512
                }
                #endregion
            }


            /**
             * var application = new WApplicationInterfaceDAO(requestParams.LoggingSessionInfo);
             * var appEntitys = application.QueryByEntity(new WApplicationInterfaceEntity() { WeiXinID = requestParams.WeixinId }, null);
             * if (appEntitys != null && appEntitys.Length > 0)
             * {
             *  var entity = appEntitys.FirstOrDefault();
             *
             *  BaseService.WriteLogWeixin("AppID:  " + entity.AppID);
             *  BaseService.WriteLogWeixin("AppSecret:  " + entity.AppSecret);
             *
             *  //扫描带参数二维码事件
             *
             *  BaseService.WriteLogWeixin("二维码 eventKey:  " + eventKey.InnerText);
             *
             *
             *  if (!string.IsNullOrEmpty(eventKey.InnerText))//这里如果是二维码扫锚,就找出了二维码的code,可以在这里推送该二维码对应的图文素材******
             *  {
             *      qrcodeId = eventKey.InnerText.Substring(8);
             *      //这个地方传得是eventKey.ToString(),,而不是上面做的qrcodeId = eventKey.InnerText.Substring(8),所以不会找到对应的二维码的真正的key,也就不会推送二维码的key对应的图文素材信息
             *      eventsBll.SendQrCodeWxMessage(requestParams.LoggingSessionInfo, requestParams.LoggingSessionInfo.CurrentLoggingManager.Customer_Id, requestParams.WeixinId, eventKey.ToString(),
             *      requestParams.OpenId, this.httpContext, requestParams);
             *  }
             *
             *
             *  //BaseService.WriteLogWeixin("二维码 qrcodeId:  " + qrcodeId);
             *
             *  ////保存用户信息///// <param name="isShow">1: 关注  0: 取消关注</param>
             *   commonService.SaveUserInfo(requestParams.OpenId, requestParams.WeixinId, "1", entity.AppID, entity.AppSecret, qrcodeId, requestParams.LoggingSessionInfo);
             * }
             **/
        }