public ActionResult LoadFileBrowserTreeData(LoadFileBrowserTreeDataParameters parameters)
        {
            try
            {
                var path = _storagePath;
                if (!string.IsNullOrEmpty(parameters.Path))
                {
                    path = Path.Combine(path, parameters.Path);
                }

                var request = new FileListOptions(path);
                var tree    = _htmlHandler.GetFileList(request);

                var result = new FileBrowserTreeDataResponse
                {
                    nodes = Utils.ToFileTreeNodes(parameters.Path, tree.Files).ToArray(),
                    count = tree.Files.Count
                };

                return(ToJsonResult(result));
            }
            catch (Exception e)
            {
                return(this.JsonOrJsonP(new FailedResponse {
                    Reason = e.Message
                }, null));
            }
        }
        public HttpResponseMessage loadFileTree(PostedDataWrapper postedData)
        {
            String relDirPath = "";

            // get posted data
            if (postedData != null)
            {
                relDirPath = postedData.path;
            }
            // get file list from storage path
            FileListOptions fileListOptions = new FileListOptions(relDirPath);
            // get temp directory name
            String tempDirectoryName = new ViewerConfig().CacheFolderName;

            try
            {
                FileListContainer fileListContainer = viewerHtmlHandler.GetFileList(fileListOptions);

                List <FileDescriptionWrapper> fileList = new List <FileDescriptionWrapper>();
                // parse files/folders list
                foreach (FileDescription fd in fileListContainer.Files)
                {
                    FileDescriptionWrapper fileDescription = new FileDescriptionWrapper();
                    fileDescription.guid = fd.Guid;
                    // check if current file/folder is temp directory or is hidden
                    if (tempDirectoryName.Equals(fd.Name) || new FileInfo(fileDescription.guid).Attributes.HasFlag(FileAttributes.Hidden))
                    {
                        // ignore current file and skip to next one
                        continue;
                    }
                    else
                    {
                        // set file/folder name
                        fileDescription.name = fd.Name;
                    }
                    // set file type
                    fileDescription.docType = fd.DocumentType;
                    // set is directory true/false
                    fileDescription.isDirectory = fd.IsDirectory;
                    // set file size
                    fileDescription.size = fd.Size;
                    // add object to array list
                    fileList.Add(fileDescription);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, fileList));
            }
            catch (Exception ex)
            {
                // set exception message
                ErrorMsgWrapper errorMsgWrapper = new ErrorMsgWrapper();
                errorMsgWrapper.message   = ex.Message;
                errorMsgWrapper.exception = ex;
                return(Request.CreateResponse(HttpStatusCode.OK, errorMsgWrapper));
            }
        }
Пример #3
0
        public JsonResult <List <string> > Get()
        {
            ViewerHtmlHandler      handler = Utils.CreateViewerHtmlHandler();
            List <FileDescription> tree    = null;

            tree = handler.GetFileList().Files;
            List <String> result = tree.Where(
                x => x.Name != "README.txt" &&
                !x.IsDirectory &&
                !String.IsNullOrWhiteSpace(x.Name) &&
                !String.IsNullOrWhiteSpace(x.FileFormat)
                ).Select(x => x.Name).ToList();

            return(Json(result));
        }
Пример #4
0
        public ActionResult LoadFileBrowserTreeData(LoadFileBrowserTreeDataParameters parameters)
        {
            var path = _storagePath;

            if (!string.IsNullOrEmpty(parameters.Path))
            {
                path = Path.Combine(path, parameters.Path);
            }

            var options   = new FileListOptions(path);
            var container = _htmlHandler.GetFileList(options);

            var result = new FileBrowserTreeDataResponse
            {
                nodes = Utils.ToFileTreeNodes(parameters.Path, container.Files).ToArray(),
                count = container.Files.Count
            };

            return(ToJsonResult(result));
        }
Пример #5
0
        public static FileBrowserTreeDataResponse LoadFileBrowserTreeData(LoadFileBrowserTreeDataParameters parameters)
        {
            var path = _storagePath;

            if (!string.IsNullOrEmpty(parameters.Path))
            {
                path = Path.Combine(path, parameters.Path);
            }



            var tree      = _htmlHandler.GetFileList(new FileListOptions(path));
            var treeNodes = tree.Files;
            var data      = new FileBrowserTreeDataResponse
            {
                nodes = ToFileTreeNodes(parameters.Path, treeNodes).ToArray(),
                count = tree.Files.Count
            };

            return(data);
        }
Пример #6
0
        public ActionResult Get()
        {
            ViewerHtmlHandler      handler = Utils.CreateViewerHtmlHandler();
            List <FileDescription> tree    = null;

            try
            {
                tree = handler.GetFileList().Files;
            }
            catch (Exception)
            {
                throw;
            }
            List <String> result = tree.Where(x => x.Name != "README.txt" &&
                                              !x.IsDirectory &&
                                              !String.IsNullOrWhiteSpace(x.Name) &&
                                              !String.IsNullOrWhiteSpace(x.DocumentType))
                                   .Select(x => x.Name).ToList();

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        //   [ScriptMethod(UseHttpGet = true)]
        public static string files()
        {
            ViewerHtmlHandler      handler = Utils.CreateViewerHtmlHandler();
            List <FileDescription> tree    = null;

            try
            {
                tree = handler.GetFileList().Files;
            }
            catch (Exception)
            {
                throw;
            }
            List <String> result = tree.Where(x => x.Name != "README.txt" &&
                                              !x.IsDirectory &&
                                              !String.IsNullOrWhiteSpace(x.Name) &&
                                              !String.IsNullOrWhiteSpace(x.DocumentType))
                                   .Select(x => x.Name).ToList();

            return(JsonConvert.SerializeObject(
                       result
                       ));
        }