public override NCMIS.ObjectModel.PathedCmisObjectList GetChildren(string repositoryId, string folderId, int?maxItems, int skipCount, string orderBy, string filter, IncludeRelationships includeRelationships, string renditionFilter, bool includeAllowableActions, bool includePathSegment) { Kooboo.CMS.Content.Models.Repository repository = new Models.Repository(repositoryId); IObjectService folderService = ObjectService.GetService(typeof(Folder)); string objectId = folderId; folderService.TryPraseObjectId(objectId, out folderId); FolderType folderType = CmisFolderHelper.IdentifyFolderType(repository, folderId); PathedCmisObjectList pathedList = new PathedCmisObjectList(); IEnumerable <PathedCmisObject> children = folderService.GetChildren(repositoryId, objectId, filter, includeRelationships) .Select(it => new PathedCmisObject() { Object = it }); var count = children.Count(); pathedList.NumItems = count.ToString(); pathedList.HasMoreItems = false; //IEnumerable<ContentBase> contents = new ContentBase[0]; if (folderType == FolderType.Content_Folder || folderType == FolderType.Media_Folder) { var folder = CmisFolderHelper.Parse(repository, folderId).AsActual(); IContentQuery <ContentBase> contentQuery = null; if (folder is TextFolder) { var textFolder = (TextFolder)folder; var schema = new Schema(repository, textFolder.SchemaName).AsActual(); contentQuery = textFolder.CreateQuery(); if (!string.IsNullOrEmpty(filter)) { foreach (var item in schema.Columns) { contentQuery = contentQuery.Or(new WhereContainsExpression(null, item.Name, filter)); } } } else { var mediaFolder = (TextFolder)folder; contentQuery = mediaFolder.CreateQuery(); if (!string.IsNullOrEmpty(filter)) { contentQuery = contentQuery.WhereContains("FileName", filter); } } if (!string.IsNullOrEmpty(orderBy)) { contentQuery = contentQuery.OrderBy(orderBy); } count = contentQuery.Count(); var take = maxItems.HasValue ? maxItems.Value : count; pathedList.NumItems = count.ToString(); pathedList.HasMoreItems = count > count + take; children = children.Concat(contentQuery.Select(it => new PathedCmisObject() { Object = ObjectConvertor.ToCmis((TextContent)(it), includeRelationships != IncludeRelationships.None) }).Take(take)); } pathedList.Objects = children.ToArray(); return(pathedList); }
public override NCMIS.ObjectModel.PathedCmisObjectList GetChildren(string repositoryId, string folderId, int? maxItems, int skipCount, string orderBy, string filter, IncludeRelationships includeRelationships, string renditionFilter, bool includeAllowableActions, bool includePathSegment) { Kooboo.CMS.Content.Models.Repository repository = new Models.Repository(repositoryId); IObjectService folderService = ObjectService.GetService(typeof(Folder)); string objectId = folderId; folderService.TryPraseObjectId(objectId, out folderId); FolderType folderType = CmisFolderHelper.IdentifyFolderType(repository, folderId); PathedCmisObjectList pathedList = new PathedCmisObjectList(); IEnumerable<PathedCmisObject> children = folderService.GetChildren(repositoryId, objectId, filter, includeRelationships) .Select(it => new PathedCmisObject() { Object = it }); var count = children.Count(); pathedList.NumItems = count.ToString(); pathedList.HasMoreItems = false; //IEnumerable<ContentBase> contents = new ContentBase[0]; if (folderType == FolderType.Content_Folder || folderType == FolderType.Media_Folder) { var folder = CmisFolderHelper.Parse(repository, folderId).AsActual(); IContentQuery<ContentBase> contentQuery = null; if (folder is TextFolder) { var textFolder = (TextFolder)folder; var schema = new Schema(repository, textFolder.SchemaName).AsActual(); contentQuery = textFolder.CreateQuery(); if (!string.IsNullOrEmpty(filter)) { foreach (var item in schema.Columns) { contentQuery = contentQuery.Or(new WhereContainsExpression(null, item.Name, filter)); } } } else { var mediaFolder = (TextFolder)folder; contentQuery = mediaFolder.CreateQuery(); if (!string.IsNullOrEmpty(filter)) { contentQuery = contentQuery.WhereContains("FileName", filter); } } if (!string.IsNullOrEmpty(orderBy)) { contentQuery = contentQuery.OrderBy(orderBy); } count = contentQuery.Count(); var take = maxItems.HasValue ? maxItems.Value : count; pathedList.NumItems = count.ToString(); pathedList.HasMoreItems = count > count + take; children = children.Concat(contentQuery.Select(it => new PathedCmisObject() { Object = ObjectConvertor.ToCmis((TextContent)(it), includeRelationships != IncludeRelationships.None) }).Take(take)); } pathedList.Objects = children.ToArray(); return pathedList; }