Example #1
0
        protected override void OnPreInit(EventArgs e)
        {
            SkinID = CommonLogic.CookieUSInt(SkinBase.ro_SkinCookieName).ToString();

            RegisterScriptManager();
            RegisterStyles();
        }
Example #2
0
        private void RenderTopics()
        {
            var t = new Topic(CommonLogic.QueryStringCanBeDangerousContent("Topic"), ThisCustomer.LocaleSetting, ThisCustomer.SkinID, null);

            if (t.Contents.Length == 0)
            {
                pnlNoTopic.Visible  = true;
                lblNoTopicText.Text = AppLogic.GetString("popup.aspx.5", 1, Customer.Current.LocaleSetting);
            }
            else
            {
                pnlNoTopic.Visible = true;
                lblTopic.Text      = t.Contents.Replace("(!SKINID!)", CommonLogic.CookieUSInt(SkinBase.ro_SkinCookieName).ToString());
            }
        }
Example #3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            ThisCustomer = ((InterpriseSuiteEcommercePrincipal)Context.User).ThisCustomer;
            ThisCustomer.RequireCustomerRecord();
            _SkinID   = CommonLogic.CookieUSInt(SkinBase.ro_SkinCookieName);
            ProductID = CommonLogic.QueryStringUSInt("ProductID");
            ItemCode  = InterpriseHelper.GetInventoryItemCode(ProductID);
            String ProductName = HttpContext.Current.Server.HtmlEncode(AppLogic.GetProductName(ProductID.ToString(), ThisCustomer.LocaleSetting));
            String ReturnURL   = CommonLogic.QueryStringCanBeDangerousContent("ReturnURL");


            if (ReturnURL.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1)
            {
                throw new ArgumentException("SECURITY EXCEPTION");
            }

            using (SqlConnection con = DB.NewSqlConnection())
            {
                con.Open();
                using (IDataReader rs = DB.GetRSFormat(con, String.Format("SELECT * FROM EcommerceRating with (NOLOCK) WHERE CustomerCode={0} AND ItemCode={1} AND WebsiteCode={2} AND ContactCode={3}",
                                                                          DB.SQuote(ThisCustomer.CustomerCode), DB.SQuote(ItemCode), DB.SQuote(InterpriseHelper.ConfigInstance.WebSiteCode), DB.SQuote(ThisCustomer.ContactCode))))
                {
                    if (rs.Read())
                    {
                        TheirCurrentRating  = DB.RSFieldInt(rs, "Rating");
                        TheirCurrentComment = DB.RSField(rs, "Comments");
                        Editing             = true;
                    }
                }
            }

            if (!IsPostBack)
            {
                InitializePageContent();
            }
        }
