Example #1
0
        public IEnumerable <IArchive> GetArchivesByCategoryPath(string catPath, bool includeChild, int number,
                                                                int skipSize)
        {
            var ic = _catRepo.GetCategoryByPath(SiteId, catPath);

            int[] catIdArray;
            if (includeChild)
            {
                catIdArray = GetCatArrayByPath(ic);
                if (catIdArray.Length == 0)
                {
                    return(new List <IArchive>());
                }
            }
            else
            {
                catIdArray = new[] { ic.GetDomainId() };
            }

            return(_archiveRep.GetArchivesContainChildCategories(SiteId, catIdArray, number, skipSize));
        }
Example #2
0
        public DataTable GetPagedArchives(
            int siteId,
            string catPath,
            int pageSize,
            int skipSize,
            ref int pageIndex,
            out int records,
            out int pages,
            out IDictionary <int, IDictionary <string, string> > extendValues)
        {
            var ic         = _catRepo.GetCategoryByPath(siteId, catPath);
            var catIdArray = GetCatArrayByPath(ic);
            //获取数据
            var dt = _archiveQuery.GetPagedArchives(siteId, catIdArray,
                                                    pageSize, skipSize, ref pageIndex, out records, out pages);

            IList <int> archiveIds = new List <int>();

            foreach (DataRow dr in dt.Rows)
            {
                archiveIds.Add(int.Parse(dr["id"].ToString()));
            }


            var dict = _extendRep.GetExtendFieldValuesList(
                siteId,
                ExtendRelationType.Archive,
                archiveIds
                );

            extendValues = new Dictionary <int, IDictionary <string, string> >();
            foreach (var key in dict.Keys)
            {
                if (!extendValues.ContainsKey(key))
                {
                    extendValues.Add(key, new Dictionary <string, string>());
                }
                foreach (var value in dict[key])
                {
                    // 避免重复键
                    if (!extendValues[key].ContainsKey(value.Field.Name))
                    {
                        extendValues[key].Add(value.Field.Name, value.Value);
                    }
                    else
                    {
                        extendValues[key][value.Field.Name] = value.Value;
                    }
                }
            }

            return(dt);
        }
Example #3
0
        public IEnumerable <CategoryDto> GetCategories(
            int siteId, string catPath)
        {
            var site = repo.GetSiteById(siteId);
            var ic   = _categoryRep.GetCategoryByPath(siteId, catPath);

            if (ic == null)
            {
                yield break;
            }
            foreach (var category in ic.NextLevelChilds)
            {
                yield return(CategoryDto.ConvertFrom(category));
            }
        }
Example #4
0
 public ICategory GetCategoryByPath(string path)
 {
     return(_categoryRep.GetCategoryByPath(GetAggregaterootId(), path));
 }