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)); } }
public List <FileDescription> LoadFileTree(FileTreeOptions fileTreeOptions) { Uri uri = Uri.IsWellFormedUriString(fileTreeOptions.Path, UriKind.Absolute) ? new Uri(fileTreeOptions.Path) : GetUriFromGuid(fileTreeOptions.Path); FtpWebRequest request = GetFtpRequest(uri, WebRequestMethods.Ftp.ListDirectory); List <FileDescription> result = new List <FileDescription>(); using (FtpWebResponse response = (FtpWebResponse)request.GetResponse()) { Stream responseStream = response.GetResponseStream(); if (responseStream != null) { using (StreamReader reader = new StreamReader(responseStream)) { string guid; while ((guid = reader.ReadLine()) != null) { result.Add(new FileDescription(guid, !guid.Contains("."))); } } } } return(result); }
/// <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); }
public HttpResponseMessage loadFileTree(AnnotationPostedDataEntity fileTreeRequest) { string relDirPath = fileTreeRequest.path; // get file list from storage path FileTreeOptions fileListOptions = new FileTreeOptions(relDirPath); // get temp directory name string tempDirectoryName = new AnnotationConfig().TempFolderName; try { FileTreeContainer fileListContainer = AnnotationImageHandler.LoadFileTree(fileListOptions); List <FileDescriptionEntity> fileList = new List <FileDescriptionEntity>(); // parse files/folders list foreach (FileDescription fd in fileListContainer.FileTree) { FileDescriptionEntity fileDescription = new FileDescriptionEntity(); fileDescription.guid = fd.Guid; // check if current file/folder is temp directory or is hidden FileInfo fileInfo = new FileInfo(fileDescription.guid); if (tempDirectoryName.ToLower().Equals(fileDescription.guid) || fileInfo.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 (System.Exception ex) { // set exception message return(Request.CreateResponse(HttpStatusCode.OK, new Resources().GenerateException(ex))); } }
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)); }
/// <summary> /// Load file tree list for custom path /// </summary> public static void LoadFileTree_CustomPath() { Console.WriteLine("***** {0} *****", "Load file tree list for custom path"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Load file tree list for custom path var options = new FileTreeOptions(@"D:\"); FileTreeContainer container = imageHandler.LoadFileTree(options); foreach (var node in container.FileTree) { if (node.IsDirectory) { Console.WriteLine("Guid: {0} | Name: {1} | LastModificationDate: {2}", node.Guid, node.Name, node.LastModificationDate); } else Console.WriteLine("Guid: {0} | Name: {1} | Document type: {2} | File type: {3} | Extension: {4} | Size: {5} | LastModificationDate: {6}", node.Guid, node.Name, node.DocumentType, node.FileType, node.Extension, node.Size, node.LastModificationDate); } }
/// <summary> /// Load directory structure as file tree /// </summary> /// <param name="Path"></param> public static void LoadFileTree(String Path) { //ExStart:LoadFileTree // Create/initialize image handler ViewerImageHandler imageHandler = new ViewerImageHandler(Utilities.GetConfigurations()); // Load file tree list for custom path var options = new FileTreeOptions(Path); // Load file tree list for ViewerConfig.StoragePath FileTreeContainer container = imageHandler.LoadFileTree(options); foreach (var node in container.FileTree) { if (node.IsDirectory) { Console.WriteLine("Guid: {0} | Name: {1} | LastModificationDate: {2}", node.Guid, node.Name, node.LastModificationDate); } else { Console.WriteLine("Guid: {0} | Name: {1} | Document type: {2} | File type: {3} | Extension: {4} | Size: {5} | LastModificationDate: {6}", node.Guid, node.Name, node.DocumentType, node.FileType, node.Extension, node.Size, node.LastModificationDate); } } //ExEnd:LoadFileTree }
/// <summary> /// Loads files/folders structure for specified path /// </summary> /// <param name="fileTreeOptions">The file tree options.</param> /// <returns>System.Collections.Generic.List<GroupDocs.Viewer.Domain.FileDescription>.</returns> public List <FileDescription> LoadFileTree(FileTreeOptions fileTreeOptions) { try { string path = GetNormalizedBlobName(fileTreeOptions.Path); List <FileDescription> fileTree = GetFileTree(path); switch (fileTreeOptions.OrderBy) { case FileTreeOptions.FileTreeOrderBy.Name: fileTree = fileTreeOptions.OrderAsc ? fileTree.OrderBy(_ => _.Name).ToList() : fileTree.OrderByDescending(_ => _.Name).ToList(); break; case FileTreeOptions.FileTreeOrderBy.LastModificationDate: fileTree = fileTreeOptions.OrderAsc ? fileTree.OrderBy(_ => _.LastModificationDate).ToList() : fileTree.OrderByDescending(_ => _.LastModificationDate).ToList(); break; case FileTreeOptions.FileTreeOrderBy.Size: fileTree = fileTreeOptions.OrderAsc ? fileTree.OrderBy(_ => _.Size).ToList() : fileTree.OrderByDescending(_ => _.Size).ToList(); break; default: break; } return(fileTree); } catch (StorageException ex) { throw new System.Exception("Failed to load file tree.", ex); } }
public List<FileDescription> LoadFileTree(FileTreeOptions fileTreeOptions) { throw new NotImplementedException(); }
public List <FileDescription> LoadFileTree(FileTreeOptions fileTreeOptions) { //TODO return(new List <FileDescription>()); }
public List <FileDescription> LoadFileTree(FileTreeOptions fileTreeOptions) { throw new NotImplementedException(); }
public List<FileDescription> LoadFileTree(FileTreeOptions fileTreeOptions) { Uri uri = Uri.IsWellFormedUriString(fileTreeOptions.Path, UriKind.Absolute) ? new Uri(fileTreeOptions.Path) : GetUriFromGuid(fileTreeOptions.Path); FtpWebRequest request = GetFtpRequest(uri, WebRequestMethods.Ftp.ListDirectory); List<FileDescription> result = new List<FileDescription>(); using (FtpWebResponse response = (FtpWebResponse)request.GetResponse()) { Stream responseStream = response.GetResponseStream(); if (responseStream != null) { using (StreamReader reader = new StreamReader(responseStream)) { string guid; while ((guid = reader.ReadLine()) != null) { result.Add(new FileDescription(guid, !guid.Contains("."))); } } } } return result; }