예제 #1
0
        /// <summary>
        /// 获取微信统一凭证接口
        /// </summary>
        /// <returns></returns>
        public string GetAccessToken(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <EmptyRequestParameter> >();
            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);
            var appService         = new WApplicationInterfaceBLL(loggingSessionInfo);


            var appEntity = appService.QueryByEntity(new WApplicationInterfaceEntity()
            {
                CustomerId = rp.CustomerID
            }, null)[0];

            var tempAccessToke = new CommonBLL().GetAccessTokenByCache(appEntity.AppID, appEntity.AppSecret, loggingSessionInfo);

            //重新取一次
            appEntity = appService.QueryByEntity(new WApplicationInterfaceEntity()
            {
                CustomerId = rp.CustomerID
            }, null)[0];

            WxAccessToken accessToken = new WxAccessToken()
            {
                access_token   = tempAccessToke.access_token,//appEntity.RequestToken,
                expires_in     = tempAccessToke.expires_in,
                ExpirationTime = appEntity.ExpirationTime.ToString()
            };

            return(new SuccessResponse <IAPIResponseData>(accessToken).ToJSON());
        }
예제 #2
0
        public void GetKeyByApp()
        {
            WApplicationInterfaceBLL    server = new WApplicationInterfaceBLL(loggingSessionInfo);
            WApplicationInterfaceEntity info   = server.GetByID(applicationId);

            if (info == null)
            {
                Response.Write("不存在对应的微信标识");
            }
            else
            {
                strAppId     = info.AppID;
                strAppSecret = info.AppSecret;
                if (info.AuthUrl == null || info.AuthUrl.Equals(""))
                {
                }
                else
                {
                    //qianzhi 2014-03-17
                    if (!info.AuthUrl.EndsWith("/"))
                    {
                        info.AuthUrl = info.AuthUrl.Insert(info.AuthUrl.Length, "/");
                    }

                    strRedirectUri = info.AuthUrl + "WXOAuth/AuthCodeReques.aspx";
                }
            }
        }
예제 #3
0
        //新增方法可推送图文、图片信息
        public void PushMessage(string memberID, string messageContent, SendMessageEntity wxmessageEntty)
        {
            WApplicationInterfaceEntity[] wApplicationInterfaceEntities = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity {
                CustomerId = loggingSessionInfo.ClientID
            }, null);
            if (wApplicationInterfaceEntities.Length > 0)
            {
                VipEntity vipEntity = new VipBLL(loggingSessionInfo).GetByID(memberID);


                if (string.IsNullOrEmpty(vipEntity.WeiXinUserId))
                {
                    throw new Exception("VipID:" + vipEntity.VIPID + "没有关注公众号");
                }

                if (new CSPublicInterface(loggingSessionInfo).IsWeixinCSMessageActiveUser(memberID))//目前还没做是否超过48小时客服时间限制
                {
                    CommonBLL commonBll = new CommonBLL();
                    wxmessageEntty.touser = vipEntity.WeiXinUserId;
                    commonBll.SendMessage(wxmessageEntty, wApplicationInterfaceEntities[0].AppID,
                                          wApplicationInterfaceEntities[0].AppSecret, loggingSessionInfo);
                }
                else
                {
                    throw new Exception("VipID:" + vipEntity.VIPID + "已经超过48小时有效期");
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 获取jsapi_ticket
        /// </summary>
        /// <returns></returns>
        public string getJsApiConfig(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <WeiXinConfigRq> >();

            if (string.IsNullOrEmpty(rp.OpenID))//OpenID为空立刻返回空数据,让前端跳转高级auth认证
            {
                return(new SuccessResponse <IAPIResponseData>(new XeiXinJsApiConfig()).ToJSON());
            }
            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
            var appService         = new WApplicationInterfaceBLL(loggingSessionInfo);
            var wxUserInfoBLL      = new WXUserInfoBLL(loggingSessionInfo);
            var vipService         = new VipBLL(loggingSessionInfo);
            var appEntity          = new WApplicationInterfaceEntity();

            var vipEntitys = vipService.QueryByEntity(new VipEntity {
                WeiXinUserId = rp.OpenID, ClientID = loggingSessionInfo.ClientID
            }, null);

            if (vipEntitys != null && vipEntitys.Length > 0)
            {
                appEntity = appService.QueryByEntity(new WApplicationInterfaceEntity()
                {
                    WeiXinID = vipEntitys[0].WeiXin, CustomerId = rp.CustomerID
                }, null).FirstOrDefault();
            }
            else
            {
                //优先从支持多号运营的表中取
                var wxUserInfo = wxUserInfoBLL.QueryByEntity(new WXUserInfoEntity()
                {
                    CustomerID = loggingSessionInfo.ClientID, WeiXinUserID = rp.OpenID
                }, null).FirstOrDefault();
                if (wxUserInfo != null)
                {
                    appEntity = appService.QueryByEntity(new WApplicationInterfaceEntity()
                    {
                        WeiXinID = wxUserInfo.WeiXin, CustomerId = rp.CustomerID
                    }, null).FirstOrDefault();
                }
            }
            //返回空数据,让前端跳转高级auth认证
            if (string.IsNullOrEmpty(appEntity.AppID))
            {
                return(new SuccessResponse <IAPIResponseData>(new XeiXinJsApiConfig()).ToJSON());
            }
            string            timestamp = ((long)((DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds)).ToString();
            string            nonceStr  = Guid.NewGuid().ToString("N").Substring(0, 16);
            XeiXinJsApiConfig config    = new XeiXinJsApiConfig()
            {
                debug     = rp.Parameters.debug,
                appId     = appEntity.AppID,
                timestamp = timestamp,
                nonceStr  = nonceStr,
                signature = this.getJsApiSignature(this.getJsApiTicket(rp.CustomerID, appEntity.AppID, appEntity.AppSecret), nonceStr, timestamp, rp.Parameters.url),
                jsApiList = new List <string>()
            };

            return(new SuccessResponse <IAPIResponseData>(config).ToJSON());
        }
예제 #5
0
        protected override GetModuleListRD ProcessRequest(DTO.Base.APIRequest <EmptyRequestParameter> pRequest)
        {
            var rd = new GetModuleListRD();
            var loggingSessionInfo              = new SessionManager().CurrentUserLoginInfo;
            WApplicationInterfaceBLL bllApp     = new WApplicationInterfaceBLL(loggingSessionInfo);
            T_UserGuideModulesBLL    bll        = new T_UserGuideModulesBLL(loggingSessionInfo);
            List <ModuleInfo>        moduleList = new List <ModuleInfo>();
            //是否绑定微信公众号
            var entityApp = bllApp.QueryByEntity(new WApplicationInterfaceEntity()
            {
                CustomerId = loggingSessionInfo.ClientID, IsDelete = 0
            }, null);

            if (entityApp.Count() > 0)
            {
                rd.IsBindWeChat = 1;
            }
            ///新手引导大模块
            var entity = bll.QueryByEntity(new T_UserGuideModulesEntity()
            {
                ModuleStep = 0, IsDelete = 0
            }, null);
            IEnumerable <ModuleInfo> ModuleList = from e in entity
                                                  select new ModuleInfo()
            {
                ModuleName         = e.ModuleName,
                ModuleCode         = e.ModuleCode,
                UserGuideModulesId = e.UserGuideModulesId.ToString(),
                ParentModule       = e.ParentModule.ToString(),
                Url      = e.Url,
                VideoUrl = e.VideoUrl,
                //ImageUrl1=e.ImageUrl1,
                //ImageUrl2=e.ImageUrl2,
                //ImageUrl3=e.ImageUrl3
            };
            ///每个用户最后一次的记录,已经模块是否完成
            T_UserGuideAccessLogBLL bllUserGuideLog = new T_UserGuideAccessLogBLL(loggingSessionInfo);
            var LogList = bllUserGuideLog.QueryByEntity(new Entity.T_UserGuideAccessLogEntity()
            {
                CustomerId = loggingSessionInfo.ClientID, UserId = loggingSessionInfo.CurrentLoggingManager.User_Id, IsDelete = 0
            }, null);

            foreach (var m in ModuleList)
            {
                foreach (var log in LogList)
                {
                    if (m.UserGuideModulesId == log.UserGuideModulesId.ToString())
                    {
                        m.LastStep       = (int)log.LastAccessStep;
                        m.LastUrl        = log.Url;
                        m.FinishedStatus = (int)log.FinishedStatus;
                    }
                }
                moduleList.Add(m);
            }
            rd.ModuleInfoList = moduleList;

            return(rd);
        }
예제 #6
0
        public string CretaeWxCode()
        {
            var responseData = new ResponseData();

            try
            {
                //微信 公共平台
                var wapentity = new WApplicationInterfaceBLL(this.CurrentUserInfo).QueryByEntity(new WApplicationInterfaceEntity
                {
                    CustomerId = this.CurrentUserInfo.ClientID,
                    IsDelete   = 0
                }, null).FirstOrDefault();

                //获取当前二维码 最大值
                var MaxWQRCod = new WQRCodeManagerBLL(this.CurrentUserInfo).GetMaxWQRCod() + 1;

                if (wapentity == null || wapentity.ApplicationId == null)
                {
                    responseData.success = false;
                    responseData.msg     = "无设置微信公众平台!";
                    return(responseData.ToJSON());
                }

                string imageUrl = string.Empty;

                #region 生成二维码
                JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL();
                imageUrl = commonServer.GetQrcodeUrl(wapentity.AppID.ToString().Trim()
                                                     , wapentity.AppSecret.Trim()
                                                     , "1", MaxWQRCod
                                                     , this.CurrentUserInfo);

                if (string.IsNullOrEmpty(imageUrl))
                {
                    responseData.success = false;
                    responseData.msg     = "二维码生成失败!";
                }
                else
                {
                    string host = ConfigurationManager.AppSettings["DownloadImageUrl"];
                    CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                    imageUrl = downloadServer.DownloadFile(imageUrl, host);
                }
                #endregion
                responseData.success = true;
                responseData.msg     = "二维码生成成功!";
                var rp = new ReposeData()
                {
                    imageUrl  = imageUrl,
                    MaxWQRCod = MaxWQRCod
                };
                responseData.data = rp;
                return(responseData.ToJSON());
            }
            catch (Exception ex)
            {
                throw new APIException(ex.Message);
            }
        }
예제 #7
0
        /// <summary>
        /// 取消授权
        /// </summary>
        /// <param name="appid"></param>
        /// <param name="clientid"></param>
        /// <returns></returns>
        public static bool UnauthWechatApp(string appid)
        {
            var clientId           = "eb17cc2569c74ab7888b1f403972d37d";//测试用
            var loggingSessionInfo = Default.GetBSLoggingSession(clientId, "open");
            var waiBll             = new WApplicationInterfaceBLL(loggingSessionInfo);
            var wmenuBll           = new WMenuBLL(loggingSessionInfo);
            var userInfo           = loggingSessionInfo;

            userInfo.CurrentLoggingManager.Connection_String = WebConfigurationManager.AppSettings["APConn"];
            var customerWxMappingBll = new TCustomerWeiXinMappingBLL(userInfo);
            var customerId           = customerWxMappingBll.GetCustomerIdByAppId(appid);
            var waiEntitys           = new WApplicationInterfaceEntity[] { };
            var waiEntity            = new WApplicationInterfaceEntity();
            var component_Appid      = WebConfigurationManager.AppSettings["Component_Appid"];

            waiEntitys = waiBll.QueryByEntity(new WApplicationInterfaceEntity {
                AppID = appid, OpenOAuthAppid = component_Appid, CustomerId = customerId, IsDelete = 0
            }, null);
            if (waiEntitys != null && waiEntitys.Length > 0)
            {
                waiEntity = waiEntitys.FirstOrDefault();
                //waiEntity.OpenOAuthAppid = null;//置空
                //waiBll.Update(waiEntity);
                waiBll.Delete(waiEntity);



                //查询参数
                List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                };
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "WeiXinID", Value = waiEntity.WeiXinID
                });
                var tempList = wmenuBll.PagedQuery(complexCondition.ToArray(), null, 10, 1);
                if (tempList.Entities.Length > 0)
                {
                    foreach (var item in tempList.Entities)
                    {
                        wmenuBll.Delete(item);
                    }
                }

                //var wmenuEntitys = wmenuBll.QueryByEntity(new WMenuEntity { WeiXinID = waiEntity.WeiXinID }, null);
                //if (wmenuEntitys != null && wmenuEntitys.Length > 0)
                //{
                //    foreach (var item in wmenuEntitys)
                //    {
                //        wmenuBll.Delete(item);
                //    }
                //}
            }
            return(true);
        }
