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 FileServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new FileService(this.StripeClient); this.createOptions = new FileCreateOptions { File = typeof(FileServiceTest).GetTypeInfo().Assembly.GetManifestResourceStream(FileName), FileLinkData = new FileLinkDataOptions { Create = true, Metadata = new Dictionary <string, string> { { "key", "value" }, }, }, Purpose = FilePurpose.BusinessLogo, }; this.listOptions = new FileListOptions { Limit = 1, }; }
private void AddFiles(FileListResponse response, FileListOptions options) { foreach (var file in response.files) { if (responseFiles.Count >= maxFilesTotal) { break; } var newFile = ResponseFile.FromFile(file); var res = responseUsers.Where(x => x.id == file.user); if (res.Count() > 0) { newFile.linkedUser = res.First(); if (file.username == "") { newFile.username = res.First().name; } } responseFiles.Add(newFile); } slackFiles.Items.Refresh(); PopulateFilterByFileType(); SetStatus($"Page received. (Received: {response.paging.page} Available: {response.paging.pages})"); SetProgress((response.paging.page) / ((double)maxFilesTotal / maxFilesPerPage) * 100.0, $"Receiving {response.paging.page} / {Math.Ceiling((double)maxFilesTotal / (double)maxFilesPerPage)}"); if (responseFiles.Count < maxFilesTotal && response.paging.page < response.paging.pages) { SetStatus($"Delaying next request by {apiCallDelay}ms..."); Task.Delay(apiCallDelay).ContinueWith(t => { options.page = response.paging.page + 1; GetFilesFromSlack(options); }); } }
private void GetFilesFromSlack(FileListOptions options) { if (client == null) { return; } client.GetFiles((response) => { if (options.page == null) { SetStatus($"Receiving first page..."); } else { SetStatus($"Receiving page {options.page}..."); } Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() => { AddFiles(response, options); })); }, channel: options.channel, userId: options.userId, from: options.from, to: options.to, count: options.count, page: options.page, types: options.types ); }
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)); } }
public FileServiceTest() { this.service = new FileService(); this.createOptions = new FileCreateOptions() { File = typeof(FileServiceTest).GetTypeInfo().Assembly.GetManifestResourceStream(FileName), Purpose = FilePurpose.BusinessLogo, }; this.listOptions = new FileListOptions() { Limit = 1, }; }
public FileServiceTest(MockHttpClientFixture mockHttpClientFixture) : base(mockHttpClientFixture) { this.service = new FileService(); this.createOptions = new FileCreateOptions { File = typeof(FileServiceTest).GetTypeInfo().Assembly.GetManifestResourceStream(FileName), Purpose = FilePurpose.BusinessLogo, }; this.listOptions = new FileListOptions { Limit = 1, }; }
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)); }
private void Connect_Click(object sender, RoutedEventArgs e) { if (Oauth_Value == "") { MessageBoxResult dialogResult = MessageBox.Show($"Oauth field is empty", "Error", MessageBoxButton.OK); return; } SetStatus("Connecting..."); if (ConnectToSlack() == null) { SetStatus("Can't connect. Maybe invalid Oauth?"); return; } ClearslackFiles(); maxFilesTotal = (int)MaxFiles.Value; maxFilesPerPage = Math.Min(maxFilesTotal, 100); if (ComboUser.Items.Count == 0) { GetUsersFromSlack(); } // First Run var options = new FileListOptions() { channel = (ComboChannels.SelectedItem == null) ? null : (ComboChannels.SelectedItem as ResponseChannel).id, userId = (ComboUser.SelectedItem == null) ? null : (ComboUser.SelectedItem as ResponseUser).id, from = DateFrom.SelectedDate, to = DateTo.SelectedDate, count = maxFilesPerPage, page = null, types = (FileTypes)ComboFileTypes.SelectedItem }; GetFilesFromSlack(options); }
/// <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 FileListOptions(Path); // Load file tree list for ViewerConfig.StoragePath FileListContainer container = imageHandler.GetFileList(options); foreach (var node in container.Files) { 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:LoadFioleTree }
public List <FileDescription> LoadFileTree(FileListOptions fileListOptions) { //TODO return(new List <FileDescription>()); }
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); }