Ejemplo n.º 1
0
        public async Task <JsonResult> ParentsAsync(FullPath path)
        {
            var response = new TreeResponseModel();

            if (path.Directory.FullName == path.RootVolume.RootDirectory)
            {
                response.Tree.Add(await BaseModel.CreateAsync(path.Directory, path.RootVolume));
            }
            else
            {
                var parent = path.Directory;

                foreach (var item in await parent.Parent.GetDirectoriesAsync())
                {
                    response.Tree.Add(await BaseModel.CreateAsync(item, path.RootVolume));
                }

                while (parent.FullName != path.RootVolume.RootDirectory)
                {
                    parent = parent.Parent;
                    response.Tree.Add(await BaseModel.CreateAsync(parent, path.RootVolume));
                }
            }

            return(await Json(response));
        }
Ejemplo n.º 2
0
        public async Task <JsonResult> TreeAsync(FullPath path)
        {
            var response = new TreeResponseModel();

            foreach (var item in await path.Directory.GetDirectoriesAsync())
            {
                if (!item.Attributes.HasFlag(FileAttributes.Hidden))
                {
                    response.Tree.Add(await BaseModel.CreateAsync(item, path.RootVolume));
                }
            }
            return(await Json(response));
        }
Ejemplo n.º 3
0
        public async Task <JsonResult> Tree(string target)
        {
            FullPath          fullPath = ParsePath(target);
            TreeResponseModel answer   = new TreeResponseModel();

            foreach (var item in fullPath.Directory.GetDirectories())
            {
                if ((item.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                {
                    answer.Tree.Add(BaseModel.Create(item, fullPath.Root));
                }
            }
            return(await Json(answer));
        }
        public async Task <JsonResult> ParentsAsync(FullPath path)
        {
            var response = new TreeResponseModel();

            if (path.Directory.FullName == path.RootVolume.RootDirectory)
            {
                response.Tree.Add(await BaseModel.Create(this, path.Directory, path.RootVolume));
            }
            else
            {
                // Not root level

                // Go back to root
                var parent = path.Directory;

                while (parent != null && parent.Name != path.RootVolume.RootDirectory)
                {
                    // Update parent
                    parent = parent.Parent;

                    // Ensure it's a child of the root
                    if (parent != null && path.RootVolume.RootDirectory.Contains(parent.Name))
                    {
                        response.Tree.Insert(0, await BaseModel.Create(this, parent, path.RootVolume));
                    }
                }

                // Check that directory has a parent
                if (path.Directory.Parent != null)
                {
                    var items = await AzureStorageAPI.ListFilesAndDirectories(path.Directory.Parent.FullName);

                    // Add all visible directories except the target
                    foreach (var dir in items.Where(i => i is CloudFileDirectory && ((CloudFileDirectory)i).Name != path.Directory.Name))
                    {
                        var d = new AzureStorageDirectory(dir as CloudFileDirectory);
                        if (!d.Attributes.HasFlag(FileAttributes.Hidden))
                        {
                            response.Tree.Add(await BaseModel.Create(this, d, path.RootVolume));
                        }
                    }
                }
            }
            return(await Json(response));
        }
Ejemplo n.º 5
0
        public async Task <JsonResult> TreeAsync(FullPath path)
        {
            var response = new TreeResponseModel();

            var items = await AzureStorageAPI.ListFilesAndDirectoriesAsync(path.Directory.FullName);

            // Add visible directories
            foreach (var dir in items.Where(i => i is CloudFileDirectory))
            {
                var d = new AzureStorageDirectory(dir as CloudFileDirectory);
                if (!d.Attributes.HasFlag(FileAttributes.Hidden))
                {
                    response.Tree.Add(await BaseModel.CreateAsync(d, path.RootVolume));
                }
            }

            return(await Json(response));
        }
Ejemplo n.º 6
0
        public async Task <JsonResult> Parents(string target)
        {
            FullPath          fullPath = ParsePath(target);
            TreeResponseModel answer   = new TreeResponseModel();

            if (fullPath.Directory.FullName == fullPath.Root.Directory.FullName)
            {
                answer.Tree.Add(BaseModel.Create(fullPath.Directory, fullPath.Root));
            }
            else
            {
                DirectoryInfo parent = fullPath.Directory;
                foreach (var item in parent.Parent.GetDirectories())
                {
                    answer.Tree.Add(BaseModel.Create(item, fullPath.Root));
                }
                while (parent.FullName != fullPath.Root.Directory.FullName)
                {
                    parent = parent.Parent;
                    answer.Tree.Add(BaseModel.Create(parent, fullPath.Root));
                }
            }
            return(await Json(answer));
        }