Page 1 of 1
HowTo Perform GetlatestVersion() through API
Posted: Thu Jun 21, 2007 6:27 am
by impact79
Hello,
i am new to the Vault API and have questions about how to accomplish a GetLatestVersion on a Repository subfolder.
Logging in into the server and setting the active repository already works, but how do i continue from here ?
Any help appreciated
Thanks,
impact79
Posted: Thu Jun 21, 2007 7:41 am
by jeremy_sg
Which version of Vault are you using?
Posted: Thu Jul 05, 2007 4:24 pm
by holdera
I used the get method of the ClientInstance object found in VaultClientOperationsLib. It is overloaded to work on a file, a folder or an array of files. I used the folder version to update all my files at once. make sure you understand what all the parameters do.
I didn't check the file out first or change its working directory, so it replaces all my local files with the most recent from the server. This is what I want, provided I am not currently working on anything in that directory. The params let you specify what to do with modified local files
Code: Select all
myClient.Get(searchFolder,true,true,MakeWritableType.MakeAllFilesReadOnly,SetFileTimeType.Current,MergeType.AttemptAutomaticMerge,null);
Posted: Mon Jan 28, 2008 5:02 pm
by Jinx
I've tried this but I always get the error "Value cannot be null. Parameter name: path".
I tried passing in the last variable also to no avail... here's my test code I was trying just to see if I could get it to work:
Code: Select all
Sub Main()
Dim Client As New VaultClientOperationsLib.ClientInstance()
Client.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client, "c:\Temp")
Client.Login("<<myserver>>", "<<myuser>>", "<<mypassword>>")
Dim Ri() As VaultRepositoryInfo
Client.ListRepositories(Ri)
For Each Bleh As VaultRepositoryInfo In Ri
If Bleh.RepName = "Default Repository" Then
Console.WriteLine("Default Repository found, Id=" & Bleh.RepID)
Client.SetActiveRepositoryID(Bleh.RepID, Client.Connection.Username, Bleh.UniqueRepID, True, False)
End If
Next
Dim Vf As VaultClientOperationsLib.VaultClientFolder = Client.Repository.Root.FindFolderRecursive("$/ETA2/Interfaces/FTI Weekend Update/")
Dim Cb As New VaultClientOperationsLib.PromptForOverwriteCallback(AddressOf Temp)
Dim Op As New VaultClientOperationsLib.OverwritePrompt(MergeType.OverwriteWorkingCopy, Cb)
Client.Get(Vf, False, True, MakeWritableType.MakeAllFilesWritable, SetFileTimeType.Current, MergeType.OverwriteWorkingCopy, Op)
End Sub
Function Temp() As Boolean
Return True ' :P
End Function
I also tried this as the client.get line from another post I saw here passing in a null for the last option... am I missing setting a path somewhere, and if so, where?:
Code: Select all
Client.Get(Vf, False, True, MakeWritableType.MakeAllFilesWritable, SetFileTimeType.Current, MergeType.OverwriteWorkingCopy, Nothing)
We're currently using 3.5.1 (4786)
Posted: Tue Jan 29, 2008 8:51 am
by jeremy_sg
Try removing the trailing slash from the folder path.
Posted: Tue Jan 29, 2008 9:16 am
by Jinx
Tried that, it still gets the same error on the Client.Get line which is "Value cannot be null. Parameter name: path"
It appears to be downloading a bunch of config files and information from the vault but never completes the operation.
I don't know if this makes a difference or not but the references I've included on the project are VaultClientNetLib, VaultClientOperationsLib & VaultLib. I didn't see where I was using anything outside of those.
Posted: Tue Jan 29, 2008 9:23 am
by jeremy_sg
It's also possible that you're trying to do a get on a folder that doesn't have a working folder set. Try setting the working folder first.
Posted: Tue Jan 29, 2008 10:39 am
by Jinx
You're correct, after looking through the object browser I figured out how to set the working folder. Below is the final example code snippet that works for posterity. Thank you for your assistance, it's much appreciated!
Code: Select all
Imports VaultClientOperationsLib
Imports VaultLib
Module Module1
Sub Main()
Dim Client As New VaultClientOperationsLib.ClientInstance()
Client.Init(VaultClientNetLib.VaultConnection.AccessLevelType.Client, "c:\New")
Client.Login("<<myserver>>", "<<myuser>>", "<<mypassword>>")
Dim Ri() As VaultRepositoryInfo
Client.ListRepositories(Ri)
For Each Bleh As VaultRepositoryInfo In Ri
If Bleh.RepName = "Default Repository" Then
Console.WriteLine("Default Repository found, Id=" & Bleh.RepID)
Client.SetActiveRepositoryID(Bleh.RepID, Client.Connection.Username, Bleh.UniqueRepID, True, False)
Client.TreeCache.SetWorkingFolder("$/ETA2/Interfaces/FTI Weekend Update", "C:\New")
End If
Next
Dim Vf As VaultClientOperationsLib.VaultClientFolder = Client.Repository.Root.FindFolderRecursive("$/ETA2/Interfaces/FTI Weekend Update")
Client.Get(Vf, True, True, MakeWritableType.MakeAllFilesWritable, SetFileTimeType.Current, MergeType.OverwriteWorkingCopy, Nothing)
End Sub
End Module