Hi,
I would like to share each file in a folder, but not the folders themselves. I can not figure out how to do this through vault without having to share each folder individually, so I am using the Vault Client API.
I am using version 3.5 Vault Client API and am having trouble using ChangeSetItem_CreateFolder. I am able to navigate through the tree and display all folders in vault, but I get an error when trying to create a new folder.
Here is my code:
shareToFolder and shareFromFolder are VaultClientFolder objects that the user has selected from a TreeView displayed on a UI.
After I am already logged in to vault, I do the following:
string fullFolderPath = shareToFolder.FullPath + "/" + shareFromFolder.Name + "/";
ClientInstance ci = new ClientInstance();
ci.UseFileSystemWatchers = false;
ci.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client);
ChangeSetItem_CreateFolder csaf = new ChangeSetItem_CreateFolder(
VaultDateTime.Now,
"Sharing by automated tool",
String.Empty,
fullFolderPath);
ChangeSetItemColl csic = new ChangeSetItemColl();
csic.Add(csaf);
ci.InternalChangeSet_Append(csic);
ci.Commit(csic);
I get the error at ci.InternalChangeSet_Append(csic)
The error is the following:
Message:"Object reference not set to an instance of an object."
Source:"VaultClientOperationsLib"
Any help on this would be appreciated. Thanks!
Problems with ChangeSetItem_CreateFolder
Moderator: SourceGear
Re: Problems with ChangeSetItem_CreateFolder
You need to set a repository. Look at ClientInstance.SetActiveRepositoryID
Re: Problems with ChangeSetItem_CreateFolder
I figured out what this problem was. I was not setting the repository. I have changed the code to set the repository as follows. However, now Commit is coming back with FALSE instead of TRUE and the folder is not being created. Any ideas?
public void LogIn()
{
_vaultClient.UseFileSystemWatchers = false;
_vaultClient.Init(VaultConnection.AccessLevelType.Client);
if (_vaultClient.ConnectionStateType == VaultClientOperationsLib.ConnectionStateType.Unconnected)
{
string url = "http://uslaxpxvault/VaultService/";
string user = "*****";
string password = "*****";
string repository = "phoenix";
_vaultClient.Login(url, user, password);
SetRepository(repository, user);
_vaultClient.EventEngine.addListener(this, typeof(MessageEvent));
_vaultClient.EventEngine.addListener(this, typeof(BulkMessageEvent));
}
}
private void RecursivelyShareFiles(VaultClientFolder shareFromFolder, VaultClientFolder shareToFolder)
{
//Create the share from folder under the share to folder
string fullFolderPath = shareToFolder.FullPath + "/" + shareFromFolder.Name;
_vaultClient.UseFileSystemWatchers = false;
_vaultClient.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client);
ChangeSetItem_CreateFolder csaf = new ChangeSetItem_CreateFolder(
VaultDateTime.Now,
"Sharing by automated tool",
String.Empty,
fullFolderPath);
ChangeSetItemColl csic = new ChangeSetItemColl();
csic.Add(csaf);
_vaultClient.InternalChangeSet_Append(csic);
_vaultClient.InternalChangeSet_SetComment("Sharing by automated tool");
bool result = _vaultClient.Commit(csic);
}
public void LogIn()
{
_vaultClient.UseFileSystemWatchers = false;
_vaultClient.Init(VaultConnection.AccessLevelType.Client);
if (_vaultClient.ConnectionStateType == VaultClientOperationsLib.ConnectionStateType.Unconnected)
{
string url = "http://uslaxpxvault/VaultService/";
string user = "*****";
string password = "*****";
string repository = "phoenix";
_vaultClient.Login(url, user, password);
SetRepository(repository, user);
_vaultClient.EventEngine.addListener(this, typeof(MessageEvent));
_vaultClient.EventEngine.addListener(this, typeof(BulkMessageEvent));
}
}
private void RecursivelyShareFiles(VaultClientFolder shareFromFolder, VaultClientFolder shareToFolder)
{
//Create the share from folder under the share to folder
string fullFolderPath = shareToFolder.FullPath + "/" + shareFromFolder.Name;
_vaultClient.UseFileSystemWatchers = false;
_vaultClient.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client);
ChangeSetItem_CreateFolder csaf = new ChangeSetItem_CreateFolder(
VaultDateTime.Now,
"Sharing by automated tool",
String.Empty,
fullFolderPath);
ChangeSetItemColl csic = new ChangeSetItemColl();
csic.Add(csaf);
_vaultClient.InternalChangeSet_Append(csic);
_vaultClient.InternalChangeSet_SetComment("Sharing by automated tool");
bool result = _vaultClient.Commit(csic);
}
Re: Problems with ChangeSetItem_CreateFolder
Shannon - Thank you for your response. I posted mine before I saw yours. Do you have any idea why commit is not working for me?
Thanks!
Thanks!
Re: Problems with ChangeSetItem_CreateFolder
Is there anything in the log file?
You shouldn't be calling these lines more than once:
_vaultClient.UseFileSystemWatchers = false;
_vaultClient.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client);
You shouldn't be calling these lines more than once:
_vaultClient.UseFileSystemWatchers = false;
_vaultClient.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client);