protected override IEnumerable <NodeBase> GetChildren(DirectoryNode parent, NodeType nodeType) { if (!parent.Exists()) { return(Enumerable.Empty <NodeBase>()); } var children = _store[parent].Children; return(children); }
protected override IEnumerable <NodeBase> GetChildren(DirectoryNode parent, NodeType nodeType) { try { if (!parent.Exists()) { return(Enumerable.Empty <NodeBase>()); } using (var scope = _factory.CreateScope()) { var children = new List <NodeBase>(); var uow = scope.ServiceProvider.GetRequiredService <IUnitOfWork>(); var parentFolder = CompositeFileSystemHelper.FolderPathToEntity(uow, _userEntity, parent.Path.StringPath); _userEntity.tbl_UserFolder = uow.UserFolders.Get(QueryExpressionFactory.GetQueryExpression <tbl_UserFolder>() .Where(x => x.IdentityId == _userEntity.IdentityId).ToLambda()) .ToList(); _userEntity.tbl_UserFile = uow.UserFiles.Get(QueryExpressionFactory.GetQueryExpression <tbl_UserFile>() .Where(x => x.IdentityId == _userEntity.IdentityId).ToLambda()) .ToList(); foreach (var folder in _userEntity.tbl_UserFolder.Where(x => x.IdentityId == _userEntity.IdentityId && x.ParentId == parentFolder.Id)) { children.Add(new DirectoryNode(folder.VirtualName, parent, new NodeTimeInfo(folder.Created, folder.LastAccessed, folder.LastUpdated))); } foreach (var file in _userEntity.tbl_UserFile.Where(x => x.IdentityId == _userEntity.IdentityId && x.FolderId == parentFolder.Id)) { children.Add(new FileNode(file.VirtualName, parent, new NodeTimeInfo(file.Created, file.LastAccessed, file.LastUpdated))); } return(children); } } catch (Exception ex) { Log.Error(ex.ToString()); throw; } }
protected override IEnumerable <NodeBase> GetChildren(DirectoryNode parent, NodeType nodeType) { try { if (!parent.Exists()) { return(Enumerable.Empty <NodeBase>()); } var children = new List <NodeBase>(); WindowsIdentity.RunImpersonated(_userToken, () => { var parentFolder = SmbFileSystemHelper.FolderPathToCIFS(_userMount + parent.Path.StringPath); foreach (var folderPath in Directory.GetDirectories(parentFolder.FullName)) { var folder = new DirectoryInfo(folderPath); children.Add(new DirectoryNode(folder.Name, parent, new NodeTimeInfo(folder.CreationTime, folder.LastAccessTime, folder.LastWriteTime))); } foreach (var filePath in Directory.GetFiles(parentFolder.FullName)) { var file = new FileInfo(filePath); children.Add(new FileNode(file.Name, parent, new NodeTimeInfo(file.CreationTime, file.LastAccessTime, file.LastWriteTime))); } }); return(children); } catch (Exception ex) { Log.Error(ex.ToString()); throw; } }