예제 #8
0
        /// <summary>
        /// 获取code
        /// </summary>
        private void GetOAuthCode()
        {
            try
            {
                //判断客户ID是否传递
                if (!string.IsNullOrEmpty(Request["customerId"]))
                {
                    customerId = Request["customerId"];
                }
                if (!string.IsNullOrEmpty(Request["applicationId"]))
                {
                    applicationId = Request["applicationId"];
                }
                else
                {
                    loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");
                    var list = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity {
                        CustomerId = customerId
                    }, null).ToList();

                    if (list != null && list.Count > 0)
                    {
                        applicationId = list.FirstOrDefault().ApplicationId;
                    }
                    else
                    {
                        Response.Write("<br>");
                        Response.Write("没有获取微信标识,请联系管理员尽快处理.");
                        Response.End();
                    }
                }
                strState = customerId + "," + amount;
                strState = HttpUtility.UrlEncode(strState, Encoding.UTF8);
                byte[] buff = Encoding.UTF8.GetBytes(strState);
                strState = Convert.ToBase64String(buff);
                //strState = CommonCompress.StringCompress(strState);
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("strState1: {0}", strState)
                });
                string url = "http://open.weixin.qq.com/connect/oauth2/authorize?appid=" + strAppId + "&redirect_uri=" + HttpUtility.UrlEncode(strRedirectUri) + "&response_type=code&scope=snsapi_base&state=" + strState + "#wechat_redirect";
                //Response.Write(url);
                Response.Redirect(url);
            }
            catch (Exception ex)
            {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("GetOAuthCode 出错: {0}", ex.ToString())
                });
            }
        }
예제 #9
0
        public void GetKeyByApp()
        {
            WApplicationInterfaceBLL    server = new WApplicationInterfaceBLL(loggingSessionInfo);
            WApplicationInterfaceEntity info   = server.GetByID(applicationId);

            if (info == null)
            {
                Response.Write("不存在对应的微信标识");
            }
            else
            {
                strAppId     = info.AppID;
                strAppSecret = info.AppSecret;
            }
        }
예제 #10
0
        public void ReplyImage(string ImageId)
        {
            var wMaterialImageBll    = new WMaterialImageBLL(requestParams.LoggingSessionInfo);
            var wMaterialImageEntity = wMaterialImageBll.GetByID(ImageId);

            var commonService = new CommonBLL();
            var appService    = new WApplicationInterfaceBLL(requestParams.LoggingSessionInfo);
            var appEntity     = appService.QueryByEntity(new WApplicationInterfaceEntity()
            {
                WeiXinID = requestParams.WeixinId
            }, null).FirstOrDefault();
            var accessToken = commonService.GetAccessTokenByCache(appEntity.AppID, appEntity.AppSecret, requestParams.LoggingSessionInfo);

            UploadMediaEntity media = commonService.UploadMediaFile(accessToken.access_token, wMaterialImageEntity.ImageUrl, MediaType.Image);

            commonService.ResponseImageMessage(requestParams.WeixinId, requestParams.OpenId, media.media_id, httpContext, requestParams);
        }
예제 #11
0
        public void GetKeyByApp()
        {
            WApplicationInterfaceBLL    server = new WApplicationInterfaceBLL(loggingSessionInfo);
            WApplicationInterfaceEntity info   = server.GetByID(applicationId);

            if (info == null)
            {
                Response.Write("不存在对应的微信标识");
            }
            else
            {
                strAppId     = info.AppID;
                strAppSecret = info.AppSecret;
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("泸州老窖:APPID: {0},AppSecret:{1}", strAppId, strAppSecret)
                });
            }
        }
        /// <summary>
        /// 获取列表
        /// </summary>
        public string GetListData()
        {
            var service = new WApplicationInterfaceBLL(new SessionManager().CurrentUserLoginInfo);
            IList <WApplicationInterfaceEntity> data = new List <WApplicationInterfaceEntity>();
            string content = string.Empty;

            data = service.QueryByEntity(new WApplicationInterfaceEntity
            {
                CustomerId = new SessionManager().CurrentUserLoginInfo.CurrentUser.customer_id
            }, null);
            //data = service.GetAll().ToList();

            var jsonData = new JsonData();

            jsonData.totalCount = data.Count.ToString();
            jsonData.data       = data;

            content = jsonData.ToJSON();
            return(content);
        }
예제 #13
0
 public void GetIsMoreCS(string content)
 {
     try
     {
         WApplicationInterfaceBLL bll = new WApplicationInterfaceBLL(requestParams.LoggingSessionInfo);
         int     isMoreCs             = 0;
         DataSet wentity = bll.GetIsMoreCS(requestParams.LoggingSessionInfo.ClientID, requestParams.WeixinId);
         if (wentity != null && wentity.Tables[0].Rows.Count > 0)
         {
             isMoreCs = Convert.ToInt32(wentity.Tables[0].Rows[0]["IsMoreCS"].ToString());
             if (isMoreCs == 1)  //是否支持多客服
             {
                 ResponseTextMessage(requestParams.WeixinId, requestParams.OpenId, content, httpContext);
             }
         }
     }
     catch (Exception ex)
     {
         BaseService.WriteLogWeixin("异常信息:  " + ex.ToString());
     }
 }
