Check for latest version

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
realtytrac
Posts: 34
Joined: Wed Jun 15, 2005 2:07 pm

Check for latest version

Post by realtytrac » Mon Jul 11, 2005 4:50 pm

I am doing a search on history items based on a specific search criterion. I want to be able to check if the version of the files found in the search is the latest version of the file or not.

I have the following code so far:

VaultLib.VaultHistoryItem[] items = new VaultLib.VaultHistoryItem[1];
_myClient.Connection.HistoryBegin(req, 100, ref rowsRetrieved, ref token);

if (rowsRetrieved > 0)
{
_myClient.Connection.HistoryFetch(token, 0, rowsRetrieved - 1, ref items);
}
_myClient.Connection.HistoryEnd(token);
foreach (VaultLib.VaultHistoryItem item in items)
{
newItem = new VaultVDDItem(fileName,version);
myList.Add(newItem);
fileName = item.Name;
version = (int)item.Version;
// VaultClientFolder searchFolder = _myClient.Repository.Root.FindFolderRecursive(VDDConstants.VaultFolder);
// VaultClientFile file = new VaultClientFile();
// RecursivelySearchForFileName(searchFolder,fileName,ref file);
// VaultFileProperties v = _myClient.GetFileProperties(item.Name,file.ObjVerID);
}

The stuff in comments i tried, but was not able to get it to work properly. Please advise.

Thanks

haider

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Tue Jul 12, 2005 7:34 am

How does the commented code fail? Also, to see if the history item is the same version as the file that you search to find, you can compare their objverids.

realtytrac
Posts: 34
Joined: Wed Jun 15, 2005 2:07 pm

Post by realtytrac » Tue Jul 12, 2005 9:35 am

Well i see how you can check the objID and if they match, then that means i have the latest version in the history item. However, that requires a recursive search which takes time off the clock. I want to use this function:

VaultFileProperties v = _myClient.GetFileProperties(fileName.Substring(fileName.LastIndexOf("/")+1),item.ObjVerID);

because VaultFileProperties has a .LatestVersion property which i assume is what i am looking for. However, when i pass the ObjVerID of the history item into the second parameter, i get the following error:

System.Web.Services.Protocols.SoapException: 1206 : FailObjPathInvalid

What values am i supposed to pass into the second parameter to achieve my objective.

Thanks a lot jeremy

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Tue Jul 12, 2005 9:46 am

You don't need GetFileProperties, because the vaultclientfile already has the objverid property. You can send the full current path to FindFileRecursive to get the current VaultClientFile object in the tree. That object will have the most recent objverid.

realtytrac
Posts: 34
Joined: Wed Jun 15, 2005 2:07 pm

Post by realtytrac » Tue Jul 12, 2005 9:57 am

i guess i will just use the recursive method. i thought the other method would be faster. Thanks for the help

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Tue Jul 12, 2005 9:59 am

FindFileRecursive is not slow at all. It's entirely client side and uses cached data. It will return null if the file isn't found or if there's a folder there.

Post Reply