Example #4
0
        public void LoadSkinTemplate()
        {
            SkinID = 1;
            if (m_IGD.Length != 0)
            {
                m_TemplateName = "empty.ascx"; // force override for admin phone order pages
            }
            if (m_TemplateName.Length == 0)
            {
                m_TemplateName = "template.ascx";
            }
            m_TemplateFN = string.Empty;
            if (m_TemplateName.Length != 0)
            {
                SkinID = CommonLogic.QueryStringUSInt("SkinID");

                if (SkinID == 0 && CommonLogic.QueryStringCanBeDangerousContent("AffiliateID").Length != 0)
                {
                    DataSet ds = DB.GetDS("Select DefaultSkinID from CustomerSalesRep with (NOLOCK) where SalesRepGroupCode=" + DB.SQuote(CommonLogic.QueryStringCanBeDangerousContent("AffiliateID")), AppLogic.CachingOn, System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()));
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        SkinID = DB.RowFieldInt(ds.Tables[0].Rows[0], "DefaultSkinID");
                    }
                    ds.Dispose();
                }
                if (SkinID == 0)
                {
                    SkinID = m_DefaultSkinID;
                }

                if (SkinID == 0)
                {
                    SkinID = CommonLogic.CookieUSInt(ro_SkinCookieName);
                }

                if (SkinID == 0)
                {
                    SkinID = 1;
                }

                AppLogic.SetCookie(ro_SkinCookieName, SkinID.ToString(), new TimeSpan(365, 0, 0, 0, 0));
                m_ThisCustomer.SkinID = SkinID;


                string LocaleTemplateURLCacheName    = string.Format("template_{0}_{1}_{1}", m_TemplateName, SkinID.ToString(), ThisCustomer.LocaleSetting);
                string WebLocaleTemplateURLCacheName = string.Format("template_{0}_{1}_{1}", m_TemplateName, SkinID.ToString(), Localization.WebConfigLocale);
                string TemplateURLCacheName          = string.Format("template_{0}_{1}_{1}", m_TemplateName, SkinID.ToString(), "");

                // try customer locale:

                string   webLocale     = Localization.WebConfigLocale;
                string   localeSetting = ThisCustomer.LocaleSetting;
                DateTime mins          = System.DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes());

                string _url = Path.Combine(SkinRoot, m_TemplateName.Replace(".ascx", "." + localeSetting + ".ascx"));
                m_TemplateFN = CommonLogic.SafeMapPath(_url);

                if (!CommonLogic.FileExists(m_TemplateFN))
                {
                    // try default store locale path:
                    _url         = Path.Combine(SkinRoot, m_TemplateName.Replace(".ascx", "." + webLocale + ".ascx"));
                    m_TemplateFN = CommonLogic.SafeMapPath(_url);
                }

                if (!CommonLogic.FileExists(m_TemplateFN))
                {
                    _url         = Path.Combine(SkinRoot, m_TemplateName);
                    m_TemplateFN = CommonLogic.SafeMapPath(_url);
                }

                if (AppLogic.CachingOn)
                {
                    HttpContext.Current.Cache.Insert(TemplateURLCacheName, _url, null, mins, TimeSpan.Zero);
                }

                if (_url != null && _url != string.Empty && !CommonLogic.FileExists(_url))
                {
                    SkinID = 1;

                    AppLogic.SetCookie(ro_SkinCookieName, SkinID.ToString(), new TimeSpan(365, 0, 0, 0, 0));
                    m_ThisCustomer.SkinID = SkinID;

                    // try customer locale:
                    _url = Path.Combine(SkinRoot, m_TemplateName.Replace(".ascx", "." + localeSetting + ".ascx"));

                    m_TemplateFN = _url.ToMapPath();
                    if (!CommonLogic.FileExists(m_TemplateFN))
                    {
                        // try default store locale path:
                        _url         = Path.Combine(SkinRoot, m_TemplateName.Replace(".ascx", "." + webLocale + ".ascx"));
                        m_TemplateFN = _url.ToMapPath();
                    }
                    if (!CommonLogic.FileExists(m_TemplateFN))
                    {
                        // try base (NULL) locale path:
                        _url         = Path.Combine(SkinRoot, m_TemplateName);
                        m_TemplateFN = _url.ToMapPath();
                    }
                    if (AppLogic.CachingOn)
                    {
                        HttpContext.Current.Cache.Insert(TemplateURLCacheName, _url, null, mins, TimeSpan.Zero);
                    }
                }
                try
                {
                    m_Template = (TemplateBase)LoadControl(_url);
                }
                catch { } // if defined template not FOUND...
            }
            if (m_Template != null)
            {
                m_Template.AppRelativeTemplateSourceDirectory = "~/"; // move it from skins/skin_N to root relative, so all links/image refs are from root of site
            }
        }
