Exemplo n.º 1
0
        private void SetPushModel(string eventKey, string WeiXin, string OpenId)
        {
            try
            {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("中欧扫描--关注SetPushModel 进入 eventKey:{0},WeiXin:{1},OpenId:{2}", eventKey, WeiXin, OpenId)
                });

                #region 动态处理事件KEY值

                var menuDAO = new WMenuDAO(loggingSessionInfo);
                var ds      = menuDAO.GetMenusByKey(WeiXin, eventKey);

                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string typeId     = ds.Tables[0].Rows[0]["MaterialTypeId"].ToString(); //素材类型
                    string materialId = ds.Tables[0].Rows[0]["MaterialId"].ToString();     //素材ID
                    string modelId    = ds.Tables[0].Rows[0]["ModelId"].ToString();        //模型ID

                    BaseService.WriteLogWeixin("typeId:" + typeId);
                    BaseService.WriteLogWeixin("materialId:" + materialId);
                    BaseService.WriteLogWeixin("modelId:" + modelId);

                    switch (typeId)
                    {
                    //case MaterialType.TEXT:         //回复文字消息
                    //    ReplyText(materialId);
                    //    break;
                    case MaterialType.IMAGE_TEXT:       //回复图文消息
                        GetImageText(materialId, WeiXin, OpenId);
                        break;

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

                #endregion
            }
            catch (Exception ex)
            {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("中欧扫描--关注SetPushModel 进入 错误:{0}", ex.ToString())
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取微信用户登录信息
        /// </summary>
        /// <param name="weixinID"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static LoggingSessionInfo GetWeixinLoggingSession(string weixinID)
        {
            LoggingSessionInfo loggingSessionInfo = GetLoggingSession();

            var    server     = new WMenuDAO(loggingSessionInfo);
            string conn       = server.GetCustomerConn(weixinID);//通过微信id
            string customerId = server.GetCustomerID(weixinID);

            loggingSessionInfo.Conn = conn;
            loggingSessionInfo.CurrentLoggingManager.Connection_String = loggingSessionInfo.Conn;

            loggingSessionInfo.CurrentUser.customer_id = customerId;
            loggingSessionInfo.ClientID = customerId;
            loggingSessionInfo.CurrentLoggingManager.Customer_Id = customerId;

            return(loggingSessionInfo);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 处理点击事件 Jermyn20140512
        /// </summary>
        /// <param name="eventKey"></param>
        public virtual void HandlerClickJermyn(string eventKey)
        {
            //事件KEY值,与自定义菜单接口中KEY值对应
            BaseService.WriteLogWeixin("EventKey:" + eventKey);

            #region 动态处理事件KEY值

            var menuDAO = new WMenuDAO(requestParams.LoggingSessionInfo);
            var ds      = menuDAO.GetMenusByKeyJermyn(requestParams.WeixinId, eventKey);//根据事件KEY值去取对应的微信按钮

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                string typeId  = ds.Tables[0].Rows[0]["MaterialTypeId"].ToString(); //素材类型
                string Text    = ds.Tables[0].Rows[0]["Text"].ToString();           //素材ID
                string menuId  = ds.Tables[0].Rows[0]["Id"].ToString();             //模型ID
                string ImageId = ds.Tables[0].Rows[0]["ImageId"].ToString();

                BaseService.WriteLogWeixin("typeId:" + typeId);
                BaseService.WriteLogWeixin("menuId:" + menuId);
                BaseService.WriteLogWeixin("Text:" + Text);

                switch (typeId)
                {
                case MaterialType.TEXT:             //回复文字消息
                    //ReplyText(materialId);
                    ReplyTextJermyn(Text);
                    break;

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

                case MaterialType.IMAGE:             //回复文字消息
                    //ReplyText(materialId);
                    ReplyImage(ImageId);
                    break;

                default:
                    break;
                }
            }

            #endregion
        }
Exemplo n.º 4
0
        //处理点击事件
        public override void HandlerClick(string eventKey)
        {
            //事件KEY值,与自定义菜单接口中KEY值对应
            BaseService.WriteLogWeixin("EventKey:" + eventKey);

            #region 动态处理事件KEY值

            var menuDAO = new WMenuDAO(requestParams.LoggingSessionInfo);
            var ds      = menuDAO.GetMenusByKey(requestParams.WeixinId, eventKey);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                string typeId     = ds.Tables[0].Rows[0]["MaterialTypeId"].ToString(); //素材类型
                string materialId = ds.Tables[0].Rows[0]["MaterialId"].ToString();     //素材ID
                string modelId    = ds.Tables[0].Rows[0]["ModelId"].ToString();        //模型ID

                BaseService.WriteLogWeixin("typeId:" + typeId);
                BaseService.WriteLogWeixin("materialId:" + materialId);
                BaseService.WriteLogWeixin("modelId:" + modelId);

                switch (typeId)
                {
                case MaterialType.TEXT:             //回复文字消息
                    ReplyText(materialId);
                    break;

                case MaterialType.IMAGE_TEXT:       //回复图文消息
                    ReplyNews(materialId);
                    break;

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

                default:
                    break;
                }
            }

            #endregion
        }
