Пример #1
0
            internal void GetProducts()
            {
                SqlCommand            retCmd = cmdGetProduct();
                List <SiteMapProduct> xList  = new List <SiteMapProduct>();

                if (SiteMap.Settings.ProductFiltering)
                {
                    retCmd.Parameters["@StoreID"].Value = AppLogic.StoreID();
                }

                Action <System.Data.IDataReader> readEntities = rd =>
                {
                    while (rd.Read())
                    {
                        SiteMapProduct prd = new SiteMapProduct();
                        prd.EntityID      = rd.FieldInt("ProductID");
                        prd.MappingEntity = this.EntityType;
                        prd.Name          = XmlCommon.GetLocaleEntry(rd.Field("Name"), Customer.Current.LocaleSetting, false);
                        prd.SEName        = rd.Field("SEName");
                        xList.Add(prd);
                    }
                };

                DB.UseDataReader(retCmd, readEntities);
                Products = xList.ToArray();
            }
Пример #2
0
            public new static NestedSiteMapEntity[] GetEntities(string EntityType)
            {
                Dictionary <int, NestedSiteMapEntity> _list = new Dictionary <int, NestedSiteMapEntity>();

                SqlCommand getCommand = getEntitySQL(EntityType);
                Action <System.Data.IDataReader> readEntities = rd =>
                {
                    while (rd.Read())
                    {
                        NestedSiteMapEntity entity = new NestedSiteMapEntity();
                        entity.EntityID       = rd.FieldInt("ID");
                        entity.Name           = XmlCommon.GetLocaleEntry(rd.Field("Name"), Customer.Current.LocaleSetting, false);
                        entity.SEName         = rd.Field("SEName");
                        entity.ParentEntityID = rd.FieldInt("ParentID");
                        entity.EntityType     = EntityType;
                        entity.GetProducts();
                        _list.Add(entity.EntityID, entity);
                    }
                };

                DB.UseDataReader(getCommand, readEntities);


                return(OrganizeEntities(_list).ToArray());
            }
Пример #3
0
            public virtual XmlNode ToSiteMapTopicNode(XmlDocument context)
            {
                String tName = XmlCommon.GetLocaleEntry(Name, Customer.Current.LocaleSetting, true);

                Topic t = new Topic(tName, Customer.Current.LocaleSetting);

                return(SiteMapNode(t.SectionTitle, SE.MakeDriverLink(tName), context));
            }
Пример #4
0
        public string LocalizedValue(string unlocalizedValue)
        {
            var customer       = AppLogic.GetCurrentCustomer();
            var localizedValue = unlocalizedValue;

            if (customer != null)
            {
                localizedValue = XmlCommon.GetLocaleEntry(unlocalizedValue, customer.LocaleSetting, true);
            }
            else
            {
                localizedValue = XmlCommon.GetLocaleEntry(unlocalizedValue, Localization.GetDefaultLocale(), true);
            }

            return(localizedValue);
        }
Пример #5
0
        /// <summary>
        /// Determines a localized value for the current locale for any product property when multiple locales are being used
        /// </summary>
        /// <param name="val">The unlocalized string value to localize</param>
        /// <returns>A localized string based on the current locale</returns>
        public String LocalizedValue(String val)
        {
            Customer ThisCustomer = AppLogic.GetCurrentCustomer();

            String LocalValue = val;

            if (ThisCustomer != null)
            {
                LocalValue = XmlCommon.GetLocaleEntry(val, ThisCustomer.LocaleSetting, true);
            }
            else
            {
                LocalValue = XmlCommon.GetLocaleEntry(val, Localization.GetDefaultLocale(), true);
            }

            return(LocalValue);
        }
Пример #6
0
            internal static SiteMapEntity[] GetEntities(string EntityType)
            {
                List <SiteMapEntity> _list = new List <SiteMapEntity>();

                SqlCommand getCommand = getEntitySQL(EntityType);
                Action <System.Data.IDataReader> readEntities = rd =>
                {
                    while (rd.Read())
                    {
                        SiteMapEntity entity = new SiteMapEntity();
                        entity.EntityID   = rd.FieldInt("ID");
                        entity.Name       = XmlCommon.GetLocaleEntry(rd.Field("Name"), Customer.Current.LocaleSetting, false);
                        entity.SEName     = rd.Field("SEName");
                        entity.EntityType = EntityType;
                        _list.Add(entity);
                    }
                };

                DB.UseDataReader(getCommand, readEntities);
                return(_list.ToArray());
            }
