public ActionResult LoadFileBrowserTreeData(LoadFileBrowserTreeDataParameters parameters)
        {
            var path = _storagePath;

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



            var tree      = _htmlHandler.LoadFileTree(new FileTreeOptions(path));
            var treeNodes = tree.FileTree;
            var data      = new FileBrowserTreeDataResponse
            {
                nodes = ToFileTreeNodes(parameters.Path, treeNodes).ToArray(),
                count = tree.FileTree.Count
            };

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            var serializedData = serializer.Serialize(data);

            return(Content(serializedData, "application/json"));
        }
Пример #2
0
        public ActionResult LoadFileBrowserTreeData(LoadFileBrowserTreeDataParameters parameters)
        {
            try
            {
                var path = _storagePath;
                if (!string.IsNullOrEmpty(parameters.Path))
                {
                    path = Path.Combine(path, parameters.Path);
                }

                var request = new FileTreeOptions(path);
                var tree    = _htmlHandler.LoadFileTree(request);

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

                return(ToJsonResult(result));
            }
            catch (Exception e)
            {
                return(this.JsonOrJsonP(new FailedResponse {
                    Reason = e.Message
                }, null));
            }
        }
        /// <summary>
        /// How to use custom input data handler
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("***** {0} *****", "How to use custom input data handler");

            /* ********************* SAMPLE ********************* */

            // Setup GroupDocs.Viewer config
            ViewerConfig config = new ViewerConfig();
            config.StoragePath = @"C:\storage";

            // File guid
            string guid = @"word.doc";

            // Use custom IInputDataHandler implementation
            IInputDataHandler inputDataHandler = new FtpInputDataHandler();

            // Get file HTML representation
            ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config, inputDataHandler);

            List<PageHtml> pages = htmlHandler.GetPages(guid);

            Console.WriteLine("Pages count: {0}", pages.Count);

            // Get list of entities for ftp root folder
            FileTreeOptions options = new FileTreeOptions(@"ftp://localhost");
            FileTreeContainer container = htmlHandler.LoadFileTree(options);
        }
Пример #4
0
        public ActionResult LoadFileBrowserTreeData(LoadFileBrowserTreeDataParameters parameters)
        {
            var path = _storagePath;

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

            var request = new FileTreeOptions(path);
            var tree    = _htmlHandler.LoadFileTree(request);

            var result = new FileBrowserTreeDataResponse
            {
                nodes = Utils.ToFileTreeNodes(parameters.Path, tree.FileTree).ToArray(),
                count = tree.FileTree.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.LoadFileTree(new FileTreeOptions(path));
            var treeNodes = tree.FileTree;
            var data      = new FileBrowserTreeDataResponse
            {
                nodes = ToFileTreeNodes(parameters.Path, treeNodes).ToArray(),
                count = tree.FileTree.Count
            };

            return(data);
        }