コード例 #1
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            OrderHelper.SetDynamicLandingPageVersion(OrderHelper.GetVersionName(), ClientOrderData);
            if (CartContext != null && CartContext.RequestParam.Equals(""))
            {
                if (Request.QueryString.Count > 0)
                {
                    CartContext.RequestParam = CommonHelper.GetQueryString(Request.RawUrl);
                }
                else if (Response.Cookies["sid"] != null && Response.Cookies["sid"].Value != null)
                {
                    CartContext.RequestParam = "?sid=" + Response.Cookies["sid"].Value;
                }
            }
            ClientCartContext clientData = (ClientCartContext)Session["ClientOrderData"];

            if (!Page.IsPostBack)
            {
                string version    = OrderHelper.GetVersionName().ToLower();
                string strTermUrl = "";
                strTermUrl = Request.Url.ToString().ToLower().Replace(":81", "");
                //if (version.Equals("mobile_b2"))
                //{
                //    Response.RedirectPermanent(strTermUrl.Replace("/mobile_b2/", "/mobile_a1/"));
                //}

                SitePreference sitePrefCache = CSFactory.GetCacheSitePref();
                if (!sitePrefCache.GeoLocationService)
                {
                    string GeoCoountry = "";
                    GeoCoountry = CommonHelper.GetGeoTargetLocation(CommonHelper.IpAddress(HttpContext.Current));
                }

                if (Request["versionlp"] != null)
                {
                    Version = Request["versionlp"].ToString();
                    if (clientData.OrderAttributeValues != null)
                    {
                        if (clientData.OrderAttributeValues.ContainsKey("DynamicVerionName"))
                        {
                            Version = clientData.OrderAttributeValues["DynamicVerionName"].Value;
                        }
                        else
                        {
                            clientData.OrderAttributeValues.Add("DynamicVerionName", new AttributeValue(Version));
                        }
                    }
                }
                OrderHelper.RedirectMobile();
                OrderHelper.SetDynamicLandingPageVersion(Version, clientData);

                if (CartContext != null && CartContext.RequestParam.Equals(""))
                {
                    if (Request.QueryString.Count > 0)
                    {
                        CartContext.RequestParam = CommonHelper.GetQueryString(Request.RawUrl);
                    }
                    else if (Response.Cookies["sid"] != null)
                    {
                        CartContext.RequestParam = "?sid=" + Response.Cookies["sid"].Value;
                    }
                }
                else if (CartContext != null && Request.QueryString.Count > 0 && !CartContext.RequestParam.ToLower().Equals(CommonHelper.GetQueryString(Request.RawUrl).ToLower()))
                {
                    CartContext.RequestParam = CommonHelper.GetQueryString(Request.RawUrl);
                }
                OrderHelper.SetDynamicLandingPageVersion(OrderHelper.GetVersionName(), ClientOrderData);
                var qs = HttpUtility.ParseQueryString(Request.QueryString.ToString());
                if (Request["sid"] != null)
                {
                    string sid    = Request["sid"].ToLower();
                    string newSid = OrderHelper.getMobileSid(sid);
                    if (!sid.Equals(newSid))
                    {
                        CommonHelper.SetCookie("sid", newSid, new TimeSpan(1, 24, 1, 1));
                        qs.Remove("sid");
                        qs.Set("sid", newSid);
                        if (Request.RawUrl.Contains("?"))
                        {
                            Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf('?')) + "?" + qs);
                        }
                        else
                        {
                            Response.Redirect(Request.RawUrl + "?" + qs);
                        }
                    }
                }



                // versionName used in Header.ascx

                string versioName = OrderHelper.GetVersionName().ToLower();

                if (Request["sid"] == null || Request["sid"].Equals(""))
                {
                    string sid = OrderHelper.GetDynamicVersionData("sid");
                    if (sid.Length > 0)
                    {
                        CommonHelper.SetCookie("sid", sid, new TimeSpan(1, 24, 1, 1));
                        qs.Set("sid", sid);
                        if (Request.RawUrl.Contains("?"))
                        {
                            Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf('?')) + "?" + qs);
                        }
                        else
                        {
                            Response.Redirect(Request.RawUrl + "?" + qs);
                        }
                    }
                }
                else if (Response.Cookies["sid"] != null && Response.Cookies["sid"].Value != null && Response.Cookies["sid"].Value.Equals("1"))
                {
                    string sid = OrderHelper.GetDynamicVersionData("sid");
                    if (sid.Length > 0)
                    {
                        CommonHelper.SetCookie("sid", sid, new TimeSpan(1, 24, 1, 1));
                        qs.Set("sid", sid);
                        if (Request.RawUrl.Contains("?"))
                        {
                            Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf('?')) + "?" + qs);
                        }
                        else
                        {
                            Response.Redirect(Request.RawUrl + "?" + qs);
                        }
                    }
                }
                else if (Request["sid"] != null && DynamicSidDAL.GetDynamicsid(Request["sid"].ToLower()).Count == 0)
                {
                    string sid = OrderHelper.GetDynamicVersionData("sid");
                    if (sid.Length > 0)
                    {
                        CommonHelper.SetCookie("sid", sid, new TimeSpan(1, 24, 1, 1));
                        qs.Set("sid", sid);
                        if (Request.RawUrl.Contains("?"))
                        {
                            Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf('?')) + "?" + qs);
                        }
                        else
                        {
                            Response.Redirect(Request.RawUrl + "?" + qs);
                        }
                    }
                }
                else if (Request["sid"] != null && DynamicSidDAL.GetDynamicsid(Request["sid"].ToLower()).Count == 0 && !Request["sid"].ToLower().Equals(OrderHelper.GetDynamicVersionData("sid").ToLower()))
                {
                    string sid = OrderHelper.GetDynamicVersionData("sid");
                    if (sid.Length > 0)
                    {
                        CommonHelper.SetCookie("sid", sid, new TimeSpan(1, 24, 1, 1));
                        qs.Remove("sid");
                        qs.Set("sid", sid);
                        if (Request.RawUrl.Contains("?"))
                        {
                            Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf('?')) + "?" + qs);
                        }
                        else
                        {
                            Response.Redirect(Request.RawUrl + "?" + qs);
                        }
                    }
                }
            }
        }
