Exemplo n.º 1
0
        public static List <CachelessStore> GetStores(Boolean all)
        {
            var stores = new List <CachelessStore>();

            var sql = "SELECT [StoreID],[StoreGUID], [Name], [ProductionURI], [StagingURI], [DevelopmentURI], [Description], [Published], [Deleted], [SkinID], [IsDefault], [CreatedOn] FROM Store";

            if (!all)
            {
                sql += " WHERE Deleted = 0 and Published = 1";
            }

            using (SqlConnection connection = new SqlConnection(DB.GetDBConn()))
            {
                connection.Open();
                IDataReader reader = DB.GetRS(sql, connection);
                while (reader.Read())
                {
                    CachelessStore store = new CachelessStore();
                    store.Initialize(reader);
                    stores.Add(store);
                }
            }

            return(stores);
        }
Exemplo n.º 2
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();
            }
        }