예제 #14
0
        /// <summary>
        /// 获取列表
        /// </summary>
        public string GetListData()
        {
            var service = new WModelBLL(new SessionManager().CurrentUserLoginInfo);
            var wApplicationInterfaceBLL = new WApplicationInterfaceBLL(new SessionManager().CurrentUserLoginInfo);
            IList <WModelEntity> data    = new List <WModelEntity>();
            string content = string.Empty;

            string key = "";

            if (Request("pid") != null && Request("pid") != string.Empty)
            {
                key = Request("pid").ToString().Trim();
            }
            string type = "";

            if (Request("type") != null && Request("type") != string.Empty)
            {
                type = Request("type").ToString().Trim();
            }
            if (type == "2")
            {
                var appList = wApplicationInterfaceBLL.QueryByEntity(new WApplicationInterfaceEntity()
                {
                    WeiXinID = key
                }, null);
                if (appList != null && appList.Length > 0)
                {
                    key = appList[0].ApplicationId;
                }
            }
            data = service.GetWModelListByAppId(key);

            var jsonData = new JsonData();

            jsonData.totalCount = data.Count.ToString();
            jsonData.data       = data;

            content = jsonData.ToJSON();
            return(content);
        }
예제 #15
0
        protected override GetAccountListRD ProcessRequest(DTO.Base.APIRequest <GetAccountListRP> pRequest)
        {
            var rd = new GetAccountListRD();

            int?pageIndex = pRequest.Parameters.PageIndex;
            int?pageSize  = pRequest.Parameters.PageSize;


            //string customerId = pRequest.CustomerID;

            //var currentUserInfo = Default.GetBSLoggingSession(customerId, "1");

            var bll = new WApplicationInterfaceBLL(CurrentUserInfo);

            var ds = bll.GetAccountList(CurrentUserInfo.ClientID, pageIndex ?? 0, pageSize ?? 15);



            if (ds.Tables[0].Rows.Count == 0)
            {
                rd.AccountList = null;
            }
            else
            {
                var tmp = ds.Tables[0].AsEnumerable().Select(t => new WXApplicationInfo
                {
                    ApplicationId = t["ApplicationId"].ToString(),
                    WeiXinName    = t["WeiXinName"].ToString()
                });
                rd.AccountList = tmp.ToArray();
            }
            int totalCount = bll.GetTotalcount(CurrentUserInfo.ClientID);



            rd.TotalPages = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(totalCount * 1.00 / (pageSize ?? 15) * 1.00)));

            return(rd);
        }
예제 #16
0
        public void GetKey()
        {
            WApplicationInterfaceBLL    server = new WApplicationInterfaceBLL(loggingSessionInfo);
            WApplicationInterfaceEntity info   = null;

            if (string.IsNullOrEmpty(applicationId))
            {
                info = server.Query(
                    new IWhereCondition[] { new EqualsCondition()
                                            {
                                                FieldName = "CustomerId", Value = customerId
                                            } }
                    , null)[0];
            }
            else
            {
                info = server.GetByID(applicationId);
            }

            if (info == null)
            {
                Response.Write("不存在对应的微信标识");
                Response.End();
            }
            else
            {
                applicationId = info.ApplicationId;
                strAppId      = info.AppID;
                strAppSecret  = info.AppSecret;
                if (info.AuthUrl == null || info.AuthUrl.Equals(""))
                {
                }
                else
                {
                    strRedirectUri = info.AuthUrl + "WXOAuth/AuthCodeReques.aspx";
                }
            }
        }
예제 #17
0
        public void GetKeyByApp()
        {
            WApplicationInterfaceBLL    server = new WApplicationInterfaceBLL(loggingSessionInfo);
            WApplicationInterfaceEntity info   = server.GetByID(applicationId);

            if (info == null)
            {
                Response.Write("不存在对应的微信标识,请联系管理员尽快处理.");
                Response.End();
            }
            else
            {
                strAppId     = info.AppID;
                strAppSecret = info.AppSecret;
                if (info.AuthUrl == null || info.AuthUrl.Equals(""))
                {
                }
                else
                {
                    strRedirectUri = info.AuthUrl + "OAuthWX.aspx";
                }
            }
        }
예제 #18
0
        protected override ShortUrlRD ProcessRequest(APIRequest <ShortUrlRP> pRequest)
        {
            ShortUrlRD rd   = new ShortUrlRD();
            var        para = pRequest.Parameters;

            var list = new WApplicationInterfaceBLL(CurrentUserInfo).QueryByEntity(new WApplicationInterfaceEntity {
                CustomerId = CurrentUserInfo.ClientID, IsDelete = 0
            }, null).ToList();

            if (list == null)
            {
                throw new Exception("该商户没有绑定微信公众号,无法生成商品二维码");
            }
            var wapentity = list.FirstOrDefault();            //获取公众号信息

            JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL();
            var shorturl = commonServer.GetShorturl(wapentity.AppID.ToString().Trim()
                                                    , wapentity.AppSecret.Trim()
                                                    , para.Url
                                                    , CurrentUserInfo);

            rd.ShortUrl = shorturl;
            return(rd);
        }
        /// <summary>
        ///
        /// </summary>
        public string GetWQRCodeTypeData()
        {
            var billService = new WQRCodeTypeBLL(new SessionManager().CurrentUserLoginInfo);
            var wApplicationInterfaceBLL = new WApplicationInterfaceBLL(new SessionManager().CurrentUserLoginInfo);
            //IList<BillStatusModel> list = new List<BillStatusModel>();
            //list.Add(new BillStatusModel() { Id = "1", Description = "基本" });
            //list.Add(new BillStatusModel() { Id = "2", Description = "高级" });

            string key = "";

            if (Request("pid") != null && Request("pid") != string.Empty)
            {
                key = Request("pid").ToString().Trim();
            }
            string type = "";

            if (Request("type") != null && Request("type") != string.Empty)
            {
                type = Request("type").ToString().Trim();
            }

            var appId = "";

            if (type == "2")
            {
                var appObjs = wApplicationInterfaceBLL.QueryByEntity(new WApplicationInterfaceEntity()
                {
                    ApplicationId = key
                }, null);
                if (appObjs != null && appObjs.Length > 0)
                {
                    appId = appObjs[0].ApplicationId;
                }
                else
                {
                    appId = "-99";
                }
            }
            else
            {
                var appObjs = wApplicationInterfaceBLL.QueryByEntity(new WApplicationInterfaceEntity()
                {
                    WeiXinID = key
                }, null);
                if (appObjs != null && appObjs.Length > 0)
                {
                    appId = appObjs[0].ApplicationId;
                }
                else
                {
                    appId = "-99";
                }
            }

            var list = billService.GetList(new WQRCodeTypeEntity()
            {
                ApplicationId = appId
            }, 0, 1000);

            string content = string.Empty;

            var jsonData = new JsonData();

            jsonData.totalCount = list.Count.ToString();
            jsonData.data       = list;

            content = jsonData.ToJSON();
            return(content);
        }
예제 #20
0
        /// <summary>
        /// 推送图文消息
        /// </summary>
        /// <param name="materialId"></param>
        public void GetImageText(string materialId, string WeiXin, string OpenId)
        {
            Loggers.Debug(new DebugLogInfo()
            {
                Message = string.Format("中欧扫描--关注materialId 进入 materialId:{0},WeiXin:{1},OpenId:{2}", materialId, WeiXin, OpenId)
            });
            try
            {
                var dsMaterialText = new WMaterialTextDAO(loggingSessionInfo).GetMaterialTextByID(materialId);
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("中欧扫描--关注loggingSessionInfo 进入 loggingSessionInfo:{0}", loggingSessionInfo.CurrentUser.customer_id)
                });
                if (dsMaterialText != null && dsMaterialText.Tables.Count > 0 && dsMaterialText.Tables[0].Rows.Count > 0)
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("中欧扫描--关注materialId 进入 dsMaterialText:")
                    });
                    var newsList = new List <NewsEntity>();

                    foreach (DataRow dr in dsMaterialText.Tables[0].Rows)
                    {
                        newsList.Add(new NewsEntity()
                        {
                            title       = dr["Title"].ToString(),
                            description = dr["Author"].ToString(),
                            picurl      = dr["CoverImageUrl"].ToString(),
                            url         = dr["OriginalUrl"].ToString()
                        });
                    }
                    JIT.CPOS.BS.BLL.WX.CommonBLL commonService = new WX.CommonBLL();
                    SendMessageEntity            sendInfo      = new SendMessageEntity();
                    sendInfo.msgtype  = "news";
                    sendInfo.touser   = OpenId;
                    sendInfo.articles = newsList;
                    WApplicationInterfaceBLL waServer = new WApplicationInterfaceBLL(loggingSessionInfo);
                    var waObj = waServer.QueryByEntity(new WApplicationInterfaceEntity
                    {
                        WeiXinID = WeiXin
                    }, null);
                    if (waObj == null || waObj.Length == 0 || waObj[0] == null)
                    {
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("中欧扫描--关注materialId 进入 waObj为空:}")
                        });
                    }
                    else
                    {
                        string appID     = string.Empty;
                        string appSecret = string.Empty;
                        appID     = waObj[0].AppID;
                        appSecret = waObj[0].AppSecret;
                        JIT.CPOS.BS.Entity.WX.ResultEntity resultInfo = new JIT.CPOS.BS.Entity.WX.ResultEntity();
                        resultInfo = commonService.SendMessage(sendInfo, appID, appSecret, loggingSessionInfo);
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("中欧扫描--关注materialId 进入 waObj:appID:{0},appSecret {1}", appID, appSecret)
                        });
                    }
                }
            }
            catch (Exception ex) {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("中欧扫描--关注GetImageText 进入 错误:{0}", ex.ToString())
                });
            }
        }
