Ejemplo n.º 1
0
        /// <summary>
        /// 加载分类词典
        /// </summary>
        private void InitCategoryDictionary()
        {
            RepositoryDataCache._categories = new Dictionary <int, IList <ICategory> >();

            IList <ICategory> categories = new List <ICategory>();
            ICategory         ic;

            categoryDal.GetAllCategories(rd =>
            {
                while (rd.Read())
                {
                    var category         = new CmsCategoryEntity();
                    category.ID          = Convert.ToInt32(rd["id"]);
                    category.Title       = (rd["page_title"] ?? "").ToString();
                    category.Description = (rd["page_description"] ?? "").ToString();
                    category.Icon        = Convert.ToString(rd["icon"]);
                    category.Keywords    = Convert.ToString(rd["page_keywords"]);
                    category.Location    = Convert.ToString(rd["location"]);
                    category.Name        = Convert.ToString(rd["name"]);
                    category.Tag         = Convert.ToString(rd["tag"]);
                    category.ParentId    = Convert.ToInt32(rd["parent_id"]);
                    category.SiteId      = Convert.ToInt32(rd["site_id"]);
                    category.Flag        = Convert.ToInt32(rd["flag"]);
                    category.Path        = Convert.ToString(rd["path"]);
                    category.SortNumber  = Convert.ToInt32(rd["sort_number"]);

                    ic = CreateCategory(category);
                    if (ic.Site() != null)
                    {
                        categories.Add(ic);
                    }
                }
            });

            foreach (var _category in categories)
            {
                if (!RepositoryDataCache._categories.ContainsKey(_category.Site().GetAggregateRootId()))
                {
                    RepositoryDataCache._categories.Add(_category.Site().GetAggregateRootId(), new List <ICategory>());
                }
                RepositoryDataCache._categories[_category.Site().GetAggregateRootId()].Add(_category);

                //添加Id->Path映射
                var key = catIdKey(_category.Site().GetAggregateRootId(), _category.GetDomainId());
                Kvdb.Put(key, _category.Get().Path);
            }

            categories = null;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 加载分类词典
        /// </summary>
        private void InitCategoryDictionary()
        {
            RepositoryDataCache._categories = new Dictionary <int, IList <ICategory> >();

            IList <ICategory> categories = new List <ICategory>();
            ICategory         ic;

            categoryDal.GetAllCategories(rd =>
            {
                while (rd.Read())
                {
                    CmsCategoryEntity category = new CmsCategoryEntity();
                    category.ID          = Convert.ToInt32(rd["id"]);
                    category.Title       = (rd["page_title"] ?? "").ToString();
                    category.Description = (rd["page_description"] ?? "").ToString();
                    category.Icon        = Convert.ToString(rd["icon"]);
                    category.Keywords    = Convert.ToString(rd["page_keywords"]);
                    category.Location    = Convert.ToString(rd["location"]);
                    category.Name        = Convert.ToString(rd["name"]);
                    category.Tag         = Convert.ToString(rd["tag"]);
                    category.ParentId    = Convert.ToInt32(rd["parent_id"]);
                    category.SiteId      = Convert.ToInt32(rd["site_id"]);
                    category.Flag        = Convert.ToInt32(rd["flag"]);
                    category.Path        = Convert.ToString(rd["path"]);
                    category.SortNumber  = Convert.ToInt32(rd["sort_number"]);

                    ic = this.CreateCategory(category);
                    if (ic.Site() != null)
                    {
                        categories.Add(ic);
                    }
                }
            });

            //排序
            // IOrderedEnumerable<ICategory> categories2 = categories.OrderBy(a => a.ID);

            foreach (ICategory _category in categories)
            {
                if (!RepositoryDataCache._categories.ContainsKey(_category.Site().GetAggregaterootId()))
                {
                    RepositoryDataCache._categories.Add(_category.Site().GetAggregaterootId(), new List <ICategory>());
                }
                RepositoryDataCache._categories[_category.Site().GetAggregaterootId()].Add(_category);

                //添加Tag映射
                String key = this.catPathKey(_category.Site().GetAggregaterootId(), _category.Get().Path);
                Kvdb.PutInt(key, _category.Lft);

                /*
                 * if (_category.Site.Id == 1 && _category.Tag.IndexOf("duct") != -1)
                 * {
                 *  var x = "1:cache:t:lft:duct-machine" == String.Format("{0}:cache:t:lft:{1}",
                 *  _category.Site.Id.ToString(),
                 *  _category.Tag);
                 * }
                 */

                //添加Id映射
                key = this.catIdKey(_category.Site().GetAggregaterootId(), _category.GetDomainId());
                Kvdb.PutInt(key, _category.Lft);
            }
            //categories2 = null;
            categories = null;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 加载分类词典
        /// </summary>
        private void GetCategoryDictionary()
        {
            RepositoryDataCache._categories = new Dictionary <int, IList <ICategory> >();

            IList <ICategory> categories = new List <ICategory>();
            ICategory         category;

            categoryDal.GetAllCategories(rd =>
            {
                while (rd.Read())
                {
                    category = this.CreateCategory(
                        int.Parse(rd["id"].ToString()),
                        _siteRep.GetSiteById(int.Parse(rd["site_id"].ToString()))
                        );
                    category.PageTitle   = (rd["page_title"] ?? "").ToString();
                    category.Description = (rd["page_description"] ?? "").ToString();
                    category.Icon        = Convert.ToString(rd["icon"]);
                    category.Keywords    = Convert.ToString(rd["page_keywords"]);
                    category.Lft         = Convert.ToInt32(rd["lft"]);
                    category.Rgt         = Convert.ToInt32(rd["rgt"]);
                    category.Location    = Convert.ToString(rd["location"]);
                    category.Name        = Convert.ToString(rd["name"]);
                    category.Tag         = Convert.ToString(rd["tag"]);
                    category.SortNumber  = Convert.ToInt32(rd["sort_number"]);

                    categories.Add(category);
                }
            });

            //排序
            // IOrderedEnumerable<ICategory> categories2 = categories.OrderBy(a => a.ID);

            foreach (ICategory _category in categories)
            {
                if (!RepositoryDataCache._categories.ContainsKey(_category.Site.Id))
                {
                    RepositoryDataCache._categories.Add(_category.Site.Id, new List <ICategory>());
                }
                RepositoryDataCache._categories[_category.Site.Id].Add(_category);

                //添加Tag映射
                String key = this.catTagKey(_category.Site.Id, _category.Tag);
                Kvdb.PutInt(key, _category.Lft);

                /*
                 * if (_category.Site.Id == 1 && _category.Tag.IndexOf("duct") != -1)
                 * {
                 *  var x = "1:cache:t:lft:duct-machine" == String.Format("{0}:cache:t:lft:{1}",
                 *  _category.Site.Id.ToString(),
                 *  _category.Tag);
                 * }
                 */

                //添加Id映射
                key = this.catIdKey(_category.Site.Id, _category.Id);
                Kvdb.PutInt(key, _category.Lft);
            }
            //categories2 = null;
            categories = null;
        }