コード例 #1
0
        protected override void OnPreInit(EventArgs e)
        {
            if (HttpContext.Current != null)
            {
                //Have to call GetPropertyValue once before you actually need it to initialize the PropertyValues collection
                HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString();

                #region SkinID
                //If it's mobile, bypass all the rest
                if (!AppLogic.IsAdminSite && MobileHelper.isMobile())
                {
                    MobileHelper.SetCustomerToMobileSkinId(ThisCustomer);
                    SkinID = ThisCustomer.SkinID;
                }
                else
                {
                    //SkinId querystring overrides everything but mobile
                    if (CommonLogic.QueryStringUSInt("skinid") > 0)
                    {
                        SkinID = CommonLogic.QueryStringUSInt("skinid");

                        //Customer has a querystring so save this to the profile.
                        if (HttpContext.Current.Profile != null)
                        {
                            HttpContext.Current.Profile.SetPropertyValue("SkinID", this.SkinID.ToString());
                        }
                    }
                    //Check to see if we are previewing the skin
                    else if (CommonLogic.QueryStringUSInt("previewskinid") > 0)
                    {
                        SkinID = CommonLogic.QueryStringUSInt("previewskinid");

                        //Customer has a preview querystring so save this to the profile.
                        if (HttpContext.Current.Profile != null)
                        {
                            HttpContext.Current.Profile.SetPropertyValue("PreviewSkinID", this.SkinID.ToString());
                        }
                    }
                    //Use the preview profile value if we have one
                    else if (HttpContext.Current.Profile != null &&
                             HttpContext.Current.Profile.PropertyValues["PreviewSkinID"] != null &&
                             CommonLogic.IsInteger(HttpContext.Current.Profile.GetPropertyValue("PreviewSkinID").ToString()))
                    {
                        int skinFromProfile = int.Parse(HttpContext.Current.Profile.GetPropertyValue("PreviewSkinID").ToString());
                        if (skinFromProfile > 0)
                        {
                            SkinID = skinFromProfile;
                        }
                    }
                    //Pull the skinid from the current profile
                    else if (HttpContext.Current.Profile != null && CommonLogic.IsInteger(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString()))
                    {
                        int skinFromProfile = int.Parse(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString());
                        if (skinFromProfile > 0)
                        {
                            SkinID = skinFromProfile;
                        }
                    }
                }

                //Now save the skinID to the customer record.  This is not used OOB.
                if (ThisCustomer.SkinID != this.SkinID)
                {
                    ThisCustomer.SkinID = this.SkinID;
                    ThisCustomer.UpdateCustomer(new SqlParameter[] { new SqlParameter("SkinID", this.SkinID) });
                }
                #endregion

                if (CommonLogic.QueryStringUSInt("affiliateid") > 0)
                {
                    HttpContext.Current.Profile.SetPropertyValue("AffiliateID", CommonLogic.QueryStringUSInt("affiliateid").ToString());
                }

                if (HttpContext.Current.Request.UrlReferrer != null && HttpContext.Current.Request.UrlReferrer.Authority != HttpContext.Current.Request.Url.Authority)
                {
                    HttpContext.Current.Profile.SetPropertyValue("Referrer", HttpContext.Current.Request.UrlReferrer.ToString());
                }

                // don't fire disclaimer logic on admin pages
                if (!AppLogic.IsAdminSite && CommonLogic.QueryStringCanBeDangerousContent("ReturnURL").IndexOf(AppLogic.AppConfig("AdminDir")) == -1 && (AppLogic.AppConfigBool("SiteDisclaimerRequired") && CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true).Length == 0))
                {
                    String ThisPageURL = CommonLogic.GetThisPageName(true) + "?" + CommonLogic.ServerVariables("QUERY_STRING");
                    Response.Redirect("disclaimer.aspx?returnURL=" + Server.UrlEncode(ThisPageURL));
                }

                #region Impersonation
                bool IGDQueryClear = false;
                m_IGD = CommonLogic.QueryStringCanBeDangerousContent("IGD").Trim();
                if (m_IGD.Length == 0 && CommonLogic.ServerVariables("QUERY_STRING").IndexOf("IGD=") != -1)
                {
                    m_IGD         = String.Empty; // there was IGD={blank} in the query string, so forcefully clear IGD!
                    IGDQueryClear = true;
                }
                bool IsStartOfImpersonation = m_IGD.Length != 0; // the url invocation starts the impersonation only!

                if (!IGDQueryClear && m_IGD.Length == 0)
                {
                    if (ThisCustomer.IsAdminUser)
                    {
                        // pull out the impersonation IGD from the customer session, if any
                        m_IGD = ThisCustomer.ThisCustomerSession["IGD"];
                    }
                }

                if (IGDQueryClear)
                {
                    // forcefully clear any IGD for this customer, just to be safe!
                    ThisCustomer.ThisCustomerSession["IGD"] = "";
                    ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                }

                Customer PhoneCustomer = null;
                if (m_IGD.Length != 0)
                {
                    if (ThisCustomer.IsAdminUser)
                    {
                        try
                        {
                            Guid IGD = new Guid(m_IGD);
                            PhoneCustomer = new Customer(IGD);
                            PhoneCustomer.IsImpersonated = true;
                        }
                        catch
                        {
                            ThisCustomer.ThisCustomerSession["IGD"] = "";
                            ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                            m_IGD = string.Empty;
                        }
                    }
                    if (PhoneCustomer != null && PhoneCustomer.HasCustomerRecord)
                    {
                        int ImpersonationTimeoutInMinutes = AppLogic.AppConfigUSInt("ImpersonationTimeoutInMinutes");
                        if (ImpersonationTimeoutInMinutes == 0)
                        {
                            ImpersonationTimeoutInMinutes = 20;
                        }
                        if (PhoneCustomer.ThisCustomerSession.LastActivity >= DateTime.Now.AddMinutes(-ImpersonationTimeoutInMinutes))
                        {
                            ThisCustomer.ThisCustomerSession["IGD"] = IGD;
                            m_AdminCustomer = ThisCustomer;  // save the owning admin user doing the impersonation here
                            ThisCustomer    = PhoneCustomer; // build the impersonation customer the phone order customer
                            bool IsAdmin = CommonLogic.ApplicationBool("IsAdminSite");

                            if (!HttpContext.Current.Items.Contains("IsBeingImpersonated"))
                            {
                                HttpContext.Current.Items.Add("IsBeingImpersonated", "true");
                            }
                        }
                        else
                        {
                            if (HttpContext.Current.Items.Contains("IsBeingImpersonated"))
                            {
                                HttpContext.Current.Items["IsBeingImpersonated"] = "false";
                            }
                            ThisCustomer.ThisCustomerSession["IGD"] = "";
                            ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                            m_IGD = string.Empty;
                            //Response.Redirect("t-phoneordertimeout.aspx");
                            Response.Redirect(SE.MakeDriverLink("phoneordertimeout"));
                        }
                    }
                }
                #endregion

                Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(Localization.GetDefaultLocale());
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(ThisCustomer.LocaleSetting);

                m_TemplateName = GetTemplateName();

                if (!AppLogic.IsAdminSite)
                {
                    ThisCustomer = MobileRedirectController.SkinBaseHook(SkinID, ThisCustomer);
                    if (SkinID == Vortx.Data.Config.MobilePlatform.SkinId && MobileHelper.isMobile())
                    {
                        m_TemplateName = "template.master";
                    }
                }

                //needs to come after the mobile check
                m_Parser = new Parser(m_EntityHelpers, SkinID, ThisCustomer);

                String SkinDirectory = String.Empty;
                String PageTheme     = String.Empty;

                SkinDirectory = "Skin_" + this.SkinID.ToString();
                PageTheme     = "Skin_" + this.SkinID.ToString();

                if (!m_TemplateName.EndsWith(".master", StringComparison.OrdinalIgnoreCase))
                {
                    m_TemplateName = m_TemplateName + ".master";
                }

                this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName;
                this.Theme          = PageTheme;

                if (!CommonLogic.FileExists(this.MasterPageFile))
                {
                    this.SkinID = AppLogic.DefaultSkinID();

                    m_TemplateName = "template.master";
                    SkinDirectory  = "Skin_" + this.SkinID.ToString();
                    PageTheme      = "Skin_" + this.SkinID.ToString();

                    this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName;
                    this.Theme          = PageTheme;
                }
            }

            base.OnPreInit(e);
        }