예제 #21
0
        //生成员工二维码
        public string CreateUserWxCode(UserInfo user, string unitName, LoggingSessionInfo loggingSessionInfo, out string errorMsg)
        {
            errorMsg = "";
            #region  生成员工二维码
            //微信 公共平台
            //兼容模式
            var wapentity = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity
            {
                CustomerId = loggingSessionInfo.ClientID,
                IsDelete   = 0
            }, null).FirstOrDefault();//取默认的第一个微信

            var QRCodeId            = Guid.NewGuid();
            var QRCodeManagerentity = new WQRCodeManagerBLL(loggingSessionInfo).QueryByEntity(new WQRCodeManagerEntity
            {
                ObjectId = user.User_Id
            }, null).FirstOrDefault();
            if (QRCodeManagerentity != null)
            {
                QRCodeId = (Guid)QRCodeManagerentity.QRCodeId;
            }
            if (QRCodeManagerentity == null)
            {
                //二维码类别
                var wqrentity = new WQRCodeTypeBLL(loggingSessionInfo).QueryByEntity(
                    new WQRCodeTypeEntity {
                    TypeCode = "UserQrCode"
                }
                    , null).FirstOrDefault();
                if (wqrentity == null)
                {
                    //responseData.success = false;
                    //responseData.msg = "无法获取员工二维码类别";
                    //return responseData.ToJSON();
                    errorMsg = "无法获取员工二维码类别";
                }
                //生成了微信二维码
                var wxCode = CretaeWxCode(loggingSessionInfo);//***
                //如果名称不为空,就把图片放在一定的背景下面
                if (!string.IsNullOrEmpty(user.User_Name) && wxCode.success == true)
                {
                    try
                    {
                        string apiDomain = ConfigurationManager.AppSettings["original_url"];
                        wxCode.ImageUrl = CombinImage(apiDomain + @"/HeadImage/qrcodeBack.jpg", wxCode.ImageUrl, unitName + "-" + user.User_Name);
                    }
                    catch
                    {
                        errorMsg = "生成二维码失败";
                    }
                }
                else
                {
                    errorMsg = "生成二维码失败";
                }

                var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo);//兼容模式

                //    Guid QRCodeId = Guid.NewGuid();

                if (!string.IsNullOrEmpty(wxCode.ImageUrl))
                {
                    WQRCodeManagerbll.Create(new WQRCodeManagerEntity
                    {
                        QRCodeId      = QRCodeId,
                        QRCode        = wxCode.MaxWQRCod.ToString(),
                        QRCodeTypeId  = wqrentity.QRCodeTypeId,
                        IsUse         = 1,
                        ObjectId      = user.User_Id,
                        CreateBy      = loggingSessionInfo.UserID,//兼容模式
                        ApplicationId = wapentity.ApplicationId,
                        IsDelete      = 0,
                        ImageUrl      = wxCode.ImageUrl,
                        CustomerId    = loggingSessionInfo.ClientID
                    });
                }

                return(wxCode.ImageUrl);//生成新的二维码地址
            }
            else
            {
                return(QRCodeManagerentity.ImageUrl);
            }



            #endregion
        }
예제 #22
0
        public HttpResponseMessage QRCode(string UnitId, string ObjectID)
        {
            Loggers.Debug(new DebugLogInfo()
            {
                Message = $"[api/Vip/QRCode]接口,参数:\"UnitId:{UnitId}&ObjectID:{ObjectID}\""
            });
            try
            {
                string customerId         = ConfigurationManager.AppSettings["CustomerId"].Trim();
                var    loggingSessionInfo = Default.GetLoggingSession(customerId, ObjectID);
                loggingSessionInfo.Conn = ConfigurationManager.AppSettings["Conn"].Trim();

                var    imageUrl = string.Empty;
                Random ro       = new Random();
                var    iUp      = 100000000;
                var    iDown    = 50000000;


                var rpVipDCode = 0;                   //临时二维码
                var iResult    = ro.Next(iDown, iUp); //随机数

                string objectid = ObjectID;

                #region 获取微信帐号

                //门店关联的公众号
                var tuBll    = new t_unitBLL(loggingSessionInfo);
                var tuEntity = new t_unitEntity();
                if (!string.IsNullOrEmpty(UnitId))
                {
                    tuEntity =
                        tuBll.QueryByEntity(new t_unitEntity()
                    {
                        unit_id = UnitId
                    }, null)
                        .FirstOrDefault();
                }

                var server = new WApplicationInterfaceBLL(loggingSessionInfo);
                var wxObj  = new WApplicationInterfaceEntity();
                if (tuEntity != null && !string.IsNullOrEmpty(tuEntity.weiXinId))
                {
                    wxObj =
                        server.QueryByEntity(
                            new WApplicationInterfaceEntity {
                        WeiXinID = tuEntity.weiXinId, CustomerId = customerId
                    },
                            null).FirstOrDefault();
                }
                else
                {
                    wxObj =
                        server.QueryByEntity(new WApplicationInterfaceEntity {
                        CustomerId = customerId
                    }, null)
                        .FirstOrDefault();
                }

                if (wxObj == null)
                {
                    throw new APIException("不存在对应的微信帐号")
                          {
                              ErrorCode = 302
                          };
                }
                else
                {
                    var commonServer = new CommonBLL();

                    imageUrl = commonServer.GetQrcodeUrl(wxObj.AppID
                                                         , wxObj.AppSecret
                                                         , rpVipDCode.ToString("")       //二维码类型  0: 临时二维码  1:永久二维码
                                                         , iResult, loggingSessionInfo); //iResult作为场景值ID,临时二维码时为32位整型,永久二维码时只支持1--100000
                    //"https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQGN7zoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL1dreENCS1htX0xxQk94SEJ6MktIAAIEUk88VwMECAcAAA==";
                    //"https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=gQGN7zoAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL1dreENCS1htX0xxQk94SEJ6MktIAAIEUk88VwMECAcAAA==";
                    if (imageUrl != null && !imageUrl.Equals(""))
                    {
                        DownloadImage downloadServer   = new DownloadImage();
                        string        downloadImageUrl = ConfigurationManager.AppSettings["website_WWW"];
                        imageUrl = downloadServer.DownloadFile(imageUrl, downloadImageUrl);
                    }
                }

                #endregion


                #region 创建临时匹配表

                VipDCodeBLL    vipDCodeServer = new VipDCodeBLL(loggingSessionInfo);
                VipDCodeEntity info           = new VipDCodeEntity();
                info.DCodeId              = iResult.ToString(); //记录传过去的二维码场景值****(保存到数据库时没加空格)
                info.CustomerId           = customerId;
                info.UnitId               = UnitId;             //获取会集店
                info.Status               = "0";
                info.IsReturn             = 0;
                info.DCodeType            = 2; // add by donal 2014-9-22 10:02:08
                loggingSessionInfo.UserID = ObjectID;
                info.CreateBy             = ObjectID;
                info.ImageUrl             = imageUrl;
                //info.VipId = RP.UserID;
                info.ObjectId = ObjectID; //分享经销商的vipid
                vipDCodeServer.Create(info);

                #endregion


                var model = new QRCodeResponseModel()
                {
                    IsSucess = true,
                    ImageUrl = imageUrl,
                    paraTmp  = iResult.ToString().Insert(4, " ")
                };

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = $"setSignUp content: {model}"
                });


                return(Request.CreateResponse(HttpStatusCode.OK, model));
            }
            catch (Exception ex)
            {
                var model = new QRCodeResponseModel()
                {
                    IsSucess     = false,
                    ErrorMessage = string.Format("获取二维码出错:{0}", ex.Message)
                };
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("获取二维码出错:{0}", ex.Message)
                });
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, model));
            }
        }
