HowTo Perform GetlatestVersion() through API
Moderator: SourceGear
HowTo Perform GetlatestVersion() through API
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
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
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
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);
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:
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?:
We're currently using 3.5.1 (4786)
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
Code: Select all
Client.Get(Vf, False, True, MakeWritableType.MakeAllFilesWritable, SetFileTimeType.Current, MergeType.OverwriteWorkingCopy, Nothing)
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.
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.
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