Ejemplo n.º 1
0
        public static string ReturnUrlByUser(MemberInfo mInfo)
        {
            string           str = HttpContext.Current.Request.Url.PathAndQuery.ToString();
            DistributorsInfo currentDistributors = DistributorsBrower.GetCurrentDistributors(Convert.ToInt32(mInfo.UserId));

            if (currentDistributors != null)
            {
                SetReferralIdCookie(currentDistributors.UserId.ToString(), "", false);
            }
            else
            {
                if (string.IsNullOrEmpty(mInfo.wid))
                {
                    ClearReferralIdCookie();
                    ClearUserCookie("", false);
                    ClearWidCookie("", false);
                    ReturnUrlByQueryString();
                }
                else
                {
                    SetReferralIdCookie(mInfo.ReferralUserId.ToString(), "", false);
                    SetWidCookie(mInfo.wid);
                }
            }
            HttpCookie cookie = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];

            if ((cookie != null) && !string.IsNullOrEmpty(cookie.Value))
            {
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["ReferralId"]))
                {
                    HiUriHelp help        = new HiUriHelp(HttpContext.Current.Request.Url.Query);
                    string    queryString = help.GetQueryString("ReferralId");
                    if (!string.IsNullOrEmpty(queryString))
                    {
                        if (queryString == cookie.Value)
                        {
                            return(string.Empty);
                        }
                        help.SetQueryString("ReferralId", cookie.Value);
                        return(HttpContext.Current.Request.Url.AbsolutePath + help.GetNewQuery());
                    }
                }
                if (!HttpContext.Current.Request.QueryString.AllKeys.Contains("returnUrl"))
                {
                    if (HttpContext.Current.Request.Url.AbsolutePath == "/logout.aspx")
                    {
                        return(string.Empty);
                    }
                    if (!HttpContext.Current.Request.QueryString.AllKeys.Contains("ReferralId") && (HttpContext.Current.Request.QueryString.Count > 0))
                    {
                        return(str + "&ReferralId=" + cookie.Value);
                    }
                    if (!HttpContext.Current.Request.QueryString.AllKeys.Contains("ReferralId"))
                    {
                        return(str + "?ReferralId=" + cookie.Value);
                    }
                }
            }
            return(string.Empty);
        }
Ejemplo n.º 2
0
        public static string ReturnUrlByUser(MemberInfo mInfo)
        {
            string           str = HttpContext.Current.Request.Url.PathAndQuery.ToString();
            DistributorsInfo currentDistributors = DistributorsBrower.GetCurrentDistributors(Globals.ToNum(mInfo.UserId), true);

            if (currentDistributors != null)
            {
                HiAffiliation.SetReferralIdCookie(currentDistributors.UserId.ToString(), "", false);
            }
            else
            {
                HiAffiliation.SetReferralIdCookie(mInfo.ReferralUserId.ToString(), "", false);
            }
            HttpCookie httpCookie = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];
            string     result;

            if (httpCookie != null && !string.IsNullOrEmpty(httpCookie.Value))
            {
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["ReferralId"]))
                {
                    HiUriHelp hiUriHelp   = new HiUriHelp(HttpContext.Current.Request.QueryString);
                    string    queryString = hiUriHelp.GetQueryString("ReferralId");
                    if (!string.IsNullOrEmpty(queryString))
                    {
                        if (queryString == httpCookie.Value)
                        {
                            result = string.Empty;
                            return(result);
                        }
                        hiUriHelp.SetQueryString("ReferralId", httpCookie.Value);
                        result = HttpContext.Current.Request.Url.AbsolutePath + hiUriHelp.GetNewQuery();
                        return(result);
                    }
                }
                if (((IList)HttpContext.Current.Request.QueryString.AllKeys).Contains("returnUrl"))
                {
                    result = string.Empty;
                }
                else if (HttpContext.Current.Request.Url.AbsolutePath == "/logout.aspx")
                {
                    result = string.Empty;
                }
                else if (!((IList)HttpContext.Current.Request.QueryString.AllKeys).Contains("ReferralId") && HttpContext.Current.Request.QueryString.Count > 0)
                {
                    result = str + "&ReferralId=" + httpCookie.Value;
                }
                else if (!((IList)HttpContext.Current.Request.QueryString.AllKeys).Contains("ReferralId"))
                {
                    result = str + "?ReferralId=" + httpCookie.Value;
                }
                else
                {
                    result = string.Empty;
                }
            }
            else
            {
                result = string.Empty;
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据当前用户获取当前页是否跳转
        /// </summary>
        public static string ReturnUrlByUser(MemberInfo mInfo)
        {
            //设置当前用户访问的店铺CookieID
            DistributorsInfo currentDistributors = DistributorsBrower.GetCurrentDistributors(Globals.ToNum(mInfo.UserId), true);

            if (currentDistributors != null)
            {
                HiAffiliation.SetReferralIdCookie(currentDistributors.UserId.ToString(), "", false);
            }
            else
            {
                HiAffiliation.SetReferralIdCookie(mInfo.ReferralUserId.ToString(), "", false);
            }

            //设置跳转地址
            HttpCookie httpCookie = HttpContext.Current.Request.Cookies["Vshop-ReferralId"];
            string     result;
            string     str = HttpContext.Current.Request.Url.PathAndQuery.ToString();

            if (httpCookie != null && !string.IsNullOrEmpty(httpCookie.Value))
            {
                if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["ReferralId"]))
                {
                    HiUriHelp hiUriHelp   = new HiUriHelp(HttpContext.Current.Request.QueryString);
                    string    queryString = hiUriHelp.GetQueryString("ReferralId");

                    if (!string.IsNullOrEmpty(queryString))
                    {
                        if (queryString == httpCookie.Value)
                        {
                            result = string.Empty;
                            return(result);
                        }

                        //如果访问的店铺不是平台,但之前存储的店铺是平台时,强制更改【V20170906】
                        if (queryString != "0" && httpCookie.Value == "0")
                        {
                            int iReferralUserId = 0;
                            int.TryParse(queryString, out iReferralUserId);
                            MemberInfo currentMember = MemberProcessor.GetCurrentMember();
                            currentMember.ReferralUserId = iReferralUserId;
                            MemberProcessor.UpdateMember(currentMember);
                            HiAffiliation.SetReferralIdCookie(queryString, "", false);
                        }

                        hiUriHelp.SetQueryString("ReferralId", httpCookie.Value);
                        result = HttpContext.Current.Request.Url.AbsolutePath + hiUriHelp.GetNewQuery();

                        return(result);
                    }
                }
                if (((IList)HttpContext.Current.Request.QueryString.AllKeys).Contains("returnUrl"))
                {
                    result = string.Empty;
                }
                else if (HttpContext.Current.Request.Url.AbsolutePath == "/logout.aspx")
                {
                    result = string.Empty;
                }
                else if (!((IList)HttpContext.Current.Request.QueryString.AllKeys).Contains("ReferralId") && HttpContext.Current.Request.QueryString.Count > 0)
                {
                    result = str + "&ReferralId=" + httpCookie.Value;
                }
                else if (!((IList)HttpContext.Current.Request.QueryString.AllKeys).Contains("ReferralId"))
                {
                    result = str + "?ReferralId=" + httpCookie.Value;
                }
                else
                {
                    result = string.Empty;
                }
            }
            else
            {
                result = string.Empty;
            }
            return(result);
        }