예제 #23
0
        /// <summary>
        /// 保存微信信息
        /// </summary>
        /// <param name="pwai"></param>
        /// <param name="paui"></param>
        /// <param name="clientId"></param>
        /// <returns></returns>
        public static bool SetWechatApp(QueryAuthResult pwai, GetAuthorizerInfoResult paui, string clientId)
        {
            #region 保存到微信信息表里
            //var clientId = "eb17cc2569c74ab7888b1f403972d37d";//测试用
            var loggingSessionInfo = Default.GetBSLoggingSession(clientId, "open");
            var waiBll             = new WApplicationInterfaceBLL(loggingSessionInfo);
            var waiEntitys         = new WApplicationInterfaceEntity[] { };
            var waiEntity          = new WApplicationInterfaceEntity();

            //去除之前授权的记录
            //查询参数
            List <IWhereCondition> complexCondition = new List <IWhereCondition> {
            };
            complexCondition.Add(new EqualsCondition()
            {
                FieldName = "AppID", Value = pwai.authorization_info.authorizer_appid
            });
            complexCondition.Add(new DirectCondition(" CustomerId != '" + clientId + "'"));
            complexCondition.Add(new EqualsCondition()
            {
                FieldName = "OpenOAuthAppid", Value = WebConfigurationManager.AppSettings["Component_Appid"]
            });
            var tempList = waiBll.PagedQuery(complexCondition.ToArray(), null, 10, 1);
            if (tempList.Entities.Length > 0)
            {
                foreach (var item in tempList.Entities)
                {
                    waiBll.Delete(item);
                }
            }

            var prevWaiEntitys = waiBll.QueryByEntity(new WApplicationInterfaceEntity {
                AppID = pwai.authorization_info.authorizer_appid, CustomerId = clientId, IsDelete = 0, OpenOAuthAppid = WebConfigurationManager.AppSettings["Component_Appid"]
            }, null);


            waiEntitys = waiBll.QueryByEntity(new WApplicationInterfaceEntity {
                AppID = pwai.authorization_info.authorizer_appid, CustomerId = clientId, IsDelete = 0
            }, null);
            if (waiEntitys != null && waiEntitys.Length > 0)
            {
                waiEntity       = waiEntitys.FirstOrDefault();
                waiEntity.URL   = Config.URL;
                waiEntity.Token = "jitmarketing";//老代码写死token//Config.ServerToken;
                //waiEntity.Token = "zmindclouds";//老代码写死token//Config.ServerToken,
                //waiEntity.AppID = "wx691c2f2bbac04b4b";
                //waiEntity.AppSecret = "0c79e1fa963cd80cc0be99b20a18faeb";
                //waiEntity.PrevEncodingAESKey = "F3Rd5xvdCqUsL5FFwhS1vSIqTRFoNpRcWhyGrOjQhAK";
                //waiEntity.CurrentEncodingAESKey = "F3Rd5xvdCqUsL5FFwhS1vSIqTRFoNpRcWhyGrOjQhAK";
                waiEntity.ServerIP     = Config.ServerIP;
                waiEntity.AuthUrl      = Config.AuthUrl;
                waiEntity.RequestToken = pwai != null ? pwai.authorization_info.authorizer_access_token : string.Empty;
                //waiEntity.RefreshToken = pwai != null ? pwai.authorization_info.authorizer_refresh_token : string.Empty,//刷新token
                waiEntity.ExpirationTime = DateTime.Now.AddSeconds(7000);//默认7200,提前200秒过期
                waiEntity.IsMoreCS       = 1;
                waiEntity.OpenOAuthAppid = WebConfigurationManager.AppSettings["Component_Appid"];
                waiBll.Update(waiEntity);
                //提交管理平台
                waiBll.setCposApMapping(waiEntity);
            }
            else
            {
                if (pwai != null && paui != null)
                {
                }
                var weixinTypeId = "3";//服务号
                switch (paui.authorizer_info.service_type_info.id.ToString())
                {
                case "0":
                    weixinTypeId = "1";    //订阅号
                    break;

                case "1":
                    weixinTypeId = "2";    //订阅号
                    break;
                }
                waiEntity = new WApplicationInterfaceEntity()
                {
                    ApplicationId = Guid.NewGuid().ToString("N"),
                    WeiXinName    = paui != null ? paui.authorizer_info.nick_name : string.Empty,
                    WeiXinID      = paui != null ? paui.authorizer_info.user_name : string.Empty,
                    URL           = Config.URL,
                    Token         = "jitmarketing", //老代码写死token//Config.ServerToken,
                    AppID         = pwai != null ? pwai.authorization_info.authorizer_appid : string.Empty,
                    AppSecret     = string.Empty,   //空

                    //Token = "zmindclouds",//老代码写死token//Config.ServerToken,
                    //AppID = "wx691c2f2bbac04b4b",
                    //AppSecret = "0c79e1fa963cd80cc0be99b20a18faeb",//空
                    //PrevEncodingAESKey = "F3Rd5xvdCqUsL5FFwhS1vSIqTRFoNpRcWhyGrOjQhAK",
                    //CurrentEncodingAESKey = "F3Rd5xvdCqUsL5FFwhS1vSIqTRFoNpRcWhyGrOjQhAK",

                    ServerIP     = Config.ServerIP,
                    WeiXinTypeId = weixinTypeId,// paui != null ? paui.authorizer_info.service_type_info.id.ToString() : "3",
                    AuthUrl      = Config.AuthUrl,
                    RequestToken = pwai != null ? pwai.authorization_info.authorizer_access_token : string.Empty,
                    //RefreshToken = pwai != null ? pwai.authorization_info.authorizer_refresh_token : string.Empty,//刷新token
                    ExpirationTime = DateTime.Now.AddSeconds(7000),                          //默认7200,提前200秒过期
                    IsHeight       = 1,                                                      //1=高级帐号
                    IsMoreCS       = 1,
                    OpenOAuthAppid = WebConfigurationManager.AppSettings["Component_Appid"], // component_AppId;
                    CustomerId     = clientId
                };
                waiBll.Create(waiEntity);

                //提交微信初级菜单
                waiBll.setCreateWXMenu(waiEntity);
                //提交管理平台
                waiBll.setCposApMapping(waiEntity);
            }

            #endregion

            return(true);
        }
예제 #24
0
        public WxCode CretaeWxCode()
        {
            var responseData = new WxCode();

            responseData.success = false;
            responseData.msg     = "二维码生成失败!";
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            try
            {
                //微信 公共平台
                var wapentity = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity
                {
                    CustomerId = loggingSessionInfo.ClientID,
                    IsDelete   = 0
                }, null).FirstOrDefault();

                //获取当前二维码 最大值
                var MaxWQRCod = new WQRCodeManagerBLL(loggingSessionInfo).GetMaxWQRCod() + 1;

                if (wapentity == null)
                {
                    responseData.success = false;
                    responseData.msg     = "无设置微信公众平台!";
                    return(responseData);
                }

                string imageUrl = string.Empty;

                #region 生成二维码
                JIT.CPOS.BS.BLL.WX.CommonBLL commonServer = new JIT.CPOS.BS.BLL.WX.CommonBLL();
                try
                {
                    imageUrl = commonServer.GetQrcodeUrl(wapentity.AppID.ToString().Trim()
                                                         , wapentity.AppSecret.Trim()
                                                         , "1", MaxWQRCod
                                                         , loggingSessionInfo);
                }
                catch (Exception e)
                {
                    responseData.success = false;
                    responseData.msg     = e.Message;// "二维码生成失败!";
                    return(responseData);
                }

                if (!string.IsNullOrEmpty(imageUrl))
                {
                    string host = ConfigurationManager.AppSettings["DownloadImageUrl"];
                    CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                    imageUrl = downloadServer.DownloadFile(imageUrl, host);
                }
                #endregion
                responseData.success   = true;
                responseData.msg       = "";
                responseData.ImageUrl  = imageUrl;
                responseData.MaxWQRCod = MaxWQRCod;


                return(responseData);
            }
            catch (Exception ex)
            {
                //throw new APIException(ex.Message);
                return(responseData);
            }
        }
