首先在Vault Explorer中可以這樣檢視和更改某個使用者組有權訪問的vault
Tools –> Administration –> Global Settings –> Groups… 開啟使用者組管理對話方塊, 雙擊某個組,點“Vaults…” 按鈕即可檢視和編輯這個組所能訪問的vault。
現在通過API來實現,沒啥說的,直接上程式碼:
using Autodesk.Connectivity.Explorer.Extensibility;
using Autodesk.Connectivity.WebServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VDF = Autodesk.DataManagement.Client.Framework;
namespace HelloWorldVaultExplorer
{
public class ListUserGroupVaults : IExplorerExtension
{
public IEnumerable<CommandSite> CommandSites()
{
CommandItem listGrougVaultsCmdItem = new CommandItem("HelloWorldVaultExplorer.ListUserGroupVaultsCmd",
"List Group Vaults - Daniel");
listGrougVaultsCmdItem.Execute += listGrougVaultsItem_Execute;
CommandSite toolsMenuSite = new CommandSite("ListUserGroupVaultsCmd.Toolbar",
"List Group Vaults Menu- Daniel");
toolsMenuSite.Location = CommandSiteLocation.ToolsMenu;
toolsMenuSite.AddCommand(listGrougVaultsCmdItem);
List<CommandSite> sites = new List<CommandSite>();
sites.Add(toolsMenuSite);
return sites;
}
void listGrougVaultsItem_Execute(object sender, CommandItemEventArgs e)
{
try
{
//using VDF = Autodesk.DataManagement.Client.Framework
VDF.Vault.Currency.Connections.Connection connection =
e.Context.Application.Connection;
string msg = "";
Group[] groups = connection.WebServiceManager.AdminService.GetAllGroups();
foreach (var group in groups)
{
GroupInfo grpInfo = connection.WebServiceManager.AdminService
.GetGroupInfoByGroupId(group.Id);
msg += grpInfo.Group.Name + "\n";
msg += "Group accessable vaults : \n";
if (grpInfo.Vaults == null)
{
msg += " this group has no accessable vaults. \n";
continue;
}
foreach (var vault in grpInfo.Vaults)
{
msg += vault.Id + ": " + vault.Name + "\n";
}
}
MessageBox.Show(msg);
}
catch (Exception ex)
{
// If something goes wrong, we don't want the exception to bubble up to Vault Explorer.
MessageBox.Show("Error: " + ex.Message);
}
}
}
}
結果: