Merge branch 'main' of https://git.azuze.fr/kawa/Sharepoint-Toolbox
This commit is contained in:
@@ -22,7 +22,10 @@ public partial class FolderBrowserDialog : Window
|
||||
public IReadOnlyList<string> SelectedFilePaths { get; private set; } = Array.Empty<string>();
|
||||
|
||||
private readonly List<CheckBox> _fileCheckboxes = new();
|
||||
<<<<<<< HEAD
|
||||
private readonly List<TreeViewItem> _expandedNodes = new();
|
||||
=======
|
||||
>>>>>>> f4cc81bb71b935c6f6f050288c9e283dcca5cfa8
|
||||
|
||||
/// <summary>
|
||||
/// Dialog for browsing library folders. Set <paramref name="allowFileSelection"/>
|
||||
@@ -81,7 +84,10 @@ public partial class FolderBrowserDialog : Window
|
||||
// Placeholder child so the expand arrow appears.
|
||||
node.Items.Add(new TreeViewItem { Header = "Loading..." });
|
||||
node.Expanded += FolderNode_Expanded;
|
||||
<<<<<<< HEAD
|
||||
_expandedNodes.Add(node);
|
||||
=======
|
||||
>>>>>>> f4cc81bb71b935c6f6f050288c9e283dcca5cfa8
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -101,9 +107,18 @@ public partial class FolderBrowserDialog : Window
|
||||
{
|
||||
var folder = _ctx.Web.GetFolderByServerRelativeUrl(info.ServerRelativeUrl);
|
||||
_ctx.Load(folder, f => f.StorageMetrics.TotalSize,
|
||||
<<<<<<< HEAD
|
||||
f => f.StorageMetrics.TotalFileCount);
|
||||
var list = _ctx.Web.Lists.GetByTitle(info.LibraryTitle);
|
||||
_ctx.Load(list, l => l.Title);
|
||||
=======
|
||||
f => f.StorageMetrics.TotalFileCount,
|
||||
f => f.Folders.Include(sf => sf.Name, sf => sf.ServerRelativeUrl,
|
||||
sf => sf.StorageMetrics.TotalSize,
|
||||
sf => sf.StorageMetrics.TotalFileCount),
|
||||
f => f.Files.Include(fi => fi.Name, fi => fi.Length,
|
||||
fi => fi.ServerRelativeUrl));
|
||||
>>>>>>> f4cc81bb71b935c6f6f050288c9e283dcca5cfa8
|
||||
var progress = new Progress<Core.Models.OperationProgress>();
|
||||
await ExecuteQueryRetryHelper.ExecuteQueryRetryAsync(_ctx, progress, CancellationToken.None);
|
||||
|
||||
@@ -114,6 +129,7 @@ public partial class FolderBrowserDialog : Window
|
||||
folder.StorageMetrics.TotalFileCount,
|
||||
folder.StorageMetrics.TotalSize);
|
||||
|
||||
<<<<<<< HEAD
|
||||
// Enumerate direct children via paginated CAML — Folder.Folders /
|
||||
// Folder.Files lazy loading hits the list-view threshold on libraries
|
||||
// above 5,000 items even when only a small folder is being expanded.
|
||||
@@ -191,6 +207,53 @@ public partial class FolderBrowserDialog : Window
|
||||
node.Items.Add(fileItem);
|
||||
}
|
||||
}
|
||||
=======
|
||||
// Child folders first
|
||||
foreach (var subFolder in folder.Folders)
|
||||
{
|
||||
if (subFolder.Name.StartsWith("_") || subFolder.Name == "Forms")
|
||||
continue;
|
||||
|
||||
var childRelative = string.IsNullOrEmpty(info.RelativePath)
|
||||
? subFolder.Name
|
||||
: $"{info.RelativePath}/{subFolder.Name}";
|
||||
|
||||
var childInfo = new FolderNodeInfo(
|
||||
info.LibraryTitle, childRelative, subFolder.ServerRelativeUrl);
|
||||
|
||||
var childNode = MakeFolderNode(
|
||||
FormatFolderHeader(subFolder.Name,
|
||||
subFolder.StorageMetrics.TotalFileCount,
|
||||
subFolder.StorageMetrics.TotalSize),
|
||||
childInfo);
|
||||
node.Items.Add(childNode);
|
||||
}
|
||||
|
||||
// Files under this folder — only shown when selection is enabled.
|
||||
if (_allowFileSelection)
|
||||
{
|
||||
foreach (var file in folder.Files)
|
||||
{
|
||||
// Library-relative path for the file (used by the transfer service)
|
||||
var fileRel = string.IsNullOrEmpty(info.RelativePath)
|
||||
? file.Name
|
||||
: $"{info.RelativePath}/{file.Name}";
|
||||
|
||||
var cb = new CheckBox
|
||||
{
|
||||
Content = $"{file.Name} ({FormatSize(file.Length)})",
|
||||
Tag = new FileNodeInfo(info.LibraryTitle, fileRel),
|
||||
Margin = new Thickness(4, 2, 0, 2),
|
||||
};
|
||||
cb.Checked += FileCheckbox_Toggled;
|
||||
cb.Unchecked += FileCheckbox_Toggled;
|
||||
_fileCheckboxes.Add(cb);
|
||||
|
||||
var fileItem = new TreeViewItem { Header = cb, Focusable = false };
|
||||
node.Items.Add(fileItem);
|
||||
}
|
||||
}
|
||||
>>>>>>> f4cc81bb71b935c6f6f050288c9e283dcca5cfa8
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -305,6 +368,7 @@ public partial class FolderBrowserDialog : Window
|
||||
Close();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
Loaded -= OnLoaded;
|
||||
@@ -320,6 +384,8 @@ public partial class FolderBrowserDialog : Window
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> f4cc81bb71b935c6f6f050288c9e283dcca5cfa8
|
||||
private record FolderNodeInfo(string LibraryTitle, string RelativePath, string ServerRelativeUrl);
|
||||
private record FileNodeInfo(string LibraryTitle, string RelativePath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user