예제 #25
0
        protected override DownloadQRCodeRD ProcessRequest(DTO.Base.APIRequest <DownloadQRCodeRP> pRequest)
        {
            string content    = string.Empty;
            string customerId = string.Empty;
            var    RD         = new DownloadQRCodeRD();

            try
            {
                #region 解析传入参数
                //解析请求字符串
                var RP = pRequest.Parameters;

                //判断客户ID是否传递

                customerId = CurrentUserInfo.CurrentUser.customer_id;


                #endregion
                var    imageUrl = string.Empty;
                Random ro       = new Random();
                var    iUp      = 100000000;
                var    iDown    = 50000000;

                if (string.IsNullOrEmpty(RP.VipDCode.ToString()) || RP.VipDCode == 0)
                {
                    throw new APIException("VipDCode参数不能为空");
                }
                var rpVipDCode = 0;                   //临时二维码
                var iResult    = ro.Next(iDown, iUp); //随机数

                if (RP.VipDCode == 9)                 //永久二维码
                {
                    var userQRCodeBll  = new WQRCodeManagerBLL(CurrentUserInfo);
                    var marketEventBll = new MarketEventBLL(CurrentUserInfo);

                    var marketEventEntity = marketEventBll.QueryByEntity(new MarketEventEntity()
                    {
                        EventCode = "CA00002433", CustomerId = CurrentUserInfo.ClientID
                    }, null).FirstOrDefault();
                    var userQRCode = userQRCodeBll.QueryByEntity(new WQRCodeManagerEntity()
                    {
                        ObjectId = marketEventEntity.MarketEventID, CustomerId = CurrentUserInfo.ClientID
                    }, null);                                                                                                                                                              //

                    if (userQRCode != null && userQRCode.Length > 0)
                    {
                        RD.imageUrl = userQRCode[0].ImageUrl;
                        return(RD);
                    }

                    //获取当前二维码 最大值
                    iResult    = new WQRCodeManagerBLL(CurrentUserInfo).GetMaxWQRCod() + 1;
                    rpVipDCode = 1;                 //永久

                    #region 获取微信帐号
                    //门店关联的公众号
                    var tueBll    = new TUnitExpandBLL(CurrentUserInfo);
                    var tueEntity = new TUnitExpandEntity();
                    if (!string.IsNullOrEmpty(CurrentUserInfo.CurrentUserRole.UnitId))
                    {
                        tueEntity = tueBll.QueryByEntity(new TUnitExpandEntity()
                        {
                            UnitId = CurrentUserInfo.CurrentUserRole.UnitId
                        }, null).FirstOrDefault();
                    }

                    var server = new WApplicationInterfaceBLL(CurrentUserInfo);
                    var wxObj  = new WApplicationInterfaceEntity();
                    if (tueEntity != null && !string.IsNullOrEmpty(tueEntity.Field1))
                    {
                        wxObj = server.QueryByEntity(new WApplicationInterfaceEntity {
                            AppID = tueEntity.Field1, CustomerId = customerId
                        }, null).FirstOrDefault();
                    }
                    else
                    {
                        wxObj = server.QueryByEntity(new WApplicationInterfaceEntity {
                            CustomerId = customerId
                        }, null).FirstOrDefault();
                    }

                    if (wxObj == null)
                    {
                        throw new APIException("没有对应公众号");
                    }
                    else
                    {
                        var commonServer = new CommonBLL();

                        imageUrl = commonServer.GetQrcodeUrl(wxObj.AppID
                                                             , wxObj.AppSecret
                                                             , rpVipDCode.ToString("")    //二维码类型  0: 临时二维码  1:永久二维码
                                                             , iResult, CurrentUserInfo); //iResult作为场景值ID,临时二维码时为32位整型,永久二维码时只支持1--100000
                        if (imageUrl != null && !imageUrl.Equals(""))
                        {
                            CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                            string downloadImageUrl = ConfigurationManager.AppSettings["website_WWW"];
                            imageUrl = downloadServer.DownloadFile(imageUrl, downloadImageUrl);
                            //如果名称不为空,就把图片放在一定的背景下面
                            //if (!string.IsNullOrEmpty(RP.Parameters.RetailTraderName))
                            //{
                            //    string apiDomain = ConfigurationManager.AppSettings["website_url"];

                            //    imageUrl = CombinImage(apiDomain + @"/HeadImage/qrcodeBack.jpg", imageUrl, RP.Parameters.RetailTraderName + "合作二维码");
                            //}
                        }
                    }

                    #endregion

                    if (!string.IsNullOrEmpty(imageUrl))    //永久二维码
                    {
                        #region 创建店员永久二维码匹配表
                        var userQrTypeBll = new WQRCodeTypeBLL(CurrentUserInfo);
                        var userQrType    = userQrTypeBll.QueryByEntity(new WQRCodeTypeEntity()
                        {
                            TypeName = "签到"
                        }, null);                                                                                       //"UserQrCode"
                        if (userQrType != null && userQrType.Length > 0)
                        {
                            var userQrCodeBll = new WQRCodeManagerBLL(CurrentUserInfo);
                            var userQrCode    = new WQRCodeManagerEntity();
                            userQrCode.QRCode        = iResult.ToString();//记录传过去的二维码场景值
                            userQrCode.QRCodeTypeId  = userQrType[0].QRCodeTypeId;
                            userQrCode.IsUse         = 1;
                            userQrCode.CustomerId    = CurrentUserInfo.CurrentUser.customer_id;
                            userQrCode.ImageUrl      = imageUrl;
                            userQrCode.ApplicationId = wxObj.ApplicationId;
                            //objectId 为店员ID
                            userQrCode.ObjectId = marketEventEntity.MarketEventID;
                            userQrCodeBll.Create(userQrCode);
                        }
                        #endregion
                    }
                }

                RD.imageUrl = imageUrl;
            }
            catch
            {
                throw new APIException("生成二维码错误");
            }
            return(RD);
        }
예제 #26
0
        private void SetToken()
        {
            string             customerId         = string.Empty;
            string             applicationId      = string.Empty;
            string             userId             = string.Empty;
            string             openId             = string.Empty;
            string             eventId            = string.Empty;
            string             strAppId           = string.Empty;
            string             strAppSecret       = string.Empty;
            LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo();

            try
            {
                #region 解析参数
                byte[] buff1 = Convert.FromBase64String(state);
                state = Encoding.UTF8.GetString(buff1);
                state = HttpUtility.UrlDecode(state, Encoding.UTF8);
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("SetToken--state: {0}", state.ToString())
                });
                string[] array = state.Split(',');
                customerId    = array[0];
                applicationId = array[1];
                userId        = array[2];
                openId        = array[3];
                eventId       = array[4];
                goUrl         = array[5];
                #endregion
                loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");

                WApplicationInterfaceBLL    server = new WApplicationInterfaceBLL(loggingSessionInfo);
                WApplicationInterfaceEntity info   = server.GetByID(applicationId);
                if (info == null)
                {
                    Response.Write("不存在对应的微信标识");
                }
                else
                {
                    Random rad  = new Random();
                    int    iRad = rad.Next(1000, 100000);
                    strAppId     = info.AppID;
                    strAppSecret = info.AppSecret;
                    JIT.CPOS.BS.BLL.WX.AuthBLL authServer = new BS.BLL.WX.AuthBLL();
                    string token     = "";
                    string openIdNew = authServer.GetAccessToken(code, strAppId, strAppSecret, loggingSessionInfo, iRad, out token);
                    //Response.Write("openId:" + openId);
                    //Response.Write("------------");
                    //Response.Write("openIdNew:" + openIdNew);
                    if (!openIdNew.Equals(""))
                    {
                        if (openId.Equals(openIdNew))
                        {
                            goUrl = HttpUtility.UrlDecode(goUrl) + "?customerId=" + customerId + "&openId=" + openId + "&userId=" + userId + "&eventId=" + eventId + "&code=" + code + "&rid=" + rad.Next(1000, 100000) + "";
                            //"http://" + HttpUtility.UrlDecode(goUrl) + "";
                            //Response.Write(goUrl);
                            Response.Redirect(goUrl);
                        }
                    }
                    else
                    {
                        Response.Write("请关注微讯网(o2omarketing)公众平台,在登录该界面操作。");
                    }
                }
            }
            catch (Exception ex) {
                strError = ex.ToString();
            }
        }
예제 #27
0
        //响应微信平台推送消息
        private void ResponseMsg(HttpContext httpContext, RequestParams requestParams)
        {
            BaseBLL  weixin  = null;
            IFactory factory = null;

            #region 通过微信类型生成对应的业务处理类

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

            if (appEntitys != null && appEntitys.Length > 0)
            {
                var entity = appEntitys.FirstOrDefault();
                BaseService.WriteLogWeixin("通过微信类型生成对应的业务处理类");
                BaseService.WriteLogWeixin("WeiXinTypeId(微信类型):  " + entity.WeiXinTypeId);

                switch (entity.WeiXinTypeId)
                {
                case WeiXinType.SUBSCRIPTION:
                    factory = new SubscriptionFactory();
                    weixin  = factory.CreateWeiXin(httpContext, requestParams);
                    BaseService.WriteLogWeixin("订阅号");
                    break;

                case WeiXinType.SERVICE:
                    factory = new ServiceFactory();
                    weixin  = factory.CreateWeiXin(httpContext, requestParams);
                    BaseService.WriteLogWeixin("服务号");
                    break;

                case WeiXinType.CERTIFICATION:        //目前我们的客户一般是认证服务号,所以关注事件从这里查看
                    factory = new CertificationFactory();
                    weixin  = factory.CreateWeiXin(httpContext, requestParams);
                    BaseService.WriteLogWeixin("认证服务号");
                    break;

                case WeiXinType.SUBSCRIPTION_EXTEND:
                    BaseService.WriteLogWeixin("可扩展订阅号");
                    break;

                case WeiXinType.SERVICE_EXTEND:
                    BaseService.WriteLogWeixin("可扩展服务号");
                    break;

                case WeiXinType.CERTIFICATION_EXTEND:
                    BaseService.WriteLogWeixin("可扩展认证服务号");
                    break;

                default:
                    factory = new SubscriptionFactory();
                    weixin  = factory.CreateWeiXin(httpContext, requestParams);
                    BaseService.WriteLogWeixin("默认订阅号");
                    break;
                }
            }

            #endregion

            weixin.ResponseMsg();//根据消息类型,回应事件。有文本消息、图片消息、多客服、地理位置、事件
        }