コード例 #2
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            if (!IsPostBack)
            {
                if (CSBasePage.GetClientDeviceType() == CSBusiness.Enum.DeviceType.Mobile)
                {
                    OrderHelper.MobileRedirect();
                }

                string version    = OrderHelper.GetVersionName().ToLower();
                string strTermUrl = "";
                strTermUrl = Request.Url.ToString().ToLower().Replace(":81", "");
                OrderHelper.RedirectDesktop();

                OrderHelper.SetDynamicLandingPageVersion(OrderHelper.GetVersionName(), ClientOrderData);
                // versionName used in Header.ascx

                string versioName = OrderHelper.GetVersionName().ToLower();
                var    qs         = HttpUtility.ParseQueryString(Request.QueryString.ToString());
                if (Request["sid"] == null || Request["sid"].Equals(""))
                {
                    string sid = OrderHelper.GetDynamicVersionData("sid");
                    if (sid.Length > 0)
                    {
                        CommonHelper.SetCookie("sid", sid, new TimeSpan(1, 24, 1, 1));
                        qs.Set("sid", sid);
                        if (Request.RawUrl.Contains("?"))
                        {
                            Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf('?')) + "?" + qs);
                        }
                        else
                        {
                            Response.Redirect(Request.RawUrl + "?" + qs);
                        }
                    }
                }
                else if (Response.Cookies["sid"] != null && Response.Cookies["sid"].Value != null && Response.Cookies["sid"].Value.Equals("1"))
                {
                    string sid = OrderHelper.GetDynamicVersionData("sid");
                    if (sid.Length > 0)
                    {
                        CommonHelper.SetCookie("sid", sid, new TimeSpan(1, 24, 1, 1));
                        qs.Set("sid", sid);
                        if (Request.RawUrl.Contains("?"))
                        {
                            Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf('?')) + "?" + qs);
                        }
                        else
                        {
                            Response.Redirect(Request.RawUrl + "?" + qs);
                        }
                    }
                }
                else if (Request["sid"] != null && DynamicSidDAL.GetDynamicsid(Request["sid"].ToLower()).Count == 0)
                {
                    string sid = OrderHelper.GetDynamicVersionData("sid");
                    if (sid.Length > 0)
                    {
                        CommonHelper.SetCookie("sid", sid, new TimeSpan(1, 24, 1, 1));
                        qs.Set("sid", sid);
                        if (Request.RawUrl.Contains("?"))
                        {
                            Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf('?')) + "?" + qs);
                        }
                        else
                        {
                            Response.Redirect(Request.RawUrl + "?" + qs);
                        }
                    }
                }
                else if (Request["sid"] != null && DynamicSidDAL.GetDynamicsid(Request["sid"].ToLower()).Count == 0 && !Request["sid"].ToLower().Equals(OrderHelper.GetDynamicVersionData("sid").ToLower()))
                {
                    string sid = OrderHelper.GetDynamicVersionData("sid");
                    if (sid.Length > 0)
                    {
                        CommonHelper.SetCookie("sid", sid, new TimeSpan(1, 24, 1, 1));
                        qs.Remove("sid");
                        qs.Set("sid", sid);
                        if (Request.RawUrl.Contains("?"))
                        {
                            Response.Redirect(Request.RawUrl.Substring(0, Request.RawUrl.IndexOf('?')) + "?" + qs);
                        }
                        else
                        {
                            Response.Redirect(Request.RawUrl + "?" + qs);
                        }
                    }
                }
            }
        }