コード例 #2
0
        protected override void OnPreInit(EventArgs e)
        {
            if (HttpContext.Current != null)
            {
                m_ThisCustomer = ((AspDotNetStorefrontPrincipal)Context.User).ThisCustomer;


                int StoreID = AppLogic.StoreID();
                m_SkinID = AppLogic.GetStoreSkinID(StoreID);

                //TODO: review this
                if (CommonLogic.IsInteger(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString()))
                {
                    int skinFromProfile = int.Parse(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString());
                    if (skinFromProfile > 0)
                    {
                        m_SkinID = skinFromProfile;
                    }
                }
                else if (AppLogic.AppConfig("Signin.SkinMaster").EqualsIgnoreCase("session"))
                {
                    m_SkinID = m_ThisCustomer.DBSkinID;
                }

                if (CommonLogic.QueryStringUSInt("skinid") > 0)
                {
                    m_SkinID = CommonLogic.QueryStringUSInt("skinid");
                }

                if (CommonLogic.QueryStringUSInt("affiliateid") > 0)
                {
                    HttpContext.Current.Profile.SetPropertyValue("AffiliateID", CommonLogic.QueryStringUSInt("affiliateid").ToString());
                }

                if (HttpContext.Current.Request.UrlReferrer != null && HttpContext.Current.Request.UrlReferrer.Authority != HttpContext.Current.Request.Url.Authority)
                {
                    HttpContext.Current.Profile.SetPropertyValue("Referrer", HttpContext.Current.Request.UrlReferrer.ToString());
                }


                if (AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("GoogleCheckout.ShowOnCartPage"))
                {
                    String s = (String)HttpContext.Current.Cache.Get("GCCallbackLoadCheck");
                    if (s == null)
                    {
                        String notused = CommonLogic.AspHTTP(AppLogic.GetStoreHTTPLocation(false) + "gccallback.aspx?loadcheck=1", 10);
                        HttpContext.Current.Cache.Insert("GCCallbackLoadCheck", "true", null, System.DateTime.Now.AddMinutes(5), TimeSpan.Zero);
                    }
                }

                // don't fire disclaimer logic on admin pages
                if (!AppLogic.IsAdminSite && CommonLogic.QueryStringCanBeDangerousContent("ReturnURL").IndexOf(AppLogic.AppConfig("AdminDir")) == -1 && (AppLogic.AppConfigBool("SiteDisclaimerRequired") && CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true).Length == 0))
                {
                    String ThisPageURL = CommonLogic.GetThisPageName(true) + "?" + CommonLogic.ServerVariables("QUERY_STRING");
                    Response.Redirect("disclaimer.aspx?returnURL=" + Server.UrlEncode(ThisPageURL));
                }

                bool IGDQueryClear = false;
                m_IGD = CommonLogic.QueryStringCanBeDangerousContent("IGD").Trim();
                if (m_IGD.Length == 0 && CommonLogic.ServerVariables("QUERY_STRING").IndexOf("IGD=") != -1)
                {
                    m_IGD         = String.Empty; // there was IGD={blank} in the query string, so forcefully clear IGD!
                    IGDQueryClear = true;
                }
                bool IsStartOfImpersonation = m_IGD.Length != 0; // the url invocation starts the impersonation only!

                if (!IGDQueryClear && m_IGD.Length == 0)
                {
                    if (m_ThisCustomer.IsAdminUser)
                    {
                        // pull out the impersonation IGD from the customer session, if any
                        m_IGD = m_ThisCustomer.ThisCustomerSession["IGD"];
                    }
                }

                if (IGDQueryClear)
                {
                    // forcefully clear any IGD for this customer, just to be safe!
                    m_ThisCustomer.ThisCustomerSession["IGD"] = "";
                    m_ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                }

                Customer PhoneCustomer = null;
                if (m_IGD.Length != 0)
                {
                    if (m_ThisCustomer.IsAdminUser)
                    {
                        try
                        {
                            Guid IGD = new Guid(m_IGD);
                            PhoneCustomer = new Customer(IGD);
                            PhoneCustomer.IsImpersonated = true;
                        }
                        catch
                        {
                            m_ThisCustomer.ThisCustomerSession["IGD"] = "";
                            m_ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                            m_IGD = string.Empty;
                        }
                    }
                    if (PhoneCustomer != null && PhoneCustomer.HasCustomerRecord)
                    {
                        int ImpersonationTimeoutInMinutes = AppLogic.AppConfigUSInt("ImpersonationTimeoutInMinutes");
                        if (ImpersonationTimeoutInMinutes == 0)
                        {
                            ImpersonationTimeoutInMinutes = 20;
                        }
                        if (PhoneCustomer.ThisCustomerSession.LastActivity >= DateTime.Now.AddMinutes(-ImpersonationTimeoutInMinutes))
                        {
                            m_ThisCustomer.ThisCustomerSession["IGD"] = IGD;
                            m_AdminCustomer = m_ThisCustomer; // save the owning admin user doing the impersonation here
                            m_ThisCustomer  = PhoneCustomer;  // build the impersonation customer the phone order customer
                            bool IsAdmin = CommonLogic.ApplicationBool("IsAdminSite");

                            if (!HttpContext.Current.Items.Contains("IsBeingImpersonated"))
                            {
                                HttpContext.Current.Items.Add("IsBeingImpersonated", "true");
                            }
                        }
                        else
                        {
                            if (HttpContext.Current.Items.Contains("IsBeingImpersonated"))
                            {
                                HttpContext.Current.Items["IsBeingImpersonated"] = "false";
                            }
                            m_ThisCustomer.ThisCustomerSession["IGD"] = "";
                            m_ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                            m_IGD = string.Empty;
                            //Response.Redirect("t-phoneordertimeout.aspx");
                            Response.Redirect(SE.MakeDriverLink("phoneordertimeout"));
                        }
                    }
                }

                Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(Localization.GetDefaultLocale());
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(ThisCustomer.LocaleSetting);

                m_Parser = new Parser(m_EntityHelpers, m_SkinID, m_ThisCustomer);

                m_TemplateName = GetTemplateName();

                #region Vortx Mobile Modification
                if (!AppLogic.IsAdminSite)
                {
                    m_ThisCustomer = MobileRedirectController.SkinBaseHook(SkinID, ThisCustomer);
                    SkinID         = ThisCustomer.SkinID;
                    if (SkinID == Vortx.Data.Config.MobilePlatform.SkinId && MobileHelper.isMobile())
                    {
                        m_TemplateName = "template.master";
                    }
                }
                #endregion

                String SkinDirectory = String.Empty;
                String PageTheme     = String.Empty;

                SkinDirectory = "Skin_" + this.SkinID.ToString();
                PageTheme     = "Skin_" + this.SkinID.ToString();

                if (!m_TemplateName.EndsWith(".master", StringComparison.OrdinalIgnoreCase))
                {
                    m_TemplateName = m_TemplateName + ".master";
                }

                this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName;
                this.Theme          = PageTheme;

                if (!CommonLogic.FileExists(this.MasterPageFile))
                {
                    this.SkinID = AppLogic.DefaultSkinID();

                    m_TemplateName = "template.master";
                    SkinDirectory  = "Skin_" + this.SkinID.ToString();
                    PageTheme      = "Skin_" + this.SkinID.ToString();

                    this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName;
                    this.Theme          = PageTheme;
                }

                HttpContext.Current.Profile.SetPropertyValue("SkinID", this.SkinID.ToString());

                if (ThisCustomer.SkinID != this.SkinID)
                {
                    ThisCustomer.SkinID = this.SkinID;
                    ThisCustomer.UpdateCustomer(new SqlParameter[] { new SqlParameter("SkinID", this.SkinID) });
                }
            }

            base.OnPreInit(e);
        }