Exemplo n.º 1
0
        public object doJSONAction()
        {
            FileExplorerParams args = FileExplorerOperations.GetAjaxData(Request);

            if (args.ActionType == "Upload")
            {
                FileExplorerOperations.Upload(args.Files, args.Path);
                return(new HttpResponseMessage()
                {
                    Content = new StringContent("ok", Encoding.UTF8, "text/plain")
                });
            }
            try
            {
                if (args.ActionType != "Paste" && args.ActionType != "GetDetails")
                {
                    var FilePath = FileExplorerOperations.ToPhysicalPath(FileExplorerOperations.ToAbsolute(args.Path));
                }
                switch (args.ActionType)
                {
                case "Read":
                    return(FileExplorerOperations.ReadData(args.Path, args.ExtensionsAllow));

                case "Search":
                    return(FileExplorerOperations.Search(args.Path, args.ExtensionsAllow, args.SearchString, args.CaseSensitive));

                case "CreateFolder":
                    return(FileExplorerOperations.NewFolder(args.Path, args.Name));

                case "Paste":
                    return(FileExplorerOperations.Paste(args.LocationFrom, args.LocationTo, args.Names, args.Action, args.CommonFiles));

                case "Remove":
                    return(FileExplorerOperations.Remove(args.Names, args.Path));

                case "Rename":
                    return(FileExplorerOperations.Rename(args.Path, args.Name, args.NewName, args.CommonFiles));

                case "GetDetails":
                    return(FileExplorerOperations.GetDetails(args.Path, args.Names));
                }
                return("");
            }
            catch (Exception e) {
                FileExplorerResponse Response = new FileExplorerResponse();
                Response.error = e.GetType().FullName + ", " + e.Message;
                return(Response);
            }
        }
Exemplo n.º 2
0
        public FileExplorerResponse GetDetails(string path, string[] names)
        {
            FileExplorerResponse DetailsResponse = new FileExplorerResponse();

            try
            {
                DetailsResponse = FileExplorerOperations.GetDetails(path, names);
                string physicalPath = GetPath(path);
                var    items        = DetailsResponse.details.ToArray();
                for (int i = 0; i < items.Length; i++)
                {
                    items[i].Permission = GetFilePermission(physicalPath, items[i].Name, items[i].Type != "File Folder");
                }
                DetailsResponse.details = items;
                return(DetailsResponse);
            }
            catch (Exception e)
            {
                DetailsResponse.error = e.GetType().FullName + ", " + e.Message;
                return(DetailsResponse);
            }
        }