示例#1
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);
        }
示例#2
0
        /// <summary>
        /// 获取包含扩展属性的文档列表
        /// </summary>
        /// <param name="siteId"></param>
        /// <param name="archives"></param>
        /// <returns></returns>
        private IEnumerable <IArchive> GetContainExtendValueArchiveList(int siteId, IEnumerable <IArchive> archives)
        {
            IDictionary <int, IList <IExtendValue> > extendValues = new Dictionary <int, IList <IExtendValue> >();

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

            foreach (var a in archives)
            {
                idList.Add(a.GetAggregateRootId());
            }

            //获取扩展信息
            extendValues = _extendRep.GetExtendFieldValuesList(siteId, ExtendRelationType.Archive, idList);
            foreach (var a in archives)
            {
                if (extendValues.ContainsKey(a.GetAggregateRootId()))
                {
                    a.SetExtendValue(extendValues[a.GetAggregateRootId()]);
                }
                yield return(a);
            }
        }