コード例 #1
0
        JsonResult IDriver.Init(string target)
        {
            FullPath fullPath;
            if (string.IsNullOrEmpty(target))
            {
                Root root = _roots.FirstOrDefault(r => r.StartPath != null);
                if (root == null)
                    root = _roots.First();
                fullPath = new FullPath(root, root.StartPath??root.Directory);
            }
            else
            {
                fullPath = ParsePath(target);
            }
            InitResponse answer = new InitResponse(DTOBase.Create(fullPath.Directory, fullPath.Root), new Options(fullPath));            

            foreach (FileInfo item in fullPath.Directory.GetFiles())
            {
                if ((item.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                    answer.Files.Add(DTOBase.Create(item, fullPath.Root));
            }
            foreach (DirectoryInfo item in fullPath.Directory.GetDirectories())
            {
                if ((item.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                    answer.Files.Add(DTOBase.Create(item, fullPath.Root));
            }
            foreach (Root item in _roots)
            {
                answer.Files.Add(DTOBase.Create(item.Directory, item));
            }
            if (fullPath.Root.Directory.FullName != fullPath.Directory.FullName)
            {
                foreach (DirectoryInfo item in fullPath.Root.Directory.GetDirectories())
                {
                    if ((item.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                        answer.Files.Add(DTOBase.Create(item, fullPath.Root));
                }
            }
            if(fullPath.Root.MaxUploadSize.HasValue)
            {
                answer.UploadMaxSize = fullPath.Root.MaxUploadSizeInKb.Value + "K";
            }
            return Json(answer);
        }
コード例 #2
0
        JsonResult IDriver.Init(string target)
        {
            Root root;
            DirectoryInfo dir;
            if (string.IsNullOrEmpty(target))
            {
                root = _roots.FirstOrDefault(r => r.StartPath != null);
                if (root == null)
                    root = _roots.First();
                dir = root.StartPath == null ? root.Directory : root.StartPath;
            }
            else
            {
                FullPath fullPath = ParsePath(target);
                root = fullPath.Root;
                dir = fullPath.Directory;
            }
            InitResponse answer = new InitResponse(DTOBase.Create(dir, root));
            

            foreach (var item in dir.GetFiles())
            {
                answer.AddResponse(DTOBase.Create(item, root));
            }
            foreach (var item in dir.GetDirectories())
            {
                answer.AddResponse(DTOBase.Create(item, root));
            }
            foreach (var item in _roots)
            {
                answer.AddResponse(DTOBase.Create(item.Directory, item));
            }
            if (root.Directory.FullName != dir.FullName)
            {
                foreach (var item in root.Directory.GetDirectories())
                {
                    answer.AddResponse(DTOBase.Create(item, root));
                }
            }
            string parentPath = string.IsNullOrEmpty(target) ? root.Alias : root.Alias + dir.FullName.Substring(root.Directory.FullName.Length).Replace('\\', '/');
            answer.Options.Path = parentPath;
            answer.Options.Url = root.Url;
            answer.Options.ThumbnailsUrl = root.TmbUrl;
            return Json(answer);
        }