예제 #28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write("进入认证界面<br/>");
            if (!IsPostBack)
            {
                Random rad  = new Random();
                int    iRad = rad.Next(1000, 100000);
                if (!string.IsNullOrEmpty(Request["state"]))
                {
                    #region state不为空
                    string state = Request["state"];
                    //Response.Write("state:" + state);
                    try
                    {
                        #region 参数拼成
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("strState2: {0}", state)
                        });
                        //byte[] buff1 = Convert.FromBase64String(state);
                        //state = Encoding.UTF8.GetString(buff1);
                        //state = HttpUtility.UrlDecode(state, Encoding.UTF8);
                        //string[] array = state.Split(',');
                        //customerId = array[0];
                        //applicationId = array[1];
                        //goUrl = array[2];
                        //goUrl = goUrlTemp + goUrl;

                        byte[] buff1 = Convert.FromBase64String(state);
                        state = Encoding.UTF8.GetString(buff1);
                        state = HttpUtility.UrlDecode(state, Encoding.UTF8);
                        string[] array = state.Split(',');
                        customerId    = array[1];
                        applicationId = array[2];
                        goUrl         = array[0];
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        Response.Write("<br/>");
                        Response.Write("state错误:" + ex.ToString());
                    }
                    #endregion
                }
                else
                {
                    #region 参数
                    //判断客户ID是否传递
                    if (!string.IsNullOrEmpty(Request["customerId"]))
                    {
                        customerId = Request["customerId"];
                    }
                    else
                    {
                        Response.Write("<br>");
                        Response.Write("没有获取客户标识");
                    }

                    if (!string.IsNullOrEmpty(Request["applicationId"]))
                    {
                        applicationId = Request["applicationId"];
                    }
                    else
                    {
                        loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");
                        var list = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity {
                            CustomerId = customerId
                        }, null).ToList();

                        if (list != null && list.Count > 0)
                        {
                            applicationId = list.FirstOrDefault().ApplicationId;
                        }
                        else
                        {
                            Response.Write("<br>");
                            Response.Write("没有获取微信标识,请联系管理员尽快处理.");
                            Response.End();
                        }
                    }

                    if (!string.IsNullOrEmpty(Request["goUrl"]))
                    {
                        goUrl = Request["goUrl"];
                        Response.Write("<br>");
                        Response.Write("goUrl:" + goUrl);
                        string eventId = Request["eventId"];
                        if (eventId != null && !eventId.Equals(""))
                        {
                            if (goUrl.IndexOf("?") > 0)
                            {
                                goUrl = goUrl + "&eventId=" + eventId + "";
                            }
                            else
                            {
                                goUrl = goUrl + "?eventId=" + eventId + "";
                            }
                        }
                        //Response.End();
                    }
                    else
                    {
                        Response.Write("<br>");
                        Response.Write("没有获取goUrl");
                        Response.End();
                    }
                    #endregion
                }
                Response.Write("<br>");
                Response.Write("goUrl:" + goUrl);
                //Response.End();
                loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");

                //Get keys about Wechat
                GetKey();

                string code = Request["code"];
                if (code == null || code.Equals(""))
                {
                    //strState = customerId + "," + applicationId + "," + goUrl; //
                    //strState = HttpUtility.UrlEncode(strState, Encoding.UTF8);
                    //byte[] buff = Encoding.UTF8.GetBytes(strState);
                    //strState = Convert.ToBase64String(buff);

                    strState = goUrl + "," + customerId + "," + applicationId; //
                    strState = HttpUtility.UrlEncode(strState, Encoding.UTF8);
                    byte[] buff = Encoding.UTF8.GetBytes(strState);
                    strState = Convert.ToBase64String(buff);

                    authBll.GetOAuthCode(strAppId, strRedirectUri, strState, this.Response);
                }
                else
                {
                    Response.Write("存在code:" + code);
                    string token  = "";
                    string openId = authBll.GetAccessToken(code, strAppId, strAppSecret, loggingSessionInfo, iRad, out token);
                    Response.Write("<br>");
                    Response.Write("OpenID:" + openId);
                    PageRedict(openId);
                }
            }
        }
예제 #29
0
        protected override SetCTWEventRD ProcessRequest(APIRequest <SetCTWEventRP> pRequest)
        {
            //图文信息
            //微信 公共平台
            var wapentity = new WApplicationInterfaceBLL(loggingSessionInfo).QueryByEntity(new WApplicationInterfaceEntity
            {
                CustomerId = loggingSessionInfo.ClientID,
                IsDelete   = 0
            }, null).FirstOrDefault();//取默认的第一个微信

            if (wapentity == null)
            {
                throw new APIException("微信公众号未授权")
                      {
                          ErrorCode = 343
                      };
            }

            var rd = new SetCTWEventRD();

            var para = pRequest.Parameters;

            strCTWEventId = para.CTWEventId;
            string strThemeId       = string.Empty;
            string strStartDate     = string.Empty;
            string strEndDate       = string.Empty;
            string strGameEventGuid = string.Empty;
            string strPageParamJson = string.Empty;

            T_CTW_LEventBLL             bllCustomerEvent       = new T_CTW_LEventBLL(loggingSessionInfo);
            T_CTW_LEventThemeBLL        bllCustomerTheme       = new T_CTW_LEventThemeBLL(loggingSessionInfo);
            T_CTW_LEventInteractionBLL  bllCustomerInteraction = new T_CTW_LEventInteractionBLL(loggingSessionInfo);
            T_CTW_PanicbuyingEventKVBLL bllPanicbuyingEventKV  = new T_CTW_PanicbuyingEventKVBLL(loggingSessionInfo);
            T_CTW_SpreadSettingBLL      bllSpreadSetting       = new T_CTW_SpreadSettingBLL(loggingSessionInfo);
            LPrizesBLL      bllPrize = new LPrizesBLL(loggingSessionInfo);
            ObjectImagesBLL imageBll = new ObjectImagesBLL(loggingSessionInfo);


            entityCustomerEvent = bllCustomerEvent.GetByID(strCTWEventId);
            if (entityCustomerEvent != null)
            {
                ///风格
                entityTheme = bllCustomerTheme.QueryByEntity(new T_CTW_LEventThemeEntity()
                {
                    CTWEventId = new Guid(strCTWEventId), OriginalThemeId = new Guid(para.OriginalThemeId)
                }, null).FirstOrDefault();
                //互动方式
                entityInteraction = bllCustomerInteraction.QueryByEntity(new T_CTW_LEventInteractionEntity {
                    CTWEventId = new Guid(strCTWEventId), OriginalLeventId = new Guid(para.OriginalLeventId)
                }, null).FirstOrDefault();
            }
            //保存风格
            SaveAndUpdateTheme(para, entityTheme, out strThemeId);
            //互动类型--游戏
            if (para.InteractionType == 1 && para.GameEventInfo != null)
            {
                SaveGameEvent(para, bllPrize, bllCustomerInteraction, strThemeId, out strStartDate, out strEndDate, out strGameEventGuid);
                para.MaterialText.PageParamJson = "[{\"key\":\"eventId\",\"value\":\"" + strCTWEventId + "\"}]";
                strPageParamJson = "[{\"key\":\"eventId\",\"value\":\"" + strCTWEventId + "\"}]";
            }
            //互动类型--促销
            if (para.InteractionType == 2 && para.PanicbuyingEventInfo != null)
            {
                SavePanicbuyingEvent(para, bllPanicbuyingEventKV, imageBll, bllCustomerInteraction, strThemeId, out strStartDate, out strEndDate);
                string strEventType = string.Empty;
                switch (para.DrawMethodCode)
                {
                case "TG":
                    strEventType = "1";
                    break;

                case "QG":
                    strEventType = "2";
                    break;

                case "RX":
                    strEventType = "3";
                    break;

                default:
                    strEventType = "99";
                    break;
                }
                para.MaterialText.PageParamJson = "[{\"key\":\"CTWEventId\",\"value\":\"" + strCTWEventId + "\"},{\"key\":\"eventTypeId\",\"value\":\"" + strEventType + "\"}]";
                strPageParamJson = "[{\"key\":\"CTWEventId\",\"value\":\"" + strCTWEventId + "\"},{\"key\":\"eventTypeId\",\"value\":\"" + strEventType + "\"}]";


                //SaveAndUpdatePanicbuyingEvent(para,bllPrize,bllPanicbuyingEventKV,imageBll,bllCustomerInteraction, strThemeId, out strStartDate, out strEndDate);
            }
            string strFocesQRCodeUrl = string.Empty;

            //分享,推广
            if (para.SpreadSettingList.Count > 0)
            {
                SaveSpreadSetting(para, bllSpreadSetting, imageBll, wapentity, out strFocesQRCodeUrl);
            }
            ///推广关注的奖励设置入 触点活动数据表
            if (para.ContactPrizeList != null && para.ContactPrizeList.Count > 0)
            {
                SaveContactPrize(para, bllPrize, strStartDate, strEndDate);
            }
            string strOnlineQRCodeId     = string.Empty;
            string strOfflineQRCodeId    = string.Empty;
            string strOnlineQRCodeUrl    = string.Empty;
            string strOfflineQRCodeUrl   = string.Empty;
            string strOnlineRedirectUrl  = string.Empty;
            string strOfflineRedirectUrl = string.Empty;

            var WQRCodeManagerbll = new WQRCodeManagerBLL(loggingSessionInfo);

            if (!string.IsNullOrEmpty(para.OfflineQRCodeId))
            {
                WQRCodeManagerbll.Delete(new WQRCodeManagerEntity()
                {
                    QRCodeId = new Guid(para.OfflineQRCodeId)
                });
            }
            if (!string.IsNullOrEmpty(para.OnlineQRCodeId))
            {
                WQRCodeManagerbll.Delete(new WQRCodeManagerEntity()
                {
                    QRCodeId = new Guid(para.OnlineQRCodeId)
                });
            }
            CreateQRCode(para, wapentity, strPageParamJson, out strOfflineQRCodeId, out strOfflineQRCodeUrl, out strOfflineRedirectUrl);
            CreateH5QRCode(para, wapentity, out strOnlineQRCodeId, out strOnlineQRCodeUrl, out strOnlineRedirectUrl);

            rd.OfflineQRCodeUrl   = strOfflineQRCodeUrl;
            rd.OnlineQRCodeUrl    = strOnlineQRCodeUrl;
            rd.OfflineRedirectUrl = strOfflineRedirectUrl;
            rd.OnlineRedirectUrl  = strOnlineRedirectUrl;//strFocesQRCodeUrl;

            if (entityCustomerEvent != null)
            {   //活动主表
                entityCustomerEvent.Name               = para.TemplateName;
                entityCustomerEvent.Desc               = para.TemplateDesc;
                entityCustomerEvent.InteractionType    = para.InteractionType;
                entityCustomerEvent.ActivityGroupId    = new Guid(para.ActivityGroupId);
                entityCustomerEvent.ImageURL           = para.TemplateImageURL;
                entityCustomerEvent.StartDate          = Convert.ToDateTime(strStartDate);
                entityCustomerEvent.EndDate            = Convert.ToDateTime(strEndDate);
                entityCustomerEvent.OnlineQRCodeId     = strOnlineQRCodeId;
                entityCustomerEvent.OfflineQRCodeId    = strOfflineQRCodeId;
                entityCustomerEvent.OffLineRedirectUrl = strOfflineRedirectUrl;
                entityCustomerEvent.OnLineRedirectUrl  = strOnlineRedirectUrl;
                bllCustomerEvent.Update(entityCustomerEvent);
            }
            else
            {
                entityCustomerEvent = new T_CTW_LEventEntity()
                {
                    CTWEventId         = new Guid(para.CTWEventId),
                    TemplateId         = new Guid(para.TemplateId),
                    Name               = para.TemplateName,
                    Desc               = para.TemplateDesc,
                    ActivityGroupId    = new Guid(para.ActivityGroupId),
                    InteractionType    = para.InteractionType,
                    ImageURL           = para.TemplateImageURL,
                    Status             = 10,
                    CustomerId         = loggingSessionInfo.ClientID,
                    StartDate          = Convert.ToDateTime(strStartDate),
                    EndDate            = Convert.ToDateTime(strEndDate),
                    OfflineQRCodeId    = strOfflineQRCodeId,
                    OnlineQRCodeId     = strOnlineQRCodeId,
                    OffLineRedirectUrl = strOfflineRedirectUrl,
                    OnLineRedirectUrl  = strOnlineRedirectUrl
                };
                bllCustomerEvent.Create(entityCustomerEvent);
            }
            return(rd);
        }