Пример #7
0
            internal static SiteMapEntity[] GetTopics(string group)
            {
                List <SiteMapEntity>             _list      = new List <SiteMapEntity>();
                SqlCommand                       getCommand = new SqlCommand("select * from Topic where Deleted = 0 and Published=1 and ShowInSiteMap = 1 " + CommonLogic.IIF(SiteMap.Settings.TopicFiltering, " and (storeid = 0 or storeid =" + AppLogic.StoreID() + ")", "") + " order by storeid desc, DisplayOrder desc, name");
                Action <System.Data.IDataReader> readTopics = rd =>
                {
                    while (rd.Read())
                    {
                        SiteMapEntity entity = new SiteMapEntity();
                        entity.EntityID   = rd.FieldInt("TopicID");
                        entity.Name       = XmlCommon.GetLocaleEntry(rd.Field("Name"), Customer.Current.LocaleSetting, false);
                        entity.SEName     = XmlCommon.GetLocaleEntry(rd.Field("Name"), Customer.Current.LocaleSetting, false);
                        entity.EntityType = "topic";
                        if (_list.FirstOrDefault(t => t.Name == entity.Name) == null)
                        {
                            _list.Add(entity);
                        }
                    }
                };

                DB.UseDataReader(getCommand, readTopics);

                return(_list.ToArray());
            }
Пример #8
0
        internal static LinkItemCollection GetChildren(ProductMappingLinkItem parent)
        {
            LinkItemCollection children = new LinkItemCollection();


            Action <IDataReader> readAction = (rs) =>
            {
                while (rs.Read())
                {
                    ProductMappingLinkItem child = new ProductMappingLinkItem();
                    child.Name           = XmlCommon.GetLocaleEntry(rs.Field("Name"), Customer.Current.LocaleSetting, true);
                    child.Parent         = parent;
                    child.Type           = rs.Field("Type");
                    child.SEName         = rs.Field("SEName");
                    child.ParentEntityID = rs.FieldInt("ParentEntityID");
                    child.DisplayOrder   = rs.FieldInt("DisplayOrder");
                    child.ID             = rs.FieldInt("ID");
                    children.Add(child);
                }
            };

            string query = string.Empty;

            switch (parent.Type.ToLowerInvariant())
            {
            case "section":
                query = string.Format("SELECT A.SectionID ID, Name, SEName, 'Section' [Type], ParentSectionID ParentEntityID, DisplayOrder FROM Section A WITH (NOLOCK) INNER JOIN (SELECT DISTINCT " +
                                      "SectionID EntityID FROM Section A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.SectionID = B.EntityID AND EntityType = 'Section' WHERE ({0} = 0 or StoreID = {1})) B " +
                                      "ON A.SectionID = B.EntityID WHERE ParentSectionID = {2} AND Published=1 AND Deleted=0 ORDER BY DisplayOrder, Name ASC", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), parent.ID);
                break;

            case "category":
                query = string.Format("SELECT A.CategoryID ID, Name, SEName, 'Category' [Type], ParentCategoryID ParentEntityID, DisplayOrder FROM Category A WITH (NOLOCK) INNER JOIN (SELECT DISTINCT " +
                                      "CategoryID EntityID FROM Category A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.CategoryID = B.EntityID AND EntityType = 'Category' WHERE ({0} = 0 or StoreID = {1})) B " +
                                      "ON A.CategoryID = B.EntityID WHERE ParentCategoryID = {2} AND Published=1 AND Deleted=0 ORDER BY DisplayOrder, Name ASC", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), parent.ID);
                break;

            case "manufacturer":
                query = string.Format("SELECT A.ManufacturerID ID, Name, SEName, 'Manufacturer' [Type], ParentManufacturerID ParentEntityID, DisplayOrder FROM Manufacturer A WITH (NOLOCK) INNER JOIN (SELECT " +
                                      "DISTINCT ManufacturerID EntityID FROM Manufacturer A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.ManufacturerID = B.EntityID AND EntityType = 'Manufacturer' WHERE ({0} = 0 or " +
                                      "StoreID = {1})) B ON A.ManufacturerID = B.EntityID WHERE ParentManufacturerID = {2} AND Published=1 AND Deleted=0 ORDER BY DisplayOrder, Name ASC", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), parent.ID);
                break;

            case "vector":
                query = string.Format("SELECT A.VectorID ID, Name, SEName, 'Vector' [Type], ParentVectorID ParentEntityID, DisplayOrder FROM Vector A WITH (NOLOCK) INNER JOIN (SELECT DISTINCT " +
                                      "VectorID EntityID FROM Vector A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.VectorID = B.EntityID AND EntityType = 'Vector' WHERE ({0} = 0 or StoreID = {1})) B " +
                                      "ON A.VectorID = B.EntityID WHERE ParentVectorID = {2} AND Published=1 AND Deleted=0 ORDER BY DisplayOrder, Name ASC", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), parent.ID);
                break;

            case "genre":
                query = string.Format("SELECT A.GenreID ID, Name, SEName, 'Genre' [Type], ParentGenreID ParentEntityID, DisplayOrder FROM Genre A WITH (NOLOCK) INNER JOIN (SELECT DISTINCT " +
                                      "GenreID EntityID FROM Genre A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.GenreID = B.EntityID AND EntityType = 'GenreID' WHERE ({0} = 0 or StoreID = {1})) B " +
                                      "ON A.GenreID = B.EntityID WHERE ParentGenreID = {2} AND Published=1 AND Deleted=0 ORDER BY DisplayOrder, Name ASC", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), parent.ID);
                break;

            case "distributor":
                query = string.Format("SELECT A.DistributorID ID, Name, SEName, 'Distributor' [Type], ParentDistributorID ParentEntityID, DisplayOrder FROM Distributor A WITH (NOLOCK) INNER JOIN (SELECT " +
                                      "DISTINCT DistributorID EntityID FROM Distributor A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.DistributorID = B.EntityID AND EntityType = 'Distributor' WHERE ({0} = 0 or " +
                                      "StoreID = {1})) B ON A.DistributorID = B.EntityID WHERE ParentDistributorID = {2} AND Published=1 AND Deleted=0 ORDER BY DisplayOrder, Name ASC", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), parent.ID);
                break;
            }

            if (query.Length > 0)
            {
                DB.UseDataReader(query, readAction);
            }

            return(children);
        }
