/// <summary> /// Gets the element by path. /// </summary> /// <param name="path">The path.</param> /// <returns></returns> public static FolderElement[] GetElementsByPath(string path) { FolderElement[] retVal = null; char delim = '/'; string[] folderParts = path.Split(new char[] { delim }); //Incorrect path if (folderParts.Length == 0) { return(retVal); } string rootFolderName = folderParts[0]; FilterElement filter = new FilterElement("Name", FilterElementType.Equal, rootFolderName); Folder[] folders = Folder.List(filter); if (folders.Length != 0) { Folder rootFolder = folders[0]; rootFolder = FindFolderByPattern(rootFolder, rootFolder.Name, delim, String.Join(delim.ToString(), folderParts)); if (rootFolder != null) { FilterElement filterElem = new FilterElement("ParentId", FilterElementType.Equal, rootFolder.PrimaryKeyId.Value); retVal = FolderElement.List(filterElem); } } return(retVal); }
/// <summary> /// Copies the specified folder id. /// </summary> /// <param name="folderId">The folder id.</param> /// <param name="parentId">The parent id.</param> public static void CopyRecursive(int folderId, int parentId) { Folder srcFolder = new Folder(folderId); Folder newFolder = (Folder)srcFolder.Clone(); newFolder.Save(); Move(newFolder, parentId); parentId = (int)newFolder.PrimaryKeyId.Value; TreeNode[] nodes = TreeManager.GetChildNodes(GetAssignedMetaClass(), folderId); foreach (TreeNode node in nodes) { CopyRecursive(node.ObjectId, parentId); } FolderElement[] elements = FolderElement.List <FolderElement>(FolderElement.GetAssignedMetaClass(), new FilterElement[] { new FilterElement("ParentId", FilterElementType.Equal, folderId) }); foreach (FolderElement element in elements) { FolderElement.Copy(element, parentId); } }