예제 #30
0
        public void CreateQRCode(SetCTWEventRP para, WApplicationInterfaceEntity wapentity, string strPageParamJson, out string strQRCode, out string QRCodeUrl, out string RedirectUrl)
        {
            #region 获取Page信息
            var pageBll = new SysPageBLL(loggingSessionInfo);

            //根据活动的抽奖方式获取:“HB” “BigDial“
            string strPageKey = string.Empty;
            switch (para.DrawMethodCode)
            {
            case "HB":
                strPageKey = "RedPacket";
                break;

            case "DZP":
                strPageKey = "BigDial";
                break;

            case "QN":
                strPageKey = "Questionnaire";
                break;

            default:
                strPageKey = "NewsActivityList";
                break;
            }
            #endregion
            #region 生成URL
            var    Domain  = ConfigurationManager.AppSettings["interfacehost"].Replace("http://", "");
            var    Domain1 = ConfigurationManager.AppSettings["interfacehost1"].Replace("http://", "");
            string URL     = string.Empty;

            #region 系统模块
            var page = pageBll.GetPageByCustomerIdAndPageKey(loggingSessionInfo.ClientID, strPageKey).SingleOrDefault();
            if (page == null)
            {
                throw new APIException("未找到Page信息")
                      {
                          ErrorCode = 341
                      }
            }
            ;
            string path        = string.Empty;                                                                           //要替换的路径
            string urlTemplate = page.URLTemplate;                                                                       //模板URL
            string json        = page.JsonValue;                                                                         // JSON体
            var    jsonDic     = json.DeserializeJSONTo <Dictionary <string, object> >();                                //转换后的字典
            var    htmls       = jsonDic["htmls"].ToJSON().DeserializeJSONTo <Dictionary <string, object>[]>().ToList(); //htmls是一个数组,里面有他的很多属性
            Dictionary <string, object> html = null;                                                                     //选择的html信息
            var defaultHtmlId = jsonDic["defaultHtml"].ToString();
            html = htmls.Find(t => t["id"].ToString() == defaultHtmlId);                                                 //默认的htmlid*****
            if (html != null)
            {
                path = html["path"].ToString();
            }
            //判断高级oauth认证
            var scope = "snsapi_userinfo";
            //if (jsonDic.ContainsKey("scope"))//必须要判断key里是否包含scope
            //{
            //    scope = (jsonDic["scope"] == null || jsonDic["scope"].ToString() == "") ? "snsapi_base" : "snsapi_userinfo";
            //}

            //判断是否有定制,没有则取JSON体中的默认
            //找出订制内容
            if (page != null)
            {
                //看是否有htmls的定制(Node值=2)
                if (page.Node == "2")
                {
                    var nodeValue = page.NodeValue;
                    //在Json解析后的集合中找到path
                    html = htmls.Find(t => t["id"].ToString() == nodeValue);
                    if (html != null)
                    {
                        path = html["path"].ToString();
                    }
                }
            }

            //读取配置信息域名,检查不用http://开头,如果有则去除
            var IsAuth = false;
            //TODO:判断页面是否需要Auth认证,如果页面需要证则再判断这个客户有没有Auth认证,Type=3
            if (page.IsAuth == 1)
            {
                //判断这个客户是否是认证客户,type=3
                var applicationBll = new WApplicationInterfaceBLL(loggingSessionInfo);
                var application    = applicationBll.GetByID(wapentity.ApplicationId);//取默认的第一个
                if (application.WeiXinTypeId == "3")
                {
                    IsAuth = true;
                }
            }

            //替换URL模板
            #region 替换URL模板
            urlTemplate = urlTemplate.Replace("_pageName_", path); //用path替换掉_pageName_***(可以查看红包或者客服的path信息即可以知道)
            var paraDic = strPageParamJson.DeserializeJSONTo <Dictionary <string, object>[]>();
            foreach (var item in paraDic)                          //这里key和value对于活动来说,其实就是活动的eventId,和eventId的值
            {
                if (item.ContainsKey("key") && item.ContainsKey("value"))
                {
                    urlTemplate = urlTemplate.Replace("{" + item["key"] + "}", item["value"].ToString());
                }
            }

            #endregion

            //根据规则组织URL
            #region 组织URL
            //读取配置文件中的域名

            if (string.IsNullOrEmpty(Domain))
            {
                throw new APIException("微信管理:未配置域名,请在web.config中添加<add key='host' value=''/>")
                      {
                          ErrorCode = 342
                      }
            }
            ;
            if (IsAuth)
            {
                //需要认证(传参数时,需要传递applicationId,对于一个商户有多个微信服务号的,不能取默认的第一个,而是精确地取固定的微信服务号)
                //通过urlTemplate(用path替换了_pageName_),生成了goUrl
                URL = string.Format("http://{0}/WXOAuth/AuthUniversal.aspx?customerId={1}&applicationId={2}&goUrl={3}&scope={4}", Domain.Trim('/'), loggingSessionInfo.ClientID, wapentity.ApplicationId, HttpUtility.UrlEncode(string.Format("{0}{1}", Domain.Trim('/'), urlTemplate)), scope);
            }
            else
            {
                //不需要认证
                URL = string.Format("http://{0}/WXOAuth/NoAuthGoto.aspx?customerId={1}&goUrl={2}", Domain.Trim('/'), loggingSessionInfo.ClientID, HttpUtility.UrlEncode(string.Format("{0}{1}", Domain.Trim('/'), urlTemplate.Trim('/'))));
            }
            RedirectUrl = URL;
            #endregion
            #endregion

            #endregion
            string sourcePath    = HttpContext.Current.Server.MapPath("/QRCodeImage/qrcode.jpg");
            string targetPath    = HttpContext.Current.Server.MapPath("/QRCodeImage/");
            string currentDomain = "http://" + HttpContext.Current.Request.Url.Host;//当前项目域名

            QRCodeUrl = Utils.GenerateQRCode(URL, currentDomain, sourcePath, targetPath);

            ObjectImagesBLL    bllObjectImages    = new ObjectImagesBLL(loggingSessionInfo);
            ObjectImagesEntity entityObjectImages = new ObjectImagesEntity();

            entityObjectImages = new ObjectImagesEntity()
            {
                ImageId     = Utils.NewGuid(),
                CustomerId  = loggingSessionInfo.ClientID,
                ImageURL    = QRCodeUrl,
                ObjectId    = strCTWEventId,
                Title       = "",
                Description = "创意仓库活动二维码"
            };
            //把下载下来的图片的地址存到ObjectImages
            bllObjectImages.Create(entityObjectImages);
            strQRCode = entityObjectImages.ImageId.ToString();
        }