您需要为每张工作表再提供一个 API 请求来检索工作表上的共享列表。请记住,工作表可以直接在工作表上或通过工作区共享。
要直接或通过工作区获取与特定组共享的工作表,您可以使用类似下面的代码(此示例依赖 LINQ)。
SmartsheetClient cl = new SmartsheetBuilder()
.SetAccessToken(ACCESS_TOKEN)
.Build();
var includeAll = new PaginationParameters(true, null, null);
Console.WriteLine("Looking for group " + SOUGHT_GROUP_NAME);
var groups = cl.GroupResources.ListGroups(includeAll);
var soughtGroup = groups.Data.Single((group) => group.Name == SOUGHT_GROUP_NAME);
Console.WriteLine("Found group ID {0} for group {1}.", soughtGroup != null ? soughtGroup.Id.ToString() : "NULL", SOUGHT_GROUP_NAME);
if (soughtGroup == null)
throw new ArgumentException("Group not found");
var sheets = cl.SheetResources.ListSheets(null, includeAll);
Console.WriteLine("Querying through {0} sheets...", sheets.Data.Count);
var sheetsSharedWithGroup = from sheet in sheets.Data
from share in cl.SheetResources.ShareResources.ListShares(sheet.Id.Value, includeAll, ShareScope.Workspace).Data
where share.GroupId == soughtGroup.Id
select new { Sheet = sheet, Share = share };
var found = sheetsSharedWithGroup.ToList();
Console.WriteLine("Found {0} sheets shared with group {1}.", found.Count, SOUGHT_GROUP_NAME);
found.ForEach(foundSheet => Console.WriteLine("Sheet {0} shared with {1} ({2})", foundSheet.Sheet.Name, foundSheet.Share.Name, foundSheet.Share.Type));
注意:我提交了一个拉取请求以添加对返回工作区共享的特定 ListShares 重载的支持。这在 REST API 中可用,但在 C# SDK 中还没有。
注意:上面的代码还没有考虑Smartsheet Sights。应该可以为 Sights 使用相应的 REST API(即List Sights、List Sight Shares,但我认为 C# SDK 中还没有。