Пример #9
0
        /// <summary>
        /// Gets all first level entities.
        /// </summary>
        /// <param name="type">The entity type.</param>
        /// <param name="locale">The customer locale.</param>
        /// <returns></returns>
        public static LinkItemCollection GetAllFirstLevel(string type, int top, string locale)
        {
            LinkItemCollection all = new LinkItemCollection();

            Action <IDataReader> readAction = (rs) =>
            {
                while (rs.Read())
                {
                    ProductMappingLinkItem entity = new ProductMappingLinkItem();
                    entity.Name           = XmlCommon.GetLocaleEntry(rs.Field("Name"), Customer.Current.LocaleSetting, true);
                    entity.SEName         = rs.Field("SEName");
                    entity.Type           = rs.Field("Type");
                    entity.ParentEntityID = rs.FieldInt("ParentEntityID");
                    entity.DisplayOrder   = rs.FieldInt("DisplayOrder");
                    entity.ID             = rs.FieldInt("ID");
                    all.Add(entity);
                }
            };

            string topQuery = string.Empty;

            if (top != ReturnAllRecords)
            {
                topQuery = "TOP {0}".FormatWith(top);
            }

            string query = string.Empty;

            switch (type.ToLowerInvariant())
            {
            case "section":
                query = string.Format("SELECT {2} A.SectionID ID, Name, SEName, 'Section' [Type], ParentSectionID ParentEntityID, DisplayOrder FROM Section A WITH (NOLOCK) INNER JOIN (SELECT DISTINCT SectionID " +
                                      "EntityID FROM Section A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.SectionID = B.EntityID AND EntityType = 'Section' WHERE ({0} = 0 or StoreID = {1})) B ON A.SectionID = B.EntityID " +
                                      "WHERE ParentSectionID = 0" + CommonLogic.IIF(AppLogic.IsAdminSite, String.Empty, "and Published=1 and Deleted=0") + " order by DisplayOrder, Name asc", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), topQuery);
                break;

            case "category":
                query = string.Format("SELECT {2} A.CategoryID ID, Name, SEName, 'Category' [Type], ParentCategoryID ParentEntityID, DisplayOrder FROM Category A WITH (NOLOCK) INNER JOIN " +
                                      "(SELECT DISTINCT CategoryID EntityID FROM Category A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.CategoryID = B.EntityID AND EntityType = 'Category' " +
                                      "WHERE ({0} = 0 or StoreID = {1})) B ON A.CategoryID = B.EntityID WHERE ParentCategoryID = 0 " + CommonLogic.IIF(AppLogic.IsAdminSite, String.Empty, "and Published=1 and Deleted=0") + " order by DisplayOrder, Name asc", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), topQuery);
                break;

            case "manufacturer":
                query = string.Format("SELECT {2} A.ManufacturerID ID, Name, SEName, 'Manufacturer' [Type], ParentManufacturerID ParentEntityID, DisplayOrder FROM Manufacturer A WITH (NOLOCK) " +
                                      "INNER JOIN (SELECT DISTINCT ManufacturerID EntityID FROM Manufacturer A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.ManufacturerID = B.EntityID AND EntityType = 'Manufacturer' " +
                                      "WHERE ({0} = 0 or StoreID = {1})) B ON A.ManufacturerID = B.EntityID WHERE ParentManufacturerID = 0 " + CommonLogic.IIF(AppLogic.IsAdminSite, String.Empty, "and Published=1 and Deleted=0") + " order by DisplayOrder, Name asc", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), topQuery);
                break;

            case "vector":
                query = string.Format("SELECT {2} A.VectorID ID, Name, SEName, 'Vector' [Type], ParentVectorID ParentEntityID, DisplayOrder FROM Vector A WITH (NOLOCK) INNER JOIN (SELECT DISTINCT VectorID " +
                                      "EntityID FROM Vector A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.VectorID = B.EntityID AND EntityType = 'Vector' WHERE ({0} = 0 or StoreID = {1})) B ON A.VectorID = B.EntityID " +
                                      "WHERE ParentVectorID = 0" + CommonLogic.IIF(AppLogic.IsAdminSite, String.Empty, "and Published=1 and Deleted=0") + " order by DisplayOrder, Name asc", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), topQuery);
                break;

            case "genre":
                query = string.Format("SELECT {2} A.GenreID ID, Name, SEName, 'Genre' [Type], ParentGenreID ParentEntityID, DisplayOrder FROM Genre A WITH (NOLOCK) INNER JOIN " +
                                      "(SELECT DISTINCT GenreID EntityID FROM Genre A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.GenreID = B.EntityID AND EntityType = 'Genre' " +
                                      "WHERE ({0} = 0 or StoreID = {1})) B ON A.GenreID = B.EntityID WHERE ParentGenreID = 0 " + CommonLogic.IIF(AppLogic.IsAdminSite, String.Empty, "and Published=1 and Deleted=0") + " order by DisplayOrder, Name asc", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), topQuery);
                break;

            case "distributor":
                query = string.Format("SELECT {2} A.DistributorID ID, Name, SEName, 'Distributor' [Type], ParentDistributorID ParentEntityID, DisplayOrder FROM Distributor A WITH (NOLOCK) " +
                                      "INNER JOIN (SELECT DISTINCT DistributorID EntityID FROM Distributor A WITH (NOLOCK) LEFT JOIN EntityStore B WITH (NOLOCK) ON A.DistributorID = B.EntityID AND EntityType = 'Distributor' " +
                                      "WHERE ({0} = 0 or StoreID = {1})) B ON A.DistributorID = B.EntityID WHERE ParentDistributorID = 0 " + CommonLogic.IIF(AppLogic.IsAdminSite, String.Empty, "and Published=1 and Deleted=0") + " order by DisplayOrder, Name asc", CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), topQuery);
                break;
            }

            if (query.Length > 0)
            {
                DB.UseDataReader(query, readAction);
            }

            return(all);
        }