Exemplo n.º 5
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public WMenuBLL(LoggingSessionInfo pUserInfo)
 {
     this.CurrentUserInfo = pUserInfo;
     this._currentDAO     = new WMenuDAO(pUserInfo);
 }
Exemplo n.º 6
0
        public static void WXLocation(HttpContext httpContext, CommonBLL commonService, RequestParams requestParams, string locationX, string locationY)
        {
            WMenuDAO wMenuDAO = new WMenuDAO(requestParams.LoggingSessionInfo);
            var      custId   = wMenuDAO.GetCustomerIdByWx(requestParams.WeixinId);

            if (requestParams.LoggingSessionInfo.CurrentUser == null)
            {
                requestParams.LoggingSessionInfo.CurrentUser = new Entity.User.UserInfo();
            }
            requestParams.LoggingSessionInfo.CurrentUser.customer_id = custId;

            BaseService.WriteLogWeixin("customerId:---------------" + custId);
            BaseService.WriteLogWeixin("openID:---------------" + requestParams.OpenId);
            BaseService.WriteLogWeixin("weixinID:---------------" + requestParams.WeixinId);

            string HandlerLocation_xyds = ConfigurationManager.AppSettings["HandlerLocation_xyds"];

            BaseService.WriteLogWeixin("HandlerLocation_xyds:---------------" + HandlerLocation_xyds);
            if (HandlerLocation_xyds != null && HandlerLocation_xyds.Length > 0 && HandlerLocation_xyds.Contains(requestParams.WeixinId))
            {
                BaseService.WriteLogWeixin("xyds:---------------");
                VipBLL server  = new VipBLL(requestParams.LoggingSessionInfo);
                var    vipInfo = server.SearchVipInfoLocation(new VipSearchEntity()
                {
                    RoleCode  = "CampusAmbassadors",
                    Longitude = locationY,
                    Latitude  = locationX,
                    OrderBy   = " a.Distance asc ",
                    Page      = 1,
                    PageSize  = 1,
                });

                if (vipInfo != null && vipInfo.vipInfoList != null && vipInfo.vipInfoList.Count > 0)
                {
                    var vip = vipInfo.vipInfoList[0];
                    if (vip != null)
                    {
                        var content = "";
                        content += "目前离你最近的校园产品专家是{0},电话:{1},{2},距离{3}米。如有任何疑问也可直接回复消息与我们联系,我们将尽快答复。";
                        content  = string.Format(
                            content,
                            vip.VipName,
                            vip.Phone,
                            vip.DeliveryAddress,
                            vip.Distance * 1000
                            );

                        BaseService.WriteLogWeixin("发送微信消息:---------------");
                        commonService.ResponseTextMessage(requestParams.WeixinId, requestParams.OpenId, content, httpContext, requestParams);
                        BaseService.WriteLogWeixin("发送微信消息完成:---------------");

                        MarketSendLogBLL marketSendLogBLL = new BLL.MarketSendLogBLL(requestParams.LoggingSessionInfo);
                        var logObj = new MarketSendLogEntity()
                        {
                            LogId           = Common.Utils.NewGuid(),
                            VipId           = vip.VIPID,
                            MarketEventId   = "华硕校园大使推介活动",
                            TemplateContent = content,
                            SendTypeId      = "1",
                            WeiXinUserId    = vip.WeiXinUserId,
                            Phone           = vip.Phone,
                            IsSuccess       = 0
                        };
                        marketSendLogBLL.Create(logObj);

                        VipVipMappingBLL vipVipMappingBLL = new VipVipMappingBLL(requestParams.LoggingSessionInfo);
                        var vipMapObj = new VipVipMappingEntity()
                        {
                            MappingId = Guid.NewGuid(),
                            VipIdSrc  = vip.VIPID,
                            VipIdDst  = requestParams.OpenId
                        };
                        vipVipMappingBLL.Create(vipMapObj);

                        logObj.IsSuccess = 1;
                        marketSendLogBLL.Update(logObj, false);
                    }
                }
            }
            else
            {
                string strError             = "";
                StoreBrandMappingBLL server = new StoreBrandMappingBLL(requestParams.LoggingSessionInfo);
                var storeInfo = server.GetStoreListByItem(null
                                                          , 1
                                                          , 10
                                                          , locationY
                                                          , locationX
                                                          , out strError);

                if (storeInfo != null && storeInfo.StoreBrandList != null && storeInfo.StoreBrandList.Count > 0)
                {
                    var newsList     = new List <WMaterialTextEntity>();
                    var original_url = ConfigurationManager.AppSettings["website_WWW"].ToString();
                    if (!original_url.EndsWith("/"))
                    {
                        original_url += "/";
                    }
                    foreach (var store in storeInfo.StoreBrandList)
                    {
                        var url = original_url + "HtmlApps/Auth.html?pageName=Map&customerId=" + requestParams.LoggingSessionInfo.CurrentUser.customer_id;
                        url += "&lng=" + store.Longitude + "&lat=" + store.Latitude;
                        url += "&storeId=" + store.StoreId;
                        url += "&addr=" + HttpUtility.UrlEncode(store.Address);
                        url += "&store=" + HttpUtility.UrlEncode(store.StoreName);

                        #region 分享业务 链接后面加上openId和userId

                        //if (url.IndexOf("ParAll=") != -1)
                        //{
                        //    var vipId = string.Empty;

                        //    VipBLL vipService = new VipBLL(requestParams.LoggingSessionInfo);
                        //    var vipEntity = vipService.QueryByEntity(new VipEntity { WeiXinUserId = requestParams.OpenId, WeiXin = requestParams.WeixinId }, null);
                        //    if (vipEntity != null && vipEntity.Length > 0)
                        //    {
                        //        vipId = vipEntity.FirstOrDefault().VIPID;
                        //    }

                        //    url += "&openId=" + requestParams.OpenId + "&userId=" + vipId;
                        //}

                        #endregion

                        newsList.Add(new WMaterialTextEntity()
                        {
                            Title         = store.StoreName + "(" + store.Distance.ToString("f1") + "公里)", // Title
                            Text          = store.StoreName + "(" + store.Distance.ToString("f1") + "公里)", // Author
                            CoverImageUrl = store.ImageUrl,                                                // CoverImageUrl
                            OriginalUrl   = url
                        });
                    }

                    commonService.ResponseNewsMessage(requestParams.WeixinId, requestParams.OpenId, newsList, httpContext, requestParams);
                }
            }
        }