Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        public JsonResult Init(string target)
        {
            var folders = mediaService.GetMediaFolders(null);
            var files   = mediaService.GetMediaFiles(null);

            var directory = new RootDto
            {
                Mime          = "directory",
                Dirs          = folders.Any() ? (byte)1 : (byte)0,
                Hash          = Helper.EncodePath("\\"),
                Locked        = 0,
                Name          = "Media",
                Read          = 1,
                Write         = 1,
                Size          = 0,
                UnixTimeStamp = (long)(DateTime.UtcNow - unixOrigin).TotalSeconds,
                VolumeId      = "v1"
            };

            var response = new InitResponse(directory);

            foreach (var file in files)
            {
                response.AddResponse(CreateDto(file));
            }

            foreach (var folder in folders)
            {
                response.AddResponse(CreateDto(folder, null));
            }

            response.Options.Path          = "Media";
            response.Options.Url           = "/";
            response.Options.ThumbnailsUrl = "/";

            return(Json(response));
        }
Exemplo n.º 3
0
        /// <summary> </summary>
        JsonResult IDriver.Init(string target, Hashtable posting_json_obj)
        {
            Root          root;
            DirectoryInfo dir;

            if (string.IsNullOrEmpty(target))
            {
                root = _roots.First();
                dir  = root.Directory;
            }
            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())
            {
                if (HttpContext.Current.Request.Params.AllKeys.Contains("mimes[]"))
                {
                    if (file_mime.mime_type(item.Extension.Trim('.')).IndexOf(HttpContext.Current.Request.Params["mimes[]"]) > -1)
                    {
                        answer.AddResponse(DTOBase.Create(item, root, posting_json_obj));
                    }
                }
                else
                {
                    answer.AddResponse(DTOBase.Create(item, root, posting_json_obj));
                }
            }
            foreach (var item in dir.GetDirectories())
            {
                answer.AddResponse(DTOBase.Create(item, root));
            }
            foreach (var item in _roots)
            {
                answer.AddResponse(DTOBase.Create(item.Directory, item));
            }
            foreach (var item in root.Directory.GetDirectories())
            {
                answer.AddResponse(DTOBase.Create(item, root));
            }
            //if (dir.FullName != root.Directory.FullName)
            //{
            //    foreach (var item in root.Directory.GetDirectories())
            //    {
            //        if (item.FullName == root.Directory.FullName)
            //        {
            //            foreach (var rootSubDir in item.GetDirectories())
            //            {
            //                if (rootSubDir.FullName != dir.FullName)
            //                {
            //                    answer.AddResponse(DTOBase.Create(rootSubDir, item));
            //                }
            //            }
            //        }
            //    }
            //}
            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.tmbUrl = root.TmbUrl;
            return(Json(answer));
        }