Example #5
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public void Page_Load(object sender, EventArgs e)
        {
            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                m_SkinBase.GoNonSecureAgain();
            }

            n = m_EntityHelper.m_TblMgr.SetContext(m_EntityInstanceID);
            //Determine if the entity is map to the current store.
            if (n == null)
            {
                HttpContext.Current.Server.Transfer("pagenotfound.aspx");
            }
            //Checking for multi store.
            CachelessStore store = new CachelessStore();

            store.StoreID = AppLogic.StoreID();
            MappedObject map = store.GetMapping(m_EntitySpecs.m_EntityName, m_EntityInstanceID);

            if (AppLogic.GlobalConfigBool("AllowEntityFiltering") == true && !map.IsMapped)
            {
                HttpContext.Current.Server.Transfer("pagenotfound.aspx");
            }
            m_ThisEntityNodeContext = n;

            String SENameINURL = CommonLogic.QueryStringCanBeDangerousContent("SEName");

            if (SENameINURL.Equals(XmlCommon.XmlField(GetActiveEntityNodeContext, "SEName"), StringComparison.InvariantCultureIgnoreCase) == false)
            {
                string QS     = BuildQueryString();
                String NewURL = string.Format("{0}{1}{2}", AppLogic.GetStoreHTTPLocation(false, false), SE.MakeEntityLink(m_EntityHelper.GetEntitySpecs.m_EntityName, m_EntityInstanceID, XmlCommon.XmlField(GetActiveEntityNodeContext, "SEName")), QS);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                HttpContext.Current.Response.Status = "301 Moved Permanently";
                HttpContext.Current.Response.AddHeader("Location", NewURL);
                m_URLValidated = false;
            }

            if (m_URLValidated)
            {
                m_CategoryFilterID     = CommonLogic.QueryStringUSInt("CategoryFilterID");
                m_SectionFilterID      = CommonLogic.QueryStringUSInt("SectionFilterID");
                m_ProductTypeFilterID  = CommonLogic.QueryStringUSInt("ProductTypeFilterID");
                m_ManufacturerFilterID = CommonLogic.QueryStringUSInt("ManufacturerFilterID");
                m_DistributorFilterID  = CommonLogic.QueryStringUSInt("DistributorFilterID");
                m_GenreFilterID        = CommonLogic.QueryStringUSInt("GenreFilterID");
                m_VectorFilterID       = CommonLogic.QueryStringUSInt("VectorFilterID");

                if (CommonLogic.QueryStringCanBeDangerousContent("CategoryFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") && CommonLogic.CookieUSInt("CategoryFilterID") != 0)
                    {
                        m_CategoryFilterID = CommonLogic.CookieUSInt("CategoryFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("SectionFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") && CommonLogic.CookieUSInt("SectionFilterID") != 0)
                    {
                        m_SectionFilterID = CommonLogic.CookieUSInt("SectionFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("ProductTypeFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") && CommonLogic.CookieUSInt("ProductTypeFilterID") != 0)
                    {
                        m_ProductTypeFilterID = CommonLogic.CookieUSInt("ProductTypeFilterID");
                    }
                    if (m_ProductTypeFilterID != 0 &&
                        !AppLogic.ProductTypeHasVisibleProducts(m_ProductTypeFilterID))
                    {
                        m_ProductTypeFilterID = 0;
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("ManufacturerFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") &&
                        CommonLogic.CookieUSInt("ManufacturerFilterID") != 0)
                    {
                        m_ManufacturerFilterID = CommonLogic.CookieUSInt("ManufacturerFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("DistributorFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") &&
                        CommonLogic.CookieUSInt("DistributorFilterID") != 0)
                    {
                        m_DistributorFilterID = CommonLogic.CookieUSInt("DistributorFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("GenreFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") &&
                        CommonLogic.CookieUSInt("GenreFilterID") != 0)
                    {
                        m_GenreFilterID = CommonLogic.CookieUSInt("GenreFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("VectorFilterID").Length == 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && AppLogic.AppConfigBool("PersistFilters") &&
                        CommonLogic.CookieUSInt("VectorFilterID") != 0)
                    {
                        m_VectorFilterID = CommonLogic.CookieUSInt("VectorFilterID");
                    }
                }

                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length != 0)
                {
                    m_CategoryFilterID     = 0;
                    m_SectionFilterID      = 0;
                    m_ManufacturerFilterID = 0;
                    m_DistributorFilterID  = 0;
                    m_GenreFilterID        = 0;
                    m_VectorFilterID       = 0;
                    m_ProductTypeFilterID  = 0;
                }

                if (AppLogic.AppConfigBool("PersistFilters"))
                {
                    HttpContext.Current.Profile.SetPropertyValue("CategoryFilterID", m_CategoryFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("SectionFilterID", m_SectionFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("ManufacturerFilterID", m_ManufacturerFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("DistributorFilterID", m_DistributorFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("GenreFilterID", m_GenreFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("VectorFilterID", m_VectorFilterID.ToString());
                    HttpContext.Current.Profile.SetPropertyValue("ProductTypeFilterID", m_ProductTypeFilterID.ToString());
                }

                m_EntityInstanceName = m_EntityHelper.m_TblMgr.CurrentName(n, m_SkinBase.ThisCustomer.LocaleSetting);

                HttpContext.Current.Profile.SetPropertyValue("LastViewedEntityName", m_EntitySpecs.m_EntityName);
                HttpContext.Current.Profile.SetPropertyValue("LastViewedEntityInstanceID", m_EntityInstanceID.ToString());
                HttpContext.Current.Profile.SetPropertyValue("LastViewedEntityInstanceName", m_EntityInstanceName);

                #region Vortx Mobile Xml Package Modification
                m_XmlPackage = Vortx.MobileFramework.MobileXmlPackageController.XmlPackageHook(m_EntityHelper.m_TblMgr.CurrentField(n, "XmlPackage").ToLowerInvariant(), m_SkinBase.ThisCustomer);
                #endregion
                if (m_XmlPackage.Length == 0)
                {
                    m_XmlPackage = AppLogic.ro_DefaultEntityXmlPackage; // provide a default for backwards compatibility
                }


                String RunTimeParms = String.Format("EntityName={0}&EntityID={1}", m_EntitySpecs.m_EntityName, m_EntityInstanceID.ToString());

                RunTimeParms += String.Format("&CatID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("CATEGORY", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_CategoryFilterID.ToString()));
                RunTimeParms += String.Format("&SecID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("SECTION", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_SectionFilterID.ToString()));
                RunTimeParms += String.Format("&ManID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("MANUFACTURER", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_ManufacturerFilterID.ToString()));
                RunTimeParms += String.Format("&DistID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("DISTRIBUTOR", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_DistributorFilterID.ToString()));
                RunTimeParms += String.Format("&GenreID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("GENRE", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_GenreFilterID.ToString()));
                RunTimeParms += String.Format("&VectorID={0}", CommonLogic.IIF(m_EntitySpecs.m_EntityName.Trim().Equals("VECTOR", StringComparison.InvariantCultureIgnoreCase), m_EntityInstanceID.ToString(), m_VectorFilterID.ToString()));
                RunTimeParms += String.Format("&ProductTypeFilterID={0}", m_ProductTypeFilterID.ToString());

                // CacheEntityPageHTML is an UNSUPPORTED and UNDOCUMENTED AppConfig
                // caching does NOT honor cross entity filtering, or other filters. Use it only on high traffic sites
                // with entity pages that do NOT vary by params other than those used in the CacheName string below.
                // if you are showing prices, they will remain the same during the cache duration (AppLogic.CacheDurationMinutes setting, usually 1 hr)
                String CacheName = String.Empty;


                m_SkinBase.SETitle = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SETitle", m_SkinBase.ThisCustomer.LocaleSetting);
                if (m_SkinBase.SETitle.Length == 0)
                {
                    m_SkinBase.SETitle = Security.HtmlEncode(AppLogic.AppConfig("StoreName") + " - " + m_EntityInstanceName);
                }
                m_SkinBase.SEDescription = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SEDescription", m_SkinBase.ThisCustomer.LocaleSetting);
                if (m_SkinBase.SEDescription.Length == 0)
                {
                    m_SkinBase.SEDescription = Security.HtmlEncode(m_EntityInstanceName);
                }
                m_SkinBase.SEKeywords = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SEKeywords", m_SkinBase.ThisCustomer.LocaleSetting);
                if (m_SkinBase.SEKeywords.Length == 0)
                {
                    m_SkinBase.SEKeywords = Security.HtmlEncode(m_EntityInstanceName);
                }
                m_SkinBase.SENoScript = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SENoScript", m_SkinBase.ThisCustomer.LocaleSetting);

                m_SkinBase.SectionTitle = Breadcrumb.GetEntityBreadcrumb(m_EntityInstanceID, m_EntityInstanceName, m_EntitySpecs.m_EntityName, m_SkinBase.ThisCustomer);

                if (m_URLValidated)
                {
                    m_PageOutput = "<!-- XmlPackage: " + m_XmlPackage + " -->\n";
                    if (m_XmlPackage.Length == 0)
                    {
                        m_PageOutput += "<p><b><font color=red>XmlPackage format was chosen, but no XmlPackage was specified!</font></b></p>";
                    }
                    else
                    {
                        String s = null;
                        if (AppLogic.AppConfigBool("CacheEntityPageHTML"))
                        {
                            CacheName = String.Format("CacheEntityPageHTML|{0}|{1}|{2}|{3}|{4}|{5}|{6}",
                                                      m_EntitySpecs.m_EntityName,
                                                      m_EntityInstanceID.ToString(),
                                                      m_SkinBase.ThisCustomer.CustomerLevelID.ToString(),
                                                      m_SkinBase.ThisCustomer.LocaleSetting,
                                                      CommonLogic.QueryStringUSInt("PageNum").ToString(),
                                                      m_SkinBase.ThisCustomer.AffiliateID.ToString(),
                                                      Vortx.MobileFramework.MobileHelper.isMobile() ? "Mobile" : "Desktop"
                                                      );

                            s = (String)HttpContext.Current.Cache.Get(CacheName);
                            if (s != null)
                            {
                                s = "<!-- CacheEntityPageHTML -->" + s;
                            }
                            m_SkinBase.SectionTitle  = (String)HttpContext.Current.Cache.Get(CacheName + "|SectionTitle");
                            m_SkinBase.SETitle       = (String)HttpContext.Current.Cache.Get(CacheName + "|SETitle");
                            m_SkinBase.SEDescription = (String)HttpContext.Current.Cache.Get(CacheName + "|SEDescription");
                            m_SkinBase.SEKeywords    = (String)HttpContext.Current.Cache.Get(CacheName + "|SEKeywords");
                            m_SkinBase.SENoScript    = (String)HttpContext.Current.Cache.Get(CacheName + "|SENoScript");
                            if (m_SkinBase.SectionTitle == null)
                            {
                                m_SkinBase.SectionTitle = String.Empty;
                            }
                            if (m_SkinBase.SETitle == null)
                            {
                                m_SkinBase.SETitle = String.Empty;
                            }
                            if (m_SkinBase.SEDescription == null)
                            {
                                m_SkinBase.SEDescription = String.Empty;
                            }
                            if (m_SkinBase.SEKeywords == null)
                            {
                                m_SkinBase.SEKeywords = String.Empty;
                            }
                            if (m_SkinBase.SENoScript == null)
                            {
                                m_SkinBase.SENoScript = String.Empty;
                            }
                        }
                        if (s == null || s.Length == 0)
                        {
                            using (XmlPackage2 p = new XmlPackage2(m_XmlPackage, m_SkinBase.ThisCustomer, m_SkinBase.SkinID, "", RunTimeParms, String.Empty, true))
                            {
                                s = AppLogic.RunXmlPackage(p, m_SkinBase.GetParser, m_SkinBase.ThisCustomer, m_SkinBase.SkinID, true, true);
                                if (p.SectionTitle != "")
                                {
                                    m_SkinBase.SectionTitle = p.SectionTitle;
                                }
                                if (p.SETitle != "")
                                {
                                    m_SkinBase.SETitle = p.SETitle;
                                }
                                if (p.SEDescription != "")
                                {
                                    m_SkinBase.SEDescription = p.SEDescription;
                                }
                                if (p.SEKeywords != "")
                                {
                                    m_SkinBase.SEKeywords = p.SEKeywords;
                                }
                                if (p.SENoScript != "")
                                {
                                    m_SkinBase.SENoScript = p.SENoScript;
                                }
                                if (AppLogic.AppConfigBool("CacheEntityPageHTML"))
                                {
                                    HttpContext.Current.Cache.Insert(CacheName, s, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                    HttpContext.Current.Cache.Insert(CacheName + "|SectionTitle", p.SectionTitle, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                    HttpContext.Current.Cache.Insert(CacheName + "|SETitle", p.SETitle, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                    HttpContext.Current.Cache.Insert(CacheName + "|SEDescription", p.SEDescription, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                    HttpContext.Current.Cache.Insert(CacheName + "|SEKeywords", p.SEKeywords, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                    HttpContext.Current.Cache.Insert(CacheName + "|SENoScript", p.SENoScript, null, DateTime.Now.AddMinutes(AppLogic.CacheDurationMinutes()), TimeSpan.Zero);
                                }
                            }
                        }
                        m_PageOutput += s;
                    }
                }
            }
            AppLogic.eventHandler("ViewEntityPage").CallEvent("&ViewEntityPage=true");

            //check if the postback was caused by the TableOrderAddToCart button
            if (m_SkinBase.IsPostBack && isTableOrderAddToCartPostBack)
            {
                HandleTableOrderAddToCart();
            }
        }
        public void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                SkinBase.GoNonSecureAgain();
            }
            n = m_EntityHelper.m_TblMgr.SetContext(m_EntityInstanceID);

            if (n == null)
            {
                HttpContext.Current.Response.Redirect("t-error404.aspx");
            }

            m_CategoryFilterID     = CommonLogic.QueryStringCanBeDangerousContent("CategoryFilterID");
            m_SectionFilterID      = CommonLogic.QueryStringCanBeDangerousContent("SectionFilterID");
            m_ProductTypeFilterID  = CommonLogic.QueryStringCanBeDangerousContent("ProductTypeFilterID");
            m_ManufacturerFilterID = CommonLogic.QueryStringCanBeDangerousContent("ManufacturerFilterID");
            m_AttributeFilterID    = CommonLogic.QueryStringCanBeDangerousContent("AttributeFilterID");
            m_AttributeFilter      = CommonLogic.GetAttributeFilter();

            if (CommonLogic.QueryStringCanBeDangerousContent("CategoryFilterID").Length == 0)
            {
                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && CommonLogic.CookieUSInt("CategoryFilterID") != 0)
                {
                    m_CategoryFilterID = CommonLogic.CookieCanBeDangerousContent("CategoryFilterID", false);
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("SectionFilterID").Length == 0)
            {
                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && CommonLogic.CookieUSInt("SectionFilterID") != 0)
                {
                    m_SectionFilterID = CommonLogic.CookieCanBeDangerousContent("SectionFilterID", false);
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("ProductTypeFilterID").Length == 0)
            {
                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && CommonLogic.CookieUSInt("ProductTypeFilterID") != 0)
                {
                    m_ProductTypeFilterID = CommonLogic.CookieCanBeDangerousContent("ProductTypeFilterID", false);
                }
                if (m_ProductTypeFilterID != String.Empty && !AppLogic.ProductTypeHasVisibleProducts(m_ProductTypeFilterID))
                {
                    m_ProductTypeFilterID = String.Empty;
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("ManufacturerFilterID").Length == 0)
            {
                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && CommonLogic.CookieUSInt("ManufacturerFilterID") != 0)
                {
                    m_ManufacturerFilterID = CommonLogic.CookieCanBeDangerousContent("ManufacturerFilterID", false);
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("AttributeFilterID").Length == 0)
            {
                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && CommonLogic.CookieUSInt("AttributeFilterID") != 0)
                {
                    m_AttributeFilterID = CommonLogic.CookieCanBeDangerousContent("AttributeFilterID", false);
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length != 0)
            {
                m_CategoryFilterID     = String.Empty;
                m_SectionFilterID      = String.Empty;
                m_ManufacturerFilterID = String.Empty;
                m_ProductTypeFilterID  = String.Empty;
                m_AttributeFilterID    = String.Empty;
                m_AttributeFilter      = String.Empty;
            }

            m_EntityInstanceName           = m_EntityHelper.m_TblMgr.CurrentName(n, m_SkinBase.ThisCustomer.LocaleSetting);
            m_EntityInstanceNameForDisplay = CommonLogic.IIF(m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "Description", m_SkinBase.ThisCustomer.LocaleSetting) != String.Empty, m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "Description", m_SkinBase.ThisCustomer.LocaleSetting), m_EntityHelper.m_TblMgr.CurrentName(n, m_SkinBase.ThisCustomer.LocaleSetting));

            AppLogic.SetCookie("LastViewedEntityName", m_EntitySpecs.m_EntityName, new TimeSpan(1, 0, 0, 0, 0));
            AppLogic.SetCookie("LastViewedEntityInstanceID", m_EntityInstanceID.ToString(), new TimeSpan(1, 0, 0, 0, 0));
            AppLogic.SetCookie("LastViewedEntityInstanceName", m_EntityInstanceNameForDisplay, new TimeSpan(1, 0, 0, 0, 0));

            m_SkinBase.SETitle = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SETitle", m_SkinBase.ThisCustomer.LocaleSetting);
            if (m_SkinBase.SETitle.Length == 0)
            {
                m_SkinBase.SETitle = HttpContext.Current.Server.HtmlEncode(AppLogic.AppConfig("StoreName") + " - " + m_EntityInstanceName);
            }
            m_SkinBase.SEDescription = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SEDescription", m_SkinBase.ThisCustomer.LocaleSetting);
            if (m_SkinBase.SEDescription.Length == 0)
            {
                m_SkinBase.SEDescription = HttpContext.Current.Server.HtmlEncode(m_EntityInstanceName);
            }
            m_SkinBase.SEKeywords = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SEKeywords", m_SkinBase.ThisCustomer.LocaleSetting);
            if (m_SkinBase.SEKeywords.Length == 0)
            {
                m_SkinBase.SEKeywords = HttpContext.Current.Server.HtmlEncode(m_EntityInstanceName);
            }
            m_SkinBase.SENoScript = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SENoScript", m_SkinBase.ThisCustomer.LocaleSetting);

            m_SkinBase.SectionTitle = "<span class=\"SectionTitleText\">";
            String ParentName = String.Empty;
            String ParentID   = m_EntityHelper.GetParentEntity(m_EntityInstanceID);

            while (ParentID != String.Empty)
            {
                ParentName = CommonLogic.IIF(m_EntityHelper.GetEntityField(ParentID, "Description", m_SkinBase.ThisCustomer.LocaleSetting) != String.Empty,
                                             m_EntityHelper.GetEntityField(ParentID, "Description", m_SkinBase.ThisCustomer.LocaleSetting),
                                             m_EntityHelper.GetEntityName(ParentID, m_SkinBase.ThisCustomer.LocaleSetting));

                m_SkinBase.SectionTitle = "<a class=\"SectionTitleText\" href=\"" + SE.MakeEntityLink(m_EntitySpecs.m_EntityName, ParentID, ParentName) + "\">" + ParentName +
                                          "</a> &rarr; " + m_SkinBase.SectionTitle;
                ParentID = m_EntityHelper.GetParentEntity(ParentID);
            }
            m_SkinBase.SectionTitle += m_EntityInstanceNameForDisplay;
            m_SkinBase.SectionTitle += "</span>";
            AppLogic.LogEvent(m_SkinBase.ThisCustomer.CustomerCode, 9, m_EntityInstanceID.ToString());

            //Include for mobile manufacturer
            if (CurrentContext.IsRequestingFromMobileMode(m_SkinBase.ThisCustomer))
            {
                m_XmlPackage = m_EntityHelper.m_TblMgr.CurrentField(n, "MobileXmlPackage").ToLowerInvariant();
                if (m_XmlPackage.IsNullOrEmptyTrimmed())
                {
                    m_XmlPackage = m_EntityHelper.m_TblMgr.CurrentField(n, "XmlPackage").ToLowerInvariant();
                }
            }
            else
            {
                m_XmlPackage = m_EntityHelper.m_TblMgr.CurrentField(n, "XmlPackage").ToLowerInvariant();
            }

            if (m_XmlPackage.Length == 0)
            {
                m_XmlPackage = AppLogic.ro_DefaultEntityXmlPackage; // provide a default for backwards compatibility
            }

            GeneratePageOutput();
        }
Example #7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            bool ByPassWorldPay = CommonLogic.QueryStringBool("bypass");
            bool NoAutoRefresh  = CommonLogic.QueryStringCanBeDangerousContent("refresh").Equals("FALSE", StringComparison.InvariantCultureIgnoreCase);

            String tmpS        = CommonLogic.GetFormInput(false, "|");
            String tmpS2       = CommonLogic.GetQueryStringInput(false, "|"); // for debug!
            String TransStatus = CommonLogic.FormCanBeDangerousContent("TransStatus");
            int    CustomerID  = CommonLogic.FormNativeInt("CartID");

            if (ByPassWorldPay)
            {
                throw new ArgumentException("WorldPay ByPass No Longer Supported");
            }

            if (TransStatus.Length == 0 || CustomerID == 0)
            {
                throw new ArgumentException("WorldPay did NOT return any Form Post information. Please contact WorldPay!!");
            }
            if (TransStatus != "Y")
            {
                String ReturnURL = AppLogic.GetStoreHTTPLocation(true) + "shoppingcart.aspx";
                //if (AppLogic.AppConfigBool("WorldPay_OnCancelAutoRedirectToCart"))
                //{
                //    Response.AddHeader("REFRESH", "1; URL=" + ReturnURL);
                //}
                //Response.Write("<html><head><title>WorldPay Checkout Canceled - Please Wait</title></head><body>");
                Response.Write("<html><head><title>WorldPay Checkout Canceled - Please Wait</title>");
                if (AppLogic.AppConfigBool("WorldPay_OnCancelAutoRedirectToCart"))
                {
                    Response.Write("<meta http-equiv=\"refresh\" content=\"1;url=" + ReturnURL + "\">");
                }
                Response.Write("</head><body>");
                if (!AppLogic.AppConfigBool("WorldPay_OnCancelAutoRedirectToCart"))
                {
                    Topic t = new Topic("WorldPayCancel");
                    Response.Write(t.Contents.Replace("(!SKINID!)", CommonLogic.CookieUSInt("SkinID").ToString())); // only way to get skin is through users' cookie
                    Response.Write("<p align=\"left\"><b>" + AppLogic.GetString("worldpayreturn.aspx.1", 1, Localization.GetDefaultLocale()) + " <a href=\"" + ReturnURL + "\">" + String.Format(AppLogic.GetString("worldpayreturn.aspx.1", 1, Localization.GetDefaultLocale()), AppLogic.GetString("AppConfig.CartPrompt", 1, Localization.GetDefaultLocale()).ToLowerInvariant()) + "</a></b></p>");
                }
                if (AppLogic.AppConfigBool("WorldPay_OnCancelAutoRedirectToCart"))
                {
                    Response.Write("<p>If you are not redirected automatically within a few seconds. Please click <a href=\"" + ReturnURL + "\">here</a> </p>");
                }
                Response.Write("</body></html>");
            }
            else
            {
                Customer ThisCustomer = new Customer(CustomerID, true);

                // need these later in processcard, don't like passing via session, but it should be safe, and is easiest thing to do
                // worldpay structure requires this, so it can work like our other payment gateways
                ThisCustomer.ThisCustomerSession["WorldPay_CartID"]         = CommonLogic.IIF(CommonLogic.FormCanBeDangerousContent("CartID").Length == 0, CustomerID.ToString(), CommonLogic.FormCanBeDangerousContent("CartID"));
                ThisCustomer.ThisCustomerSession["WorldPay_TransID"]        = CommonLogic.FormCanBeDangerousContent("TransID");
                ThisCustomer.ThisCustomerSession["WorldPay_FuturePayID"]    = CommonLogic.FormCanBeDangerousContent("FuturePayID");
                ThisCustomer.ThisCustomerSession["WorldPay_TransStatus"]    = TransStatus;
                ThisCustomer.ThisCustomerSession["WorldPay_TransTime"]      = CommonLogic.FormCanBeDangerousContent("TransTime");
                ThisCustomer.ThisCustomerSession["WorldPay_AuthAmount"]     = CommonLogic.FormCanBeDangerousContent("AuthAmount");
                ThisCustomer.ThisCustomerSession["WorldPay_AuthCurrency"]   = CommonLogic.FormCanBeDangerousContent("AuthCurrency");
                ThisCustomer.ThisCustomerSession["WorldPay_RawAuthMessage"] = CommonLogic.FormCanBeDangerousContent("RawAuthMessage");
                ThisCustomer.ThisCustomerSession["WorldPay_RawAuthCode"]    = CommonLogic.FormCanBeDangerousContent("RawAuthCode");
                ThisCustomer.ThisCustomerSession["WorldPay_CallbackPW"]     = CommonLogic.FormCanBeDangerousContent("CallbackPW");
                ThisCustomer.ThisCustomerSession["WorldPay_CardType"]       = CommonLogic.FormCanBeDangerousContent("CardType");
                ThisCustomer.ThisCustomerSession["WorldPay_CountryMatch"]   = CommonLogic.FormCanBeDangerousContent("CountryMatch");
                ThisCustomer.ThisCustomerSession["WorldPay_AVS"]            = CommonLogic.FormCanBeDangerousContent("AVS");

                if (CustomerID != 0)
                {
                    // MakeOrder ALWAYS Returns OK, because WorldPay will never return without a C for cancel or Y for success, and the C was handled above
                    int OrderNumber = AppLogic.GetNextOrderNumber();

                    ShoppingCart cart = new ShoppingCart(1, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);

                    Address UseBillingAddress = new Address();
                    UseBillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);

                    // make sure their addresss record is updated to match a worldpay checkout:
                    UseBillingAddress.ClearCCInfo();
                    UseBillingAddress.PaymentMethodLastUsed = AppLogic.ro_PMCreditCard;
                    UseBillingAddress.UpdateDB();

                    String status = Gateway.MakeOrder(String.Empty, AppLogic.TransactionMode(), cart, OrderNumber, String.Empty, String.Empty, String.Empty, String.Empty);

                    if (status.Equals(AppLogic.ro_OK, StringComparison.InvariantCultureIgnoreCase) == false)
                    {
                        throw new ArgumentException("Unknown WorldPay Callback Page Error: " + status);
                    }

                    String ReturnURL = AppLogic.GetStoreHTTPLocation(true) + "orderconfirmation.aspx?ordernumber=" + OrderNumber.ToString() + "&paymentmethod=Credit+Card";
                    Response.Write("<html><head><title>WorldPay Checkout Successful - Please Wait</title>");
                    if (!NoAutoRefresh)
                    {
                        Response.Write("<meta http-equiv=\"refresh\" content=\"1;url=" + ReturnURL + "\">");
                    }
                    Response.Write("</head><body>");
                    Topic t = new Topic("WorldPaySuccess", ThisCustomer.LocaleSetting, ThisCustomer.SkinID, null);
                    Response.Write(t.Contents.Replace("(!SKINID!)", ThisCustomer.SkinID.ToString()));
                    Response.Write("<p align=\"left\"><b>" + AppLogic.GetString("worldpayreturn.aspx.3", 1, Localization.GetDefaultLocale()) + " <a href=\"" + ReturnURL + "\">" + AppLogic.GetString("worldpayreturn.aspx.4", 1, Localization.GetDefaultLocale()) + "</a></b></p>");
                    Response.Write("</body></html>");
                }
                else
                {
                    Response.Write("<html><head><title>WorldPay Checkout Error</title></head><body>");
                    Response.Write(AppLogic.GetString("worldpayreturn.aspx.5", 1, Localization.GetDefaultLocale()));
                    Response.Write("</body></html